diff --git a/packages/google-cloud-gkehub/.eslintignore b/packages/google-cloud-gkehub/.eslintignore new file mode 100644 index 000000000000..cfc348ec4d11 --- /dev/null +++ b/packages/google-cloud-gkehub/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/packages/google-cloud-gkehub/.eslintrc.json b/packages/google-cloud-gkehub/.eslintrc.json new file mode 100644 index 000000000000..3e8d97ccb390 --- /dev/null +++ b/packages/google-cloud-gkehub/.eslintrc.json @@ -0,0 +1,4 @@ +{ + "extends": "./node_modules/gts", + "root": true +} diff --git a/packages/google-cloud-gkehub/README.md b/packages/google-cloud-gkehub/README.md index 7d257008baf1..814c1a6569dd 100644 --- a/packages/google-cloud-gkehub/README.md +++ b/packages/google-cloud-gkehub/README.md @@ -157,7 +157,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-gkehub/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`) @@ -167,7 +167,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-gkehub/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-gkehub/protos/protos.d.ts b/packages/google-cloud-gkehub/protos/protos.d.ts index 1b813bfa3e4c..c210252e8b53 100644 --- a/packages/google-cloud-gkehub/protos/protos.d.ts +++ b/packages/google-cloud-gkehub/protos/protos.d.ts @@ -223,6 +223,7 @@ export namespace google { /** Edition enum. */ enum Edition { EDITION_UNKNOWN = 0, + EDITION_LEGACY = 900, EDITION_PROTO2 = 998, EDITION_PROTO3 = 999, EDITION_2023 = 1000, @@ -253,6 +254,9 @@ export namespace google { /** FileDescriptorProto weakDependency */ weakDependency?: (number[]|null); + /** FileDescriptorProto optionDependency */ + optionDependency?: (string[]|null); + /** FileDescriptorProto messageType */ messageType?: (google.protobuf.IDescriptorProto[]|null); @@ -302,6 +306,9 @@ export namespace google { /** FileDescriptorProto weakDependency. */ public weakDependency: number[]; + /** FileDescriptorProto optionDependency. */ + public optionDependency: string[]; + /** FileDescriptorProto messageType. */ public messageType: google.protobuf.IDescriptorProto[]; @@ -436,6 +443,9 @@ export namespace google { /** DescriptorProto reservedName */ reservedName?: (string[]|null); + + /** DescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents a DescriptorProto. */ @@ -477,6 +487,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 @@ -1324,6 +1337,9 @@ export namespace google { /** EnumDescriptorProto reservedName */ reservedName?: (string[]|null); + + /** EnumDescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents an EnumDescriptorProto. */ @@ -1350,6 +1366,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 @@ -2284,6 +2303,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); @@ -2339,6 +2361,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[]; @@ -2559,6 +2584,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. */ @@ -2797,6 +2937,9 @@ export namespace google { /** EnumValueOptions debugRedact */ debugRedact?: (boolean|null); + /** EnumValueOptions featureSupport */ + featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** EnumValueOptions uninterpretedOption */ uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); } @@ -2819,6 +2962,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[]; @@ -3411,6 +3557,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. */ @@ -3440,6 +3592,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 @@ -3562,6 +3720,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. */ @@ -3681,8 +3949,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. */ @@ -3697,8 +3968,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. @@ -4231,6 +4505,13 @@ export namespace google { } } + /** SymbolVisibility enum. */ + enum SymbolVisibility { + VISIBILITY_UNSET = 0, + VISIBILITY_LOCAL = 1, + VISIBILITY_EXPORT = 2 + } + /** Properties of a Duration. */ interface IDuration { @@ -36749,6 +37030,9 @@ export namespace google { /** CommonLanguageSettings destinations */ destinations?: (google.api.ClientLibraryDestination[]|null); + + /** CommonLanguageSettings selectiveGapicGeneration */ + selectiveGapicGeneration?: (google.api.ISelectiveGapicGeneration|null); } /** Represents a CommonLanguageSettings. */ @@ -36766,6 +37050,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 @@ -37466,6 +37753,9 @@ export namespace google { /** PythonSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** PythonSettings experimentalFeatures */ + experimentalFeatures?: (google.api.PythonSettings.IExperimentalFeatures|null); } /** Represents a PythonSettings. */ @@ -37480,6 +37770,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 @@ -37558,6 +37851,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 { @@ -37884,6 +38289,9 @@ export namespace google { /** GoSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** GoSettings renamedServices */ + renamedServices?: ({ [k: string]: string }|null); } /** Represents a GoSettings. */ @@ -37898,6 +38306,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 @@ -38222,6 +38633,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, diff --git a/packages/google-cloud-gkehub/protos/protos.js b/packages/google-cloud-gkehub/protos/protos.js index c288bc54b5a6..18b0281cb97c 100644 --- a/packages/google-cloud-gkehub/protos/protos.js +++ b/packages/google-cloud-gkehub/protos/protos.js @@ -522,6 +522,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 @@ -536,6 +537,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; @@ -560,6 +562,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 @@ -582,6 +585,7 @@ this.dependency = []; this.publicDependency = []; this.weakDependency = []; + this.optionDependency = []; this.messageType = []; this.enumType = []; this.service = []; @@ -632,6 +636,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 @@ -753,6 +765,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; }; @@ -825,6 +840,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 = []; @@ -927,6 +948,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"; @@ -981,6 +1009,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -1033,6 +1062,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"); @@ -1096,6 +1132,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -1161,6 +1201,7 @@ object.extension = []; object.publicDependency = []; object.weakDependency = []; + object.optionDependency = []; } if (options.defaults) { object.name = ""; @@ -1217,6 +1258,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; }; @@ -1265,6 +1311,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 */ /** @@ -1370,6 +1417,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 @@ -1422,6 +1477,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; }; @@ -1514,6 +1571,10 @@ message.reservedName.push(reader.string()); break; } + case 11: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -1627,6 +1688,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; }; @@ -1726,6 +1796,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; }; @@ -1755,6 +1845,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; @@ -1800,6 +1891,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; }; @@ -3844,6 +3937,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 */ /** @@ -3904,6 +3998,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 @@ -3941,6 +4043,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; }; @@ -4003,6 +4107,10 @@ message.reservedName.push(reader.string()); break; } + case 6: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -4071,6 +4179,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; }; @@ -4120,6 +4237,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; }; @@ -4144,6 +4281,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; @@ -4164,6 +4302,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; }; @@ -6482,6 +6622,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 @@ -6602,6 +6743,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 @@ -6676,6 +6825,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(); @@ -6777,6 +6928,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 = []; @@ -6912,6 +7067,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"; @@ -7100,6 +7260,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"); @@ -7197,6 +7362,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")) @@ -7229,6 +7395,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) @@ -7501,6 +7669,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -7542,6 +7711,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -7641,6 +7814,488 @@ 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.editionRemoved = 1000; + break; + case "EDITION_2024": + case 1001: + message.editionRemoved = 1001; + break; + case "EDITION_1_TEST_ONLY": + case 1: + message.editionRemoved = 1; + break; + case "EDITION_2_TEST_ONLY": + case 2: + message.editionRemoved = 2; + break; + case "EDITION_99997_TEST_ONLY": + case 99997: + message.editionRemoved = 99997; + break; + case "EDITION_99998_TEST_ONLY": + case 99998: + message.editionRemoved = 99998; + break; + case "EDITION_99999_TEST_ONLY": + case 99999: + message.editionRemoved = 99999; + break; + case "EDITION_MAX": + case 2147483647: + message.editionRemoved = 2147483647; + break; + } + return message; + }; + + /** + * Creates a plain object from a FeatureSupport message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {google.protobuf.FieldOptions.FeatureSupport} message FeatureSupport + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FeatureSupport.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + 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 FeatureSupport to JSON. + * @function toJSON + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @instance + * @returns {Object.} JSON object + */ + FeatureSupport.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for FeatureSupport + * @function getTypeUrl + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + FeatureSupport.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.FieldOptions.FeatureSupport"; + }; + + return FeatureSupport; + })(); + return FieldOptions; })(); @@ -8233,6 +8888,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 */ @@ -8276,6 +8932,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 @@ -8314,6 +8978,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(); @@ -8365,6 +9031,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 = []; @@ -8417,6 +9087,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"; @@ -8450,6 +9125,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"); @@ -8482,6 +9162,7 @@ object.deprecated = false; object.features = null; object.debugRedact = false; + object.featureSupport = null; } if (message.deprecated != null && message.hasOwnProperty("deprecated")) object.deprecated = message.deprecated; @@ -8489,6 +9170,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) @@ -9956,6 +10639,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 */ /** @@ -10021,6 +10706,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 @@ -10057,6 +10758,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; }; @@ -10117,6 +10822,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; @@ -10207,6 +10920,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; }; @@ -10346,6 +11079,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; }; @@ -10369,6 +11150,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; @@ -10382,6 +11165,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; }; @@ -10509,6 +11296,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; })(); @@ -10693,6 +11693,7 @@ default: return "minimumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -10710,6 +11711,7 @@ default: return "maximumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -10758,6 +11760,10 @@ case 0: message.minimumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.minimumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.minimumEdition = 998; @@ -10810,6 +11816,10 @@ case 0: message.maximumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.maximumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.maximumEdition = 998; @@ -10918,7 +11928,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 */ /** @@ -10945,12 +11956,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. @@ -10976,10 +11995,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; }; @@ -11020,8 +12041,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: @@ -11064,6 +12089,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -11076,10 +12102,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; }; @@ -11107,6 +12138,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -11148,10 +12183,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; }; @@ -11170,13 +12210,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; }; @@ -12391,6 +13434,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() { /** @@ -94345,6 +95404,7 @@ * @interface ICommonLanguageSettings * @property {string|null} [referenceDocsUri] CommonLanguageSettings referenceDocsUri * @property {Array.|null} [destinations] CommonLanguageSettings destinations + * @property {google.api.ISelectiveGapicGeneration|null} [selectiveGapicGeneration] CommonLanguageSettings selectiveGapicGeneration */ /** @@ -94379,6 +95439,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 @@ -94411,6 +95479,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; }; @@ -94462,6 +95532,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; @@ -94513,6 +95587,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; }; @@ -94555,6 +95634,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; }; @@ -94573,8 +95657,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) { @@ -94582,6 +95668,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; }; @@ -96404,6 +97492,7 @@ * @memberof google.api * @interface IPythonSettings * @property {google.api.ICommonLanguageSettings|null} [common] PythonSettings common + * @property {google.api.PythonSettings.IExperimentalFeatures|null} [experimentalFeatures] PythonSettings experimentalFeatures */ /** @@ -96429,6 +97518,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 @@ -96455,6 +97552,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; }; @@ -96495,6 +97594,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; @@ -96535,6 +97638,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; }; @@ -96555,6 +97663,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; }; @@ -96571,10 +97684,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; }; @@ -96604,6 +97721,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; })(); @@ -97480,6 +98849,7 @@ * @memberof google.api * @interface IGoSettings * @property {google.api.ICommonLanguageSettings|null} [common] GoSettings common + * @property {Object.|null} [renamedServices] GoSettings renamedServices */ /** @@ -97491,6 +98861,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) @@ -97505,6 +98876,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 @@ -97531,6 +98910,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; }; @@ -97561,7 +98943,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) @@ -97571,6 +98953,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; @@ -97611,6 +99016,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; }; @@ -97631,6 +99044,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; }; @@ -97647,10 +99067,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; }; @@ -98289,6 +99717,251 @@ 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 diff --git a/packages/google-cloud-gkehub/protos/protos.json b/packages/google-cloud-gkehub/protos/protos.json index 085d6e28295e..aefc13144b4d 100644 --- a/packages/google-cloud-gkehub/protos/protos.json +++ b/packages/google-cloud-gkehub/protos/protos.json @@ -33,12 +33,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, @@ -77,6 +84,11 @@ "type": "int32", "id": 11 }, + "optionDependency": { + "rule": "repeated", + "type": "string", + "id": 15 + }, "messageType": { "rule": "repeated", "type": "DescriptorProto", @@ -165,6 +177,10 @@ "rule": "repeated", "type": "string", "id": 10 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 11 } }, "nested": { @@ -390,6 +406,10 @@ "rule": "repeated", "type": "string", "id": 5 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 6 } }, "nested": { @@ -440,7 +460,14 @@ "type": "ServiceOptions", "id": 3 } - } + }, + "reserved": [ + [ + 4, + 4 + ], + "stream" + ] }, "MethodDescriptorProto": { "edition": "proto2", @@ -604,6 +631,7 @@ 42, 42 ], + "php_generic_services", [ 38, 38 @@ -739,7 +767,8 @@ "type": "bool", "id": 10, "options": { - "default": false + "default": false, + "deprecated": true } }, "debugRedact": { @@ -767,6 +796,10 @@ "type": "FeatureSet", "id": 21 }, + "featureSupport": { + "type": "FeatureSupport", + "id": 22 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -836,6 +869,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 + } + } } } }, @@ -924,6 +977,10 @@ "default": false } }, + "featureSupport": { + "type": "FieldOptions.FeatureSupport", + "id": 4 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -1066,6 +1123,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_2023", "edition_defaults.value": "EXPLICIT" } @@ -1076,6 +1134,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "OPEN" } @@ -1086,6 +1145,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "PACKED" } @@ -1096,6 +1156,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "VERIFY" } @@ -1106,7 +1167,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" } }, @@ -1116,27 +1178,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, @@ -1181,7 +1254,13 @@ "UTF8_VALIDATION_UNKNOWN": 0, "VERIFY": 2, "NONE": 3 - } + }, + "reserved": [ + [ + 1, + 1 + ] + ] }, "MessageEncoding": { "values": { @@ -1196,6 +1275,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 + } + } + } } } }, @@ -1223,11 +1329,26 @@ "type": "Edition", "id": 3 }, - "features": { + "overridableFeatures": { "type": "FeatureSet", - "id": 2 + "id": 4 + }, + "fixedFeatures": { + "type": "FeatureSet", + "id": 5 } - } + }, + "reserved": [ + [ + 1, + 1 + ], + [ + 2, + 2 + ], + "features" + ] } } }, @@ -1240,6 +1361,12 @@ "id": 1 } }, + "extensions": [ + [ + 536000000, + 536000000 + ] + ], "nested": { "Location": { "fields": { @@ -1325,6 +1452,14 @@ } } }, + "SymbolVisibility": { + "edition": "proto2", + "values": { + "VISIBILITY_UNSET": 0, + "VISIBILITY_LOCAL": 1, + "VISIBILITY_EXPORT": 2 + } + }, "Duration": { "fields": { "seconds": { @@ -9896,8 +10031,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": { @@ -10120,6 +10254,10 @@ "rule": "repeated", "type": "ClientLibraryDestination", "id": 2 + }, + "selectiveGapicGeneration": { + "type": "SelectiveGapicGeneration", + "id": 3 } } }, @@ -10260,6 +10398,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 + } + } } } }, @@ -10317,6 +10477,11 @@ "common": { "type": "CommonLanguageSettings", "id": 1 + }, + "renamedServices": { + "keyType": "string", + "type": "string", + "id": 2 } } }, @@ -10378,6 +10543,19 @@ "PACKAGE_MANAGER": 20 } }, + "SelectiveGapicGeneration": { + "fields": { + "methods": { + "rule": "repeated", + "type": "string", + "id": 1 + }, + "generateOmittedAsInternal": { + "type": "bool", + "id": 2 + } + } + }, "LaunchStage": { "values": { "LAUNCH_STAGE_UNSPECIFIED": 0, @@ -10400,6 +10578,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-gkehub/samples/generated/v1/snippet_metadata_google.cloud.gkehub.v1.json b/packages/google-cloud-gkehub/samples/generated/v1/snippet_metadata_google.cloud.gkehub.v1.json index 15df274d7630..ff3c561623ff 100644 --- a/packages/google-cloud-gkehub/samples/generated/v1/snippet_metadata_google.cloud.gkehub.v1.json +++ b/packages/google-cloud-gkehub/samples/generated/v1/snippet_metadata_google.cloud.gkehub.v1.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-gkehub", - "version": "6.4.0", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-gkehub/samples/generated/v1alpha/snippet_metadata_google.cloud.gkehub.v1alpha.json b/packages/google-cloud-gkehub/samples/generated/v1alpha/snippet_metadata_google.cloud.gkehub.v1alpha.json index e02e53ebb3ee..f2c6d5fd1758 100644 --- a/packages/google-cloud-gkehub/samples/generated/v1alpha/snippet_metadata_google.cloud.gkehub.v1alpha.json +++ b/packages/google-cloud-gkehub/samples/generated/v1alpha/snippet_metadata_google.cloud.gkehub.v1alpha.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-gkehub", - "version": "6.4.0", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-gkehub/samples/generated/v1beta/snippet_metadata_google.cloud.gkehub.v1beta.json b/packages/google-cloud-gkehub/samples/generated/v1beta/snippet_metadata_google.cloud.gkehub.v1beta.json index f57f60b38d92..68cb273223a6 100644 --- a/packages/google-cloud-gkehub/samples/generated/v1beta/snippet_metadata_google.cloud.gkehub.v1beta.json +++ b/packages/google-cloud-gkehub/samples/generated/v1beta/snippet_metadata_google.cloud.gkehub.v1beta.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-gkehub", - "version": "6.4.0", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-gkehub/samples/generated/v1beta1/snippet_metadata_google.cloud.gkehub.v1beta1.json b/packages/google-cloud-gkehub/samples/generated/v1beta1/snippet_metadata_google.cloud.gkehub.v1beta1.json index 4a12f80239db..4efbecc60f8f 100644 --- a/packages/google-cloud-gkehub/samples/generated/v1beta1/snippet_metadata_google.cloud.gkehub.v1beta1.json +++ b/packages/google-cloud-gkehub/samples/generated/v1beta1/snippet_metadata_google.cloud.gkehub.v1beta1.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-gkehub", - "version": "6.4.0", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-gkehub/src/v1/gke_hub_client.ts b/packages/google-cloud-gkehub/src/v1/gke_hub_client.ts index e107b4508a9e..72415890dceb 100644 --- a/packages/google-cloud-gkehub/src/v1/gke_hub_client.ts +++ b/packages/google-cloud-gkehub/src/v1/gke_hub_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 @@ -60,7 +69,7 @@ export class GkeHubClient { 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('gke-hub'); @@ -73,10 +82,10 @@ export class GkeHubClient { 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; - gkeHubStub?: Promise<{[name: string]: Function}>; + gkeHubStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of GkeHubClient. @@ -117,21 +126,42 @@ export class GkeHubClient { * const client = new GkeHubClient({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 GkeHubClient; - 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 = 'gkehub.' + 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 GkeHubClient { 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,10 +200,7 @@ export class GkeHubClient { } // 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 { @@ -195,37 +222,39 @@ export class GkeHubClient { // Create useful helper objects for these. this.pathTemplates = { featurePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/features/{feature}' + 'projects/{project}/locations/{location}/features/{feature}', ), locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' + 'projects/{project}/locations/{location}', ), membershipPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/memberships/{membership}' + 'projects/{project}/locations/{location}/memberships/{membership}', ), membershipBindingPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/memberships/{membership}/bindings/{membershipbinding}' + 'projects/{project}/locations/{location}/memberships/{membership}/bindings/{membershipbinding}', ), namespacePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/scopes/{scope}/namespaces/{namespace}' + 'projects/{project}/locations/{location}/scopes/{scope}/namespaces/{namespace}', ), organizationLocationFleetPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/locations/{location}/fleets/{fleet}' + 'organizations/{organization}/locations/{location}/fleets/{fleet}', ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' + 'projects/{project}', ), projectLocationFleetPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/fleets/{fleet}' - ), - projectLocationMembershipRbacrolebindingPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/memberships/{membership}/rbacrolebindings/{rbacrolebinding}' - ), - projectLocationScopeRbacrolebindingPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/scopes/{scope}/rbacrolebindings/{rbacrolebinding}' + 'projects/{project}/locations/{location}/fleets/{fleet}', ), + projectLocationMembershipRbacrolebindingPathTemplate: + new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/memberships/{membership}/rbacrolebindings/{rbacrolebinding}', + ), + projectLocationScopeRbacrolebindingPathTemplate: + new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/scopes/{scope}/rbacrolebindings/{rbacrolebinding}', + ), scopePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/scopes/{scope}' + 'projects/{project}/locations/{location}/scopes/{scope}', ), }; @@ -233,26 +262,56 @@ export class GkeHubClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listMemberships: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'resources'), - listBoundMemberships: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'memberships'), - listFeatures: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'resources'), - listFleets: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'fleets'), - listScopeNamespaces: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'scopeNamespaces'), - listScopeRBACRoleBindings: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'rbacrolebindings'), - listScopes: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'scopes'), - listPermittedScopes: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'scopes'), - listMembershipBindings: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'membershipBindings'), - listMembershipRBACRoleBindings: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'rbacrolebindings') + listMemberships: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'resources', + ), + listBoundMemberships: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'memberships', + ), + listFeatures: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'resources', + ), + listFleets: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'fleets', + ), + listScopeNamespaces: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'scopeNamespaces', + ), + listScopeRBACRoleBindings: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'rbacrolebindings', + ), + listScopes: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'scopes', + ), + listPermittedScopes: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'scopes', + ), + listMembershipBindings: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'membershipBindings', + ), + listMembershipRBACRoleBindings: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'rbacrolebindings', + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -261,216 +320,386 @@ export class GkeHubClient { // rather than holding a request open. const lroOptions: GrpcClientOptions = { auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1/{name=projects/*}/locations',},{selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',get: '/v1/{resource=projects/*/locations/*/memberships/*}:getIamPolicy',additional_bindings: [{get: '/v1/{resource=projects/*/locations/*/features/*}:getIamPolicy',}], - },{selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',post: '/v1/{resource=projects/*/locations/*/memberships/*}:setIamPolicy',body: '*',additional_bindings: [{post: '/v1/{resource=projects/*/locations/*/features/*}:setIamPolicy',body: '*',}], - },{selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',post: '/v1/{resource=projects/*/locations/*/memberships/*}:testIamPermissions',body: '*',additional_bindings: [{post: '/v1/{resource=projects/*/locations/*/features/*}:testIamPermissions',body: '*',}], - },{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1/{name=projects/*/locations/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1/{name=projects/*/locations/*}/operations',}]; + lroOptions.httpRules = [ + { + selector: 'google.cloud.location.Locations.GetLocation', + get: '/v1/{name=projects/*/locations/*}', + }, + { + selector: 'google.cloud.location.Locations.ListLocations', + get: '/v1/{name=projects/*}/locations', + }, + { + selector: 'google.iam.v1.IAMPolicy.GetIamPolicy', + get: '/v1/{resource=projects/*/locations/*/memberships/*}:getIamPolicy', + additional_bindings: [ + { + get: '/v1/{resource=projects/*/locations/*/features/*}:getIamPolicy', + }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.SetIamPolicy', + post: '/v1/{resource=projects/*/locations/*/memberships/*}:setIamPolicy', + body: '*', + additional_bindings: [ + { + post: '/v1/{resource=projects/*/locations/*/features/*}:setIamPolicy', + body: '*', + }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.TestIamPermissions', + post: '/v1/{resource=projects/*/locations/*/memberships/*}:testIamPermissions', + body: '*', + additional_bindings: [ + { + post: '/v1/{resource=projects/*/locations/*/features/*}:testIamPermissions', + body: '*', + }, + ], + }, + { + selector: 'google.longrunning.Operations.CancelOperation', + post: '/v1/{name=projects/*/locations/*/operations/*}:cancel', + body: '*', + }, + { + selector: 'google.longrunning.Operations.DeleteOperation', + delete: '/v1/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v1/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v1/{name=projects/*/locations/*}/operations', + }, + ]; } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); const createMembershipResponse = protoFilesRoot.lookup( - '.google.cloud.gkehub.v1.Membership') as gax.protobuf.Type; + '.google.cloud.gkehub.v1.Membership', + ) as gax.protobuf.Type; const createMembershipMetadata = protoFilesRoot.lookup( - '.google.cloud.gkehub.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.gkehub.v1.OperationMetadata', + ) as gax.protobuf.Type; const createFeatureResponse = protoFilesRoot.lookup( - '.google.cloud.gkehub.v1.Feature') as gax.protobuf.Type; + '.google.cloud.gkehub.v1.Feature', + ) as gax.protobuf.Type; const createFeatureMetadata = protoFilesRoot.lookup( - '.google.cloud.gkehub.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.gkehub.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteMembershipResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteMembershipMetadata = protoFilesRoot.lookup( - '.google.cloud.gkehub.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.gkehub.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteFeatureResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteFeatureMetadata = protoFilesRoot.lookup( - '.google.cloud.gkehub.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.gkehub.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateMembershipResponse = protoFilesRoot.lookup( - '.google.cloud.gkehub.v1.Membership') as gax.protobuf.Type; + '.google.cloud.gkehub.v1.Membership', + ) as gax.protobuf.Type; const updateMembershipMetadata = protoFilesRoot.lookup( - '.google.cloud.gkehub.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.gkehub.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateFeatureResponse = protoFilesRoot.lookup( - '.google.cloud.gkehub.v1.Feature') as gax.protobuf.Type; + '.google.cloud.gkehub.v1.Feature', + ) as gax.protobuf.Type; const updateFeatureMetadata = protoFilesRoot.lookup( - '.google.cloud.gkehub.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.gkehub.v1.OperationMetadata', + ) as gax.protobuf.Type; const createFleetResponse = protoFilesRoot.lookup( - '.google.cloud.gkehub.v1.Fleet') as gax.protobuf.Type; + '.google.cloud.gkehub.v1.Fleet', + ) as gax.protobuf.Type; const createFleetMetadata = protoFilesRoot.lookup( - '.google.cloud.gkehub.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.gkehub.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateFleetResponse = protoFilesRoot.lookup( - '.google.cloud.gkehub.v1.Fleet') as gax.protobuf.Type; + '.google.cloud.gkehub.v1.Fleet', + ) as gax.protobuf.Type; const updateFleetMetadata = protoFilesRoot.lookup( - '.google.cloud.gkehub.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.gkehub.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteFleetResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteFleetMetadata = protoFilesRoot.lookup( - '.google.cloud.gkehub.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.gkehub.v1.OperationMetadata', + ) as gax.protobuf.Type; const createScopeNamespaceResponse = protoFilesRoot.lookup( - '.google.cloud.gkehub.v1.Namespace') as gax.protobuf.Type; + '.google.cloud.gkehub.v1.Namespace', + ) as gax.protobuf.Type; const createScopeNamespaceMetadata = protoFilesRoot.lookup( - '.google.cloud.gkehub.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.gkehub.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateScopeNamespaceResponse = protoFilesRoot.lookup( - '.google.cloud.gkehub.v1.Namespace') as gax.protobuf.Type; + '.google.cloud.gkehub.v1.Namespace', + ) as gax.protobuf.Type; const updateScopeNamespaceMetadata = protoFilesRoot.lookup( - '.google.cloud.gkehub.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.gkehub.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteScopeNamespaceResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteScopeNamespaceMetadata = protoFilesRoot.lookup( - '.google.cloud.gkehub.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.gkehub.v1.OperationMetadata', + ) as gax.protobuf.Type; const createScopeRBACRoleBindingResponse = protoFilesRoot.lookup( - '.google.cloud.gkehub.v1.RBACRoleBinding') as gax.protobuf.Type; + '.google.cloud.gkehub.v1.RBACRoleBinding', + ) as gax.protobuf.Type; const createScopeRBACRoleBindingMetadata = protoFilesRoot.lookup( - '.google.cloud.gkehub.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.gkehub.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateScopeRBACRoleBindingResponse = protoFilesRoot.lookup( - '.google.cloud.gkehub.v1.RBACRoleBinding') as gax.protobuf.Type; + '.google.cloud.gkehub.v1.RBACRoleBinding', + ) as gax.protobuf.Type; const updateScopeRBACRoleBindingMetadata = protoFilesRoot.lookup( - '.google.cloud.gkehub.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.gkehub.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteScopeRBACRoleBindingResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteScopeRBACRoleBindingMetadata = protoFilesRoot.lookup( - '.google.cloud.gkehub.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.gkehub.v1.OperationMetadata', + ) as gax.protobuf.Type; const createScopeResponse = protoFilesRoot.lookup( - '.google.cloud.gkehub.v1.Scope') as gax.protobuf.Type; + '.google.cloud.gkehub.v1.Scope', + ) as gax.protobuf.Type; const createScopeMetadata = protoFilesRoot.lookup( - '.google.cloud.gkehub.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.gkehub.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateScopeResponse = protoFilesRoot.lookup( - '.google.cloud.gkehub.v1.Scope') as gax.protobuf.Type; + '.google.cloud.gkehub.v1.Scope', + ) as gax.protobuf.Type; const updateScopeMetadata = protoFilesRoot.lookup( - '.google.cloud.gkehub.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.gkehub.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteScopeResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteScopeMetadata = protoFilesRoot.lookup( - '.google.cloud.gkehub.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.gkehub.v1.OperationMetadata', + ) as gax.protobuf.Type; const createMembershipBindingResponse = protoFilesRoot.lookup( - '.google.cloud.gkehub.v1.MembershipBinding') as gax.protobuf.Type; + '.google.cloud.gkehub.v1.MembershipBinding', + ) as gax.protobuf.Type; const createMembershipBindingMetadata = protoFilesRoot.lookup( - '.google.cloud.gkehub.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.gkehub.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateMembershipBindingResponse = protoFilesRoot.lookup( - '.google.cloud.gkehub.v1.MembershipBinding') as gax.protobuf.Type; + '.google.cloud.gkehub.v1.MembershipBinding', + ) as gax.protobuf.Type; const updateMembershipBindingMetadata = protoFilesRoot.lookup( - '.google.cloud.gkehub.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.gkehub.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteMembershipBindingResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteMembershipBindingMetadata = protoFilesRoot.lookup( - '.google.cloud.gkehub.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.gkehub.v1.OperationMetadata', + ) as gax.protobuf.Type; const createMembershipRBACRoleBindingResponse = protoFilesRoot.lookup( - '.google.cloud.gkehub.v1.RBACRoleBinding') as gax.protobuf.Type; + '.google.cloud.gkehub.v1.RBACRoleBinding', + ) as gax.protobuf.Type; const createMembershipRBACRoleBindingMetadata = protoFilesRoot.lookup( - '.google.cloud.gkehub.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.gkehub.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateMembershipRBACRoleBindingResponse = protoFilesRoot.lookup( - '.google.cloud.gkehub.v1.RBACRoleBinding') as gax.protobuf.Type; + '.google.cloud.gkehub.v1.RBACRoleBinding', + ) as gax.protobuf.Type; const updateMembershipRBACRoleBindingMetadata = protoFilesRoot.lookup( - '.google.cloud.gkehub.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.gkehub.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteMembershipRBACRoleBindingResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteMembershipRBACRoleBindingMetadata = protoFilesRoot.lookup( - '.google.cloud.gkehub.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.gkehub.v1.OperationMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { createMembership: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createMembershipResponse.decode.bind(createMembershipResponse), - createMembershipMetadata.decode.bind(createMembershipMetadata)), + createMembershipMetadata.decode.bind(createMembershipMetadata), + ), createFeature: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createFeatureResponse.decode.bind(createFeatureResponse), - createFeatureMetadata.decode.bind(createFeatureMetadata)), + createFeatureMetadata.decode.bind(createFeatureMetadata), + ), deleteMembership: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteMembershipResponse.decode.bind(deleteMembershipResponse), - deleteMembershipMetadata.decode.bind(deleteMembershipMetadata)), + deleteMembershipMetadata.decode.bind(deleteMembershipMetadata), + ), deleteFeature: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteFeatureResponse.decode.bind(deleteFeatureResponse), - deleteFeatureMetadata.decode.bind(deleteFeatureMetadata)), + deleteFeatureMetadata.decode.bind(deleteFeatureMetadata), + ), updateMembership: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateMembershipResponse.decode.bind(updateMembershipResponse), - updateMembershipMetadata.decode.bind(updateMembershipMetadata)), + updateMembershipMetadata.decode.bind(updateMembershipMetadata), + ), updateFeature: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateFeatureResponse.decode.bind(updateFeatureResponse), - updateFeatureMetadata.decode.bind(updateFeatureMetadata)), + updateFeatureMetadata.decode.bind(updateFeatureMetadata), + ), createFleet: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createFleetResponse.decode.bind(createFleetResponse), - createFleetMetadata.decode.bind(createFleetMetadata)), + createFleetMetadata.decode.bind(createFleetMetadata), + ), updateFleet: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateFleetResponse.decode.bind(updateFleetResponse), - updateFleetMetadata.decode.bind(updateFleetMetadata)), + updateFleetMetadata.decode.bind(updateFleetMetadata), + ), deleteFleet: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteFleetResponse.decode.bind(deleteFleetResponse), - deleteFleetMetadata.decode.bind(deleteFleetMetadata)), + deleteFleetMetadata.decode.bind(deleteFleetMetadata), + ), createScopeNamespace: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createScopeNamespaceResponse.decode.bind(createScopeNamespaceResponse), - createScopeNamespaceMetadata.decode.bind(createScopeNamespaceMetadata)), + createScopeNamespaceMetadata.decode.bind(createScopeNamespaceMetadata), + ), updateScopeNamespace: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateScopeNamespaceResponse.decode.bind(updateScopeNamespaceResponse), - updateScopeNamespaceMetadata.decode.bind(updateScopeNamespaceMetadata)), + updateScopeNamespaceMetadata.decode.bind(updateScopeNamespaceMetadata), + ), deleteScopeNamespace: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteScopeNamespaceResponse.decode.bind(deleteScopeNamespaceResponse), - deleteScopeNamespaceMetadata.decode.bind(deleteScopeNamespaceMetadata)), + deleteScopeNamespaceMetadata.decode.bind(deleteScopeNamespaceMetadata), + ), createScopeRBACRoleBinding: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - createScopeRBACRoleBindingResponse.decode.bind(createScopeRBACRoleBindingResponse), - createScopeRBACRoleBindingMetadata.decode.bind(createScopeRBACRoleBindingMetadata)), + createScopeRBACRoleBindingResponse.decode.bind( + createScopeRBACRoleBindingResponse, + ), + createScopeRBACRoleBindingMetadata.decode.bind( + createScopeRBACRoleBindingMetadata, + ), + ), updateScopeRBACRoleBinding: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - updateScopeRBACRoleBindingResponse.decode.bind(updateScopeRBACRoleBindingResponse), - updateScopeRBACRoleBindingMetadata.decode.bind(updateScopeRBACRoleBindingMetadata)), + updateScopeRBACRoleBindingResponse.decode.bind( + updateScopeRBACRoleBindingResponse, + ), + updateScopeRBACRoleBindingMetadata.decode.bind( + updateScopeRBACRoleBindingMetadata, + ), + ), deleteScopeRBACRoleBinding: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - deleteScopeRBACRoleBindingResponse.decode.bind(deleteScopeRBACRoleBindingResponse), - deleteScopeRBACRoleBindingMetadata.decode.bind(deleteScopeRBACRoleBindingMetadata)), + deleteScopeRBACRoleBindingResponse.decode.bind( + deleteScopeRBACRoleBindingResponse, + ), + deleteScopeRBACRoleBindingMetadata.decode.bind( + deleteScopeRBACRoleBindingMetadata, + ), + ), createScope: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createScopeResponse.decode.bind(createScopeResponse), - createScopeMetadata.decode.bind(createScopeMetadata)), + createScopeMetadata.decode.bind(createScopeMetadata), + ), updateScope: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateScopeResponse.decode.bind(updateScopeResponse), - updateScopeMetadata.decode.bind(updateScopeMetadata)), + updateScopeMetadata.decode.bind(updateScopeMetadata), + ), deleteScope: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteScopeResponse.decode.bind(deleteScopeResponse), - deleteScopeMetadata.decode.bind(deleteScopeMetadata)), + deleteScopeMetadata.decode.bind(deleteScopeMetadata), + ), createMembershipBinding: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - createMembershipBindingResponse.decode.bind(createMembershipBindingResponse), - createMembershipBindingMetadata.decode.bind(createMembershipBindingMetadata)), + createMembershipBindingResponse.decode.bind( + createMembershipBindingResponse, + ), + createMembershipBindingMetadata.decode.bind( + createMembershipBindingMetadata, + ), + ), updateMembershipBinding: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - updateMembershipBindingResponse.decode.bind(updateMembershipBindingResponse), - updateMembershipBindingMetadata.decode.bind(updateMembershipBindingMetadata)), + updateMembershipBindingResponse.decode.bind( + updateMembershipBindingResponse, + ), + updateMembershipBindingMetadata.decode.bind( + updateMembershipBindingMetadata, + ), + ), deleteMembershipBinding: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - deleteMembershipBindingResponse.decode.bind(deleteMembershipBindingResponse), - deleteMembershipBindingMetadata.decode.bind(deleteMembershipBindingMetadata)), - createMembershipRBACRoleBinding: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createMembershipRBACRoleBindingResponse.decode.bind(createMembershipRBACRoleBindingResponse), - createMembershipRBACRoleBindingMetadata.decode.bind(createMembershipRBACRoleBindingMetadata)), - updateMembershipRBACRoleBinding: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - updateMembershipRBACRoleBindingResponse.decode.bind(updateMembershipRBACRoleBindingResponse), - updateMembershipRBACRoleBindingMetadata.decode.bind(updateMembershipRBACRoleBindingMetadata)), - deleteMembershipRBACRoleBinding: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - deleteMembershipRBACRoleBindingResponse.decode.bind(deleteMembershipRBACRoleBindingResponse), - deleteMembershipRBACRoleBindingMetadata.decode.bind(deleteMembershipRBACRoleBindingMetadata)) + deleteMembershipBindingResponse.decode.bind( + deleteMembershipBindingResponse, + ), + deleteMembershipBindingMetadata.decode.bind( + deleteMembershipBindingMetadata, + ), + ), + createMembershipRBACRoleBinding: + new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createMembershipRBACRoleBindingResponse.decode.bind( + createMembershipRBACRoleBindingResponse, + ), + createMembershipRBACRoleBindingMetadata.decode.bind( + createMembershipRBACRoleBindingMetadata, + ), + ), + updateMembershipRBACRoleBinding: + new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + updateMembershipRBACRoleBindingResponse.decode.bind( + updateMembershipRBACRoleBindingResponse, + ), + updateMembershipRBACRoleBindingMetadata.decode.bind( + updateMembershipRBACRoleBindingMetadata, + ), + ), + deleteMembershipRBACRoleBinding: + new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteMembershipRBACRoleBindingResponse.decode.bind( + deleteMembershipRBACRoleBindingResponse, + ), + deleteMembershipRBACRoleBindingMetadata.decode.bind( + deleteMembershipRBACRoleBindingMetadata, + ), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.gkehub.v1.GkeHub', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.gkehub.v1.GkeHub', + 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 @@ -501,28 +730,78 @@ export class GkeHubClient { // Put together the "service stub" for // google.cloud.gkehub.v1.GkeHub. this.gkeHubStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.gkehub.v1.GkeHub') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.gkehub.v1.GkeHub', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.gkehub.v1.GkeHub, - 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 gkeHubStubMethods = - ['listMemberships', 'listBoundMemberships', 'listFeatures', 'getMembership', 'getFeature', 'createMembership', 'createFeature', 'deleteMembership', 'deleteFeature', 'updateMembership', 'updateFeature', 'generateConnectManifest', 'createFleet', 'getFleet', 'updateFleet', 'deleteFleet', 'listFleets', 'getScopeNamespace', 'createScopeNamespace', 'updateScopeNamespace', 'deleteScopeNamespace', 'listScopeNamespaces', 'getScopeRbacRoleBinding', 'createScopeRbacRoleBinding', 'updateScopeRbacRoleBinding', 'deleteScopeRbacRoleBinding', 'listScopeRbacRoleBindings', 'getScope', 'createScope', 'updateScope', 'deleteScope', 'listScopes', 'listPermittedScopes', 'getMembershipBinding', 'createMembershipBinding', 'updateMembershipBinding', 'deleteMembershipBinding', 'listMembershipBindings', 'getMembershipRbacRoleBinding', 'createMembershipRbacRoleBinding', 'updateMembershipRbacRoleBinding', 'deleteMembershipRbacRoleBinding', 'listMembershipRbacRoleBindings', 'generateMembershipRbacRoleBindingYamL']; + const gkeHubStubMethods = [ + 'listMemberships', + 'listBoundMemberships', + 'listFeatures', + 'getMembership', + 'getFeature', + 'createMembership', + 'createFeature', + 'deleteMembership', + 'deleteFeature', + 'updateMembership', + 'updateFeature', + 'generateConnectManifest', + 'createFleet', + 'getFleet', + 'updateFleet', + 'deleteFleet', + 'listFleets', + 'getScopeNamespace', + 'createScopeNamespace', + 'updateScopeNamespace', + 'deleteScopeNamespace', + 'listScopeNamespaces', + 'getScopeRbacRoleBinding', + 'createScopeRbacRoleBinding', + 'updateScopeRbacRoleBinding', + 'deleteScopeRbacRoleBinding', + 'listScopeRbacRoleBindings', + 'getScope', + 'createScope', + 'updateScope', + 'deleteScope', + 'listScopes', + 'listPermittedScopes', + 'getMembershipBinding', + 'createMembershipBinding', + 'updateMembershipBinding', + 'deleteMembershipBinding', + 'listMembershipBindings', + 'getMembershipRbacRoleBinding', + 'createMembershipRbacRoleBinding', + 'updateMembershipRbacRoleBinding', + 'deleteMembershipRbacRoleBinding', + 'listMembershipRbacRoleBindings', + 'generateMembershipRbacRoleBindingYamL', + ]; for (const methodName of gkeHubStubMethods) { const callPromise = this.gkeHubStub.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] || @@ -532,7 +811,7 @@ export class GkeHubClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -547,8 +826,14 @@ export class GkeHubClient { * @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 'gkehub.googleapis.com'; } @@ -559,8 +844,14 @@ export class GkeHubClient { * @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 'gkehub.googleapis.com'; } @@ -591,9 +882,7 @@ export class GkeHubClient { * @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; @@ -602,8 +891,9 @@ export class GkeHubClient { * 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; @@ -614,3905 +904,5827 @@ export class GkeHubClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Gets the details of a Membership. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The Membership resource name in the format - * `projects/* /locations/* /memberships/*`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.gkehub.v1.Membership|Membership}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_hub.get_membership.js - * region_tag:gkehub_v1_generated_GkeHub_GetMembership_async - */ + /** + * Gets the details of a Membership. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The Membership resource name in the format + * `projects/* /locations/* /memberships/*`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.gkehub.v1.Membership|Membership}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_hub.get_membership.js + * region_tag:gkehub_v1_generated_GkeHub_GetMembership_async + */ getMembership( - request?: protos.google.cloud.gkehub.v1.IGetMembershipRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gkehub.v1.IMembership, - protos.google.cloud.gkehub.v1.IGetMembershipRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkehub.v1.IGetMembershipRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gkehub.v1.IMembership, + protos.google.cloud.gkehub.v1.IGetMembershipRequest | undefined, + {} | undefined, + ] + >; getMembership( - request: protos.google.cloud.gkehub.v1.IGetMembershipRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.gkehub.v1.IMembership, - protos.google.cloud.gkehub.v1.IGetMembershipRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.IGetMembershipRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.gkehub.v1.IMembership, + protos.google.cloud.gkehub.v1.IGetMembershipRequest | null | undefined, + {} | null | undefined + >, + ): void; getMembership( - request: protos.google.cloud.gkehub.v1.IGetMembershipRequest, - callback: Callback< - protos.google.cloud.gkehub.v1.IMembership, - protos.google.cloud.gkehub.v1.IGetMembershipRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.IGetMembershipRequest, + callback: Callback< + protos.google.cloud.gkehub.v1.IMembership, + protos.google.cloud.gkehub.v1.IGetMembershipRequest | null | undefined, + {} | null | undefined + >, + ): void; getMembership( - request?: protos.google.cloud.gkehub.v1.IGetMembershipRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.gkehub.v1.IMembership, - protos.google.cloud.gkehub.v1.IGetMembershipRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.gkehub.v1.IGetMembershipRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.gkehub.v1.IMembership, - protos.google.cloud.gkehub.v1.IGetMembershipRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.gkehub.v1.IMembership, - protos.google.cloud.gkehub.v1.IGetMembershipRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.gkehub.v1.IGetMembershipRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.gkehub.v1.IMembership, + protos.google.cloud.gkehub.v1.IGetMembershipRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.gkehub.v1.IMembership, + protos.google.cloud.gkehub.v1.IGetMembershipRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getMembership request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.gkehub.v1.IMembership, - protos.google.cloud.gkehub.v1.IGetMembershipRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.gkehub.v1.IMembership, + | protos.google.cloud.gkehub.v1.IGetMembershipRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getMembership response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getMembership(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.gkehub.v1.IMembership, - protos.google.cloud.gkehub.v1.IGetMembershipRequest|undefined, - {}|undefined - ]) => { - this._log.info('getMembership response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getMembership(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.gkehub.v1.IMembership, + protos.google.cloud.gkehub.v1.IGetMembershipRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getMembership response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 Feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The Feature resource name in the format - * `projects/* /locations/* /features/*` - * @param {boolean} [request.returnPartialSuccess] - * Optional. If set to true, the response will return partial results when - * some regions are unreachable and the unreachable field in Feature proto - * will be populated. If set to false, the request will fail when some regions - * are unreachable. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.gkehub.v1.Feature|Feature}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_hub.get_feature.js - * region_tag:gkehub_v1_generated_GkeHub_GetFeature_async - */ + /** + * Gets details of a single Feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The Feature resource name in the format + * `projects/* /locations/* /features/*` + * @param {boolean} [request.returnPartialSuccess] + * Optional. If set to true, the response will return partial results when + * some regions are unreachable and the unreachable field in Feature proto + * will be populated. If set to false, the request will fail when some regions + * are unreachable. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.gkehub.v1.Feature|Feature}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_hub.get_feature.js + * region_tag:gkehub_v1_generated_GkeHub_GetFeature_async + */ getFeature( - request?: protos.google.cloud.gkehub.v1.IGetFeatureRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gkehub.v1.IFeature, - protos.google.cloud.gkehub.v1.IGetFeatureRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkehub.v1.IGetFeatureRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gkehub.v1.IFeature, + protos.google.cloud.gkehub.v1.IGetFeatureRequest | undefined, + {} | undefined, + ] + >; getFeature( - request: protos.google.cloud.gkehub.v1.IGetFeatureRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.gkehub.v1.IFeature, - protos.google.cloud.gkehub.v1.IGetFeatureRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.IGetFeatureRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.gkehub.v1.IFeature, + protos.google.cloud.gkehub.v1.IGetFeatureRequest | null | undefined, + {} | null | undefined + >, + ): void; getFeature( - request: protos.google.cloud.gkehub.v1.IGetFeatureRequest, - callback: Callback< - protos.google.cloud.gkehub.v1.IFeature, - protos.google.cloud.gkehub.v1.IGetFeatureRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.IGetFeatureRequest, + callback: Callback< + protos.google.cloud.gkehub.v1.IFeature, + protos.google.cloud.gkehub.v1.IGetFeatureRequest | null | undefined, + {} | null | undefined + >, + ): void; getFeature( - request?: protos.google.cloud.gkehub.v1.IGetFeatureRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.gkehub.v1.IGetFeatureRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.gkehub.v1.IFeature, - protos.google.cloud.gkehub.v1.IGetFeatureRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.gkehub.v1.IFeature, - protos.google.cloud.gkehub.v1.IGetFeatureRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.gkehub.v1.IFeature, - protos.google.cloud.gkehub.v1.IGetFeatureRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.gkehub.v1.IGetFeatureRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.gkehub.v1.IFeature, + protos.google.cloud.gkehub.v1.IGetFeatureRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.gkehub.v1.IFeature, + protos.google.cloud.gkehub.v1.IGetFeatureRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getFeature request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.gkehub.v1.IFeature, - protos.google.cloud.gkehub.v1.IGetFeatureRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.gkehub.v1.IFeature, + protos.google.cloud.gkehub.v1.IGetFeatureRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getFeature response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getFeature(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.gkehub.v1.IFeature, - protos.google.cloud.gkehub.v1.IGetFeatureRequest|undefined, - {}|undefined - ]) => { - this._log.info('getFeature response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getFeature(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.gkehub.v1.IFeature, + protos.google.cloud.gkehub.v1.IGetFeatureRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getFeature response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 the manifest for deployment of the GKE connect agent. - * - * **This method is used internally by Google-provided libraries.** - * Most clients should not need to call this method directly. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The Membership resource name the Agent will associate with, in - * the format `projects/* /locations/* /memberships/*`. - * @param {string} [request.namespace] - * Optional. Namespace for GKE Connect agent resources. Defaults to - * `gke-connect`. - * - * The Connect Agent is authorized automatically when run in the default - * namespace. Otherwise, explicit authorization must be granted with an - * additional IAM binding. - * @param {Buffer} [request.proxy] - * Optional. URI of a proxy if connectivity from the agent to - * gkeconnect.googleapis.com requires the use of a proxy. Format must be in - * the form `http(s)://{proxy_address}`, depending on the HTTP/HTTPS protocol - * supported by the proxy. This will direct the connect agent's outbound - * traffic through a HTTP(S) proxy. - * @param {string} [request.version] - * Optional. The Connect agent version to use. Defaults to the most current - * version. - * @param {boolean} [request.isUpgrade] - * Optional. If true, generate the resources for upgrade only. Some resources - * generated only for installation (e.g. secrets) will be excluded. - * @param {string} [request.registry] - * Optional. The registry to fetch the connect agent image from. Defaults to - * gcr.io/gkeconnect. - * @param {Buffer} [request.imagePullSecretContent] - * Optional. The image pull secret content for the registry, if not public. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.gkehub.v1.GenerateConnectManifestResponse|GenerateConnectManifestResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_hub.generate_connect_manifest.js - * region_tag:gkehub_v1_generated_GkeHub_GenerateConnectManifest_async - */ + /** + * Generates the manifest for deployment of the GKE connect agent. + * + * **This method is used internally by Google-provided libraries.** + * Most clients should not need to call this method directly. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The Membership resource name the Agent will associate with, in + * the format `projects/* /locations/* /memberships/*`. + * @param {string} [request.namespace] + * Optional. Namespace for GKE Connect agent resources. Defaults to + * `gke-connect`. + * + * The Connect Agent is authorized automatically when run in the default + * namespace. Otherwise, explicit authorization must be granted with an + * additional IAM binding. + * @param {Buffer} [request.proxy] + * Optional. URI of a proxy if connectivity from the agent to + * gkeconnect.googleapis.com requires the use of a proxy. Format must be in + * the form `http(s)://{proxy_address}`, depending on the HTTP/HTTPS protocol + * supported by the proxy. This will direct the connect agent's outbound + * traffic through a HTTP(S) proxy. + * @param {string} [request.version] + * Optional. The Connect agent version to use. Defaults to the most current + * version. + * @param {boolean} [request.isUpgrade] + * Optional. If true, generate the resources for upgrade only. Some resources + * generated only for installation (e.g. secrets) will be excluded. + * @param {string} [request.registry] + * Optional. The registry to fetch the connect agent image from. Defaults to + * gcr.io/gkeconnect. + * @param {Buffer} [request.imagePullSecretContent] + * Optional. The image pull secret content for the registry, if not public. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.gkehub.v1.GenerateConnectManifestResponse|GenerateConnectManifestResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_hub.generate_connect_manifest.js + * region_tag:gkehub_v1_generated_GkeHub_GenerateConnectManifest_async + */ generateConnectManifest( - request?: protos.google.cloud.gkehub.v1.IGenerateConnectManifestRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gkehub.v1.IGenerateConnectManifestResponse, - protos.google.cloud.gkehub.v1.IGenerateConnectManifestRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkehub.v1.IGenerateConnectManifestRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gkehub.v1.IGenerateConnectManifestResponse, + protos.google.cloud.gkehub.v1.IGenerateConnectManifestRequest | undefined, + {} | undefined, + ] + >; generateConnectManifest( - request: protos.google.cloud.gkehub.v1.IGenerateConnectManifestRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.gkehub.v1.IGenerateConnectManifestResponse, - protos.google.cloud.gkehub.v1.IGenerateConnectManifestRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.IGenerateConnectManifestRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.gkehub.v1.IGenerateConnectManifestResponse, + | protos.google.cloud.gkehub.v1.IGenerateConnectManifestRequest + | null + | undefined, + {} | null | undefined + >, + ): void; generateConnectManifest( - request: protos.google.cloud.gkehub.v1.IGenerateConnectManifestRequest, - callback: Callback< - protos.google.cloud.gkehub.v1.IGenerateConnectManifestResponse, - protos.google.cloud.gkehub.v1.IGenerateConnectManifestRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.IGenerateConnectManifestRequest, + callback: Callback< + protos.google.cloud.gkehub.v1.IGenerateConnectManifestResponse, + | protos.google.cloud.gkehub.v1.IGenerateConnectManifestRequest + | null + | undefined, + {} | null | undefined + >, + ): void; generateConnectManifest( - request?: protos.google.cloud.gkehub.v1.IGenerateConnectManifestRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.gkehub.v1.IGenerateConnectManifestRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.gkehub.v1.IGenerateConnectManifestResponse, - protos.google.cloud.gkehub.v1.IGenerateConnectManifestRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.gkehub.v1.IGenerateConnectManifestResponse, - protos.google.cloud.gkehub.v1.IGenerateConnectManifestRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.gkehub.v1.IGenerateConnectManifestResponse, - protos.google.cloud.gkehub.v1.IGenerateConnectManifestRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.gkehub.v1.IGenerateConnectManifestRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.gkehub.v1.IGenerateConnectManifestResponse, + | protos.google.cloud.gkehub.v1.IGenerateConnectManifestRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.gkehub.v1.IGenerateConnectManifestResponse, + protos.google.cloud.gkehub.v1.IGenerateConnectManifestRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('generateConnectManifest request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.gkehub.v1.IGenerateConnectManifestResponse, - protos.google.cloud.gkehub.v1.IGenerateConnectManifestRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.gkehub.v1.IGenerateConnectManifestResponse, + | protos.google.cloud.gkehub.v1.IGenerateConnectManifestRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('generateConnectManifest response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.generateConnectManifest(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.gkehub.v1.IGenerateConnectManifestResponse, - protos.google.cloud.gkehub.v1.IGenerateConnectManifestRequest|undefined, - {}|undefined - ]) => { - this._log.info('generateConnectManifest response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .generateConnectManifest(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.gkehub.v1.IGenerateConnectManifestResponse, + ( + | protos.google.cloud.gkehub.v1.IGenerateConnectManifestRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('generateConnectManifest response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 details of a fleet. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The Fleet resource name in the format - * `projects/* /locations/* /fleets/*`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.gkehub.v1.Fleet|Fleet}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_hub.get_fleet.js - * region_tag:gkehub_v1_generated_GkeHub_GetFleet_async - */ + /** + * Returns the details of a fleet. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The Fleet resource name in the format + * `projects/* /locations/* /fleets/*`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.gkehub.v1.Fleet|Fleet}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_hub.get_fleet.js + * region_tag:gkehub_v1_generated_GkeHub_GetFleet_async + */ getFleet( - request?: protos.google.cloud.gkehub.v1.IGetFleetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gkehub.v1.IFleet, - protos.google.cloud.gkehub.v1.IGetFleetRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkehub.v1.IGetFleetRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gkehub.v1.IFleet, + protos.google.cloud.gkehub.v1.IGetFleetRequest | undefined, + {} | undefined, + ] + >; getFleet( - request: protos.google.cloud.gkehub.v1.IGetFleetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.gkehub.v1.IFleet, - protos.google.cloud.gkehub.v1.IGetFleetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.IGetFleetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.gkehub.v1.IFleet, + protos.google.cloud.gkehub.v1.IGetFleetRequest | null | undefined, + {} | null | undefined + >, + ): void; getFleet( - request: protos.google.cloud.gkehub.v1.IGetFleetRequest, - callback: Callback< - protos.google.cloud.gkehub.v1.IFleet, - protos.google.cloud.gkehub.v1.IGetFleetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.IGetFleetRequest, + callback: Callback< + protos.google.cloud.gkehub.v1.IFleet, + protos.google.cloud.gkehub.v1.IGetFleetRequest | null | undefined, + {} | null | undefined + >, + ): void; getFleet( - request?: protos.google.cloud.gkehub.v1.IGetFleetRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.gkehub.v1.IGetFleetRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.gkehub.v1.IFleet, - protos.google.cloud.gkehub.v1.IGetFleetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.gkehub.v1.IFleet, - protos.google.cloud.gkehub.v1.IGetFleetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.gkehub.v1.IFleet, - protos.google.cloud.gkehub.v1.IGetFleetRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.gkehub.v1.IGetFleetRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.gkehub.v1.IFleet, + protos.google.cloud.gkehub.v1.IGetFleetRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.gkehub.v1.IFleet, + protos.google.cloud.gkehub.v1.IGetFleetRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getFleet request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.gkehub.v1.IFleet, - protos.google.cloud.gkehub.v1.IGetFleetRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.gkehub.v1.IFleet, + protos.google.cloud.gkehub.v1.IGetFleetRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getFleet response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getFleet(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.gkehub.v1.IFleet, - protos.google.cloud.gkehub.v1.IGetFleetRequest|undefined, - {}|undefined - ]) => { - this._log.info('getFleet response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getFleet(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.gkehub.v1.IFleet, + protos.google.cloud.gkehub.v1.IGetFleetRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getFleet response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 details of a fleet namespace. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The Namespace resource name in the format - * `projects/* /locations/* /scopes/* /namespaces/*`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.gkehub.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/gke_hub.get_scope_namespace.js - * region_tag:gkehub_v1_generated_GkeHub_GetScopeNamespace_async - */ + /** + * Returns the details of a fleet namespace. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The Namespace resource name in the format + * `projects/* /locations/* /scopes/* /namespaces/*`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.gkehub.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/gke_hub.get_scope_namespace.js + * region_tag:gkehub_v1_generated_GkeHub_GetScopeNamespace_async + */ getScopeNamespace( - request?: protos.google.cloud.gkehub.v1.IGetScopeNamespaceRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gkehub.v1.INamespace, - protos.google.cloud.gkehub.v1.IGetScopeNamespaceRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkehub.v1.IGetScopeNamespaceRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gkehub.v1.INamespace, + protos.google.cloud.gkehub.v1.IGetScopeNamespaceRequest | undefined, + {} | undefined, + ] + >; getScopeNamespace( - request: protos.google.cloud.gkehub.v1.IGetScopeNamespaceRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.gkehub.v1.INamespace, - protos.google.cloud.gkehub.v1.IGetScopeNamespaceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.IGetScopeNamespaceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.gkehub.v1.INamespace, + | protos.google.cloud.gkehub.v1.IGetScopeNamespaceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getScopeNamespace( - request: protos.google.cloud.gkehub.v1.IGetScopeNamespaceRequest, - callback: Callback< - protos.google.cloud.gkehub.v1.INamespace, - protos.google.cloud.gkehub.v1.IGetScopeNamespaceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.IGetScopeNamespaceRequest, + callback: Callback< + protos.google.cloud.gkehub.v1.INamespace, + | protos.google.cloud.gkehub.v1.IGetScopeNamespaceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getScopeNamespace( - request?: protos.google.cloud.gkehub.v1.IGetScopeNamespaceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.gkehub.v1.INamespace, - protos.google.cloud.gkehub.v1.IGetScopeNamespaceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.gkehub.v1.IGetScopeNamespaceRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.gkehub.v1.INamespace, - protos.google.cloud.gkehub.v1.IGetScopeNamespaceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.gkehub.v1.INamespace, - protos.google.cloud.gkehub.v1.IGetScopeNamespaceRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.gkehub.v1.IGetScopeNamespaceRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.gkehub.v1.INamespace, + | protos.google.cloud.gkehub.v1.IGetScopeNamespaceRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.gkehub.v1.INamespace, + protos.google.cloud.gkehub.v1.IGetScopeNamespaceRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getScopeNamespace request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.gkehub.v1.INamespace, - protos.google.cloud.gkehub.v1.IGetScopeNamespaceRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.gkehub.v1.INamespace, + | protos.google.cloud.gkehub.v1.IGetScopeNamespaceRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getScopeNamespace response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getScopeNamespace(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.gkehub.v1.INamespace, - protos.google.cloud.gkehub.v1.IGetScopeNamespaceRequest|undefined, - {}|undefined - ]) => { - this._log.info('getScopeNamespace response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getScopeNamespace(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.gkehub.v1.INamespace, + protos.google.cloud.gkehub.v1.IGetScopeNamespaceRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getScopeNamespace response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 details of a Scope RBACRoleBinding. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The RBACRoleBinding resource name in the format - * `projects/* /locations/* /scopes/* /rbacrolebindings/*`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.gkehub.v1.RBACRoleBinding|RBACRoleBinding}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_hub.get_scope_r_b_a_c_role_binding.js - * region_tag:gkehub_v1_generated_GkeHub_GetScopeRBACRoleBinding_async - */ + /** + * Returns the details of a Scope RBACRoleBinding. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The RBACRoleBinding resource name in the format + * `projects/* /locations/* /scopes/* /rbacrolebindings/*`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.gkehub.v1.RBACRoleBinding|RBACRoleBinding}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_hub.get_scope_r_b_a_c_role_binding.js + * region_tag:gkehub_v1_generated_GkeHub_GetScopeRBACRoleBinding_async + */ getScopeRBACRoleBinding( - request?: protos.google.cloud.gkehub.v1.IGetScopeRBACRoleBindingRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gkehub.v1.IRBACRoleBinding, - protos.google.cloud.gkehub.v1.IGetScopeRBACRoleBindingRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkehub.v1.IGetScopeRBACRoleBindingRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gkehub.v1.IRBACRoleBinding, + protos.google.cloud.gkehub.v1.IGetScopeRBACRoleBindingRequest | undefined, + {} | undefined, + ] + >; getScopeRBACRoleBinding( - request: protos.google.cloud.gkehub.v1.IGetScopeRBACRoleBindingRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.gkehub.v1.IRBACRoleBinding, - protos.google.cloud.gkehub.v1.IGetScopeRBACRoleBindingRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.IGetScopeRBACRoleBindingRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.gkehub.v1.IRBACRoleBinding, + | protos.google.cloud.gkehub.v1.IGetScopeRBACRoleBindingRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getScopeRBACRoleBinding( - request: protos.google.cloud.gkehub.v1.IGetScopeRBACRoleBindingRequest, - callback: Callback< - protos.google.cloud.gkehub.v1.IRBACRoleBinding, - protos.google.cloud.gkehub.v1.IGetScopeRBACRoleBindingRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.IGetScopeRBACRoleBindingRequest, + callback: Callback< + protos.google.cloud.gkehub.v1.IRBACRoleBinding, + | protos.google.cloud.gkehub.v1.IGetScopeRBACRoleBindingRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getScopeRBACRoleBinding( - request?: protos.google.cloud.gkehub.v1.IGetScopeRBACRoleBindingRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.gkehub.v1.IGetScopeRBACRoleBindingRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.gkehub.v1.IRBACRoleBinding, - protos.google.cloud.gkehub.v1.IGetScopeRBACRoleBindingRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.gkehub.v1.IRBACRoleBinding, - protos.google.cloud.gkehub.v1.IGetScopeRBACRoleBindingRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.gkehub.v1.IRBACRoleBinding, - protos.google.cloud.gkehub.v1.IGetScopeRBACRoleBindingRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.gkehub.v1.IGetScopeRBACRoleBindingRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.gkehub.v1.IRBACRoleBinding, + | protos.google.cloud.gkehub.v1.IGetScopeRBACRoleBindingRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.gkehub.v1.IRBACRoleBinding, + protos.google.cloud.gkehub.v1.IGetScopeRBACRoleBindingRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getScopeRBACRoleBinding request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.gkehub.v1.IRBACRoleBinding, - protos.google.cloud.gkehub.v1.IGetScopeRBACRoleBindingRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.gkehub.v1.IRBACRoleBinding, + | protos.google.cloud.gkehub.v1.IGetScopeRBACRoleBindingRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getScopeRBACRoleBinding response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getScopeRbacRoleBinding(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.gkehub.v1.IRBACRoleBinding, - protos.google.cloud.gkehub.v1.IGetScopeRBACRoleBindingRequest|undefined, - {}|undefined - ]) => { - this._log.info('getScopeRBACRoleBinding response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getScopeRbacRoleBinding(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.gkehub.v1.IRBACRoleBinding, + ( + | protos.google.cloud.gkehub.v1.IGetScopeRBACRoleBindingRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getScopeRBACRoleBinding response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 details of a Scope. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The Scope resource name in the format - * `projects/* /locations/* /scopes/*`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.gkehub.v1.Scope|Scope}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_hub.get_scope.js - * region_tag:gkehub_v1_generated_GkeHub_GetScope_async - */ + /** + * Returns the details of a Scope. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The Scope resource name in the format + * `projects/* /locations/* /scopes/*`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.gkehub.v1.Scope|Scope}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_hub.get_scope.js + * region_tag:gkehub_v1_generated_GkeHub_GetScope_async + */ getScope( - request?: protos.google.cloud.gkehub.v1.IGetScopeRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gkehub.v1.IScope, - protos.google.cloud.gkehub.v1.IGetScopeRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkehub.v1.IGetScopeRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gkehub.v1.IScope, + protos.google.cloud.gkehub.v1.IGetScopeRequest | undefined, + {} | undefined, + ] + >; getScope( - request: protos.google.cloud.gkehub.v1.IGetScopeRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.gkehub.v1.IScope, - protos.google.cloud.gkehub.v1.IGetScopeRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.IGetScopeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.gkehub.v1.IScope, + protos.google.cloud.gkehub.v1.IGetScopeRequest | null | undefined, + {} | null | undefined + >, + ): void; getScope( - request: protos.google.cloud.gkehub.v1.IGetScopeRequest, - callback: Callback< - protos.google.cloud.gkehub.v1.IScope, - protos.google.cloud.gkehub.v1.IGetScopeRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.IGetScopeRequest, + callback: Callback< + protos.google.cloud.gkehub.v1.IScope, + protos.google.cloud.gkehub.v1.IGetScopeRequest | null | undefined, + {} | null | undefined + >, + ): void; getScope( - request?: protos.google.cloud.gkehub.v1.IGetScopeRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.gkehub.v1.IScope, - protos.google.cloud.gkehub.v1.IGetScopeRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.gkehub.v1.IGetScopeRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.gkehub.v1.IScope, - protos.google.cloud.gkehub.v1.IGetScopeRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.gkehub.v1.IScope, - protos.google.cloud.gkehub.v1.IGetScopeRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.gkehub.v1.IGetScopeRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.gkehub.v1.IScope, + protos.google.cloud.gkehub.v1.IGetScopeRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.gkehub.v1.IScope, + protos.google.cloud.gkehub.v1.IGetScopeRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getScope request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.gkehub.v1.IScope, - protos.google.cloud.gkehub.v1.IGetScopeRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.gkehub.v1.IScope, + protos.google.cloud.gkehub.v1.IGetScopeRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getScope response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getScope(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.gkehub.v1.IScope, - protos.google.cloud.gkehub.v1.IGetScopeRequest|undefined, - {}|undefined - ]) => { - this._log.info('getScope response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getScope(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.gkehub.v1.IScope, + protos.google.cloud.gkehub.v1.IGetScopeRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getScope response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 details of a MembershipBinding. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The MembershipBinding resource name in the format - * `projects/* /locations/* /memberships/* /bindings/*`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.gkehub.v1.MembershipBinding|MembershipBinding}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_hub.get_membership_binding.js - * region_tag:gkehub_v1_generated_GkeHub_GetMembershipBinding_async - */ + /** + * Returns the details of a MembershipBinding. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The MembershipBinding resource name in the format + * `projects/* /locations/* /memberships/* /bindings/*`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.gkehub.v1.MembershipBinding|MembershipBinding}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_hub.get_membership_binding.js + * region_tag:gkehub_v1_generated_GkeHub_GetMembershipBinding_async + */ getMembershipBinding( - request?: protos.google.cloud.gkehub.v1.IGetMembershipBindingRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gkehub.v1.IMembershipBinding, - protos.google.cloud.gkehub.v1.IGetMembershipBindingRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkehub.v1.IGetMembershipBindingRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gkehub.v1.IMembershipBinding, + protos.google.cloud.gkehub.v1.IGetMembershipBindingRequest | undefined, + {} | undefined, + ] + >; getMembershipBinding( - request: protos.google.cloud.gkehub.v1.IGetMembershipBindingRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.gkehub.v1.IMembershipBinding, - protos.google.cloud.gkehub.v1.IGetMembershipBindingRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.IGetMembershipBindingRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.gkehub.v1.IMembershipBinding, + | protos.google.cloud.gkehub.v1.IGetMembershipBindingRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getMembershipBinding( - request: protos.google.cloud.gkehub.v1.IGetMembershipBindingRequest, - callback: Callback< - protos.google.cloud.gkehub.v1.IMembershipBinding, - protos.google.cloud.gkehub.v1.IGetMembershipBindingRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.IGetMembershipBindingRequest, + callback: Callback< + protos.google.cloud.gkehub.v1.IMembershipBinding, + | protos.google.cloud.gkehub.v1.IGetMembershipBindingRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getMembershipBinding( - request?: protos.google.cloud.gkehub.v1.IGetMembershipBindingRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.gkehub.v1.IGetMembershipBindingRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.gkehub.v1.IMembershipBinding, - protos.google.cloud.gkehub.v1.IGetMembershipBindingRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.gkehub.v1.IMembershipBinding, - protos.google.cloud.gkehub.v1.IGetMembershipBindingRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.gkehub.v1.IMembershipBinding, - protos.google.cloud.gkehub.v1.IGetMembershipBindingRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.gkehub.v1.IGetMembershipBindingRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.gkehub.v1.IMembershipBinding, + | protos.google.cloud.gkehub.v1.IGetMembershipBindingRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.gkehub.v1.IMembershipBinding, + protos.google.cloud.gkehub.v1.IGetMembershipBindingRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getMembershipBinding request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.gkehub.v1.IMembershipBinding, - protos.google.cloud.gkehub.v1.IGetMembershipBindingRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.gkehub.v1.IMembershipBinding, + | protos.google.cloud.gkehub.v1.IGetMembershipBindingRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getMembershipBinding response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getMembershipBinding(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.gkehub.v1.IMembershipBinding, - protos.google.cloud.gkehub.v1.IGetMembershipBindingRequest|undefined, - {}|undefined - ]) => { - this._log.info('getMembershipBinding response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getMembershipBinding(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.gkehub.v1.IMembershipBinding, + ( + | protos.google.cloud.gkehub.v1.IGetMembershipBindingRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getMembershipBinding response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 details of a Membership RBACRoleBinding. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The RBACRoleBinding resource name in the format - * `projects/* /locations/* /memberships/* /rbacrolebindings/*`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.gkehub.v1.RBACRoleBinding|RBACRoleBinding}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_hub.get_membership_r_b_a_c_role_binding.js - * region_tag:gkehub_v1_generated_GkeHub_GetMembershipRBACRoleBinding_async - */ + /** + * Returns the details of a Membership RBACRoleBinding. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The RBACRoleBinding resource name in the format + * `projects/* /locations/* /memberships/* /rbacrolebindings/*`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.gkehub.v1.RBACRoleBinding|RBACRoleBinding}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_hub.get_membership_r_b_a_c_role_binding.js + * region_tag:gkehub_v1_generated_GkeHub_GetMembershipRBACRoleBinding_async + */ getMembershipRBACRoleBinding( - request?: protos.google.cloud.gkehub.v1.IGetMembershipRBACRoleBindingRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gkehub.v1.IRBACRoleBinding, - protos.google.cloud.gkehub.v1.IGetMembershipRBACRoleBindingRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkehub.v1.IGetMembershipRBACRoleBindingRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gkehub.v1.IRBACRoleBinding, + ( + | protos.google.cloud.gkehub.v1.IGetMembershipRBACRoleBindingRequest + | undefined + ), + {} | undefined, + ] + >; getMembershipRBACRoleBinding( - request: protos.google.cloud.gkehub.v1.IGetMembershipRBACRoleBindingRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.gkehub.v1.IRBACRoleBinding, - protos.google.cloud.gkehub.v1.IGetMembershipRBACRoleBindingRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.IGetMembershipRBACRoleBindingRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.gkehub.v1.IRBACRoleBinding, + | protos.google.cloud.gkehub.v1.IGetMembershipRBACRoleBindingRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getMembershipRBACRoleBinding( - request: protos.google.cloud.gkehub.v1.IGetMembershipRBACRoleBindingRequest, - callback: Callback< - protos.google.cloud.gkehub.v1.IRBACRoleBinding, - protos.google.cloud.gkehub.v1.IGetMembershipRBACRoleBindingRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.IGetMembershipRBACRoleBindingRequest, + callback: Callback< + protos.google.cloud.gkehub.v1.IRBACRoleBinding, + | protos.google.cloud.gkehub.v1.IGetMembershipRBACRoleBindingRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getMembershipRBACRoleBinding( - request?: protos.google.cloud.gkehub.v1.IGetMembershipRBACRoleBindingRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.gkehub.v1.IGetMembershipRBACRoleBindingRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.gkehub.v1.IRBACRoleBinding, - protos.google.cloud.gkehub.v1.IGetMembershipRBACRoleBindingRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.gkehub.v1.IRBACRoleBinding, - protos.google.cloud.gkehub.v1.IGetMembershipRBACRoleBindingRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.gkehub.v1.IRBACRoleBinding, - protos.google.cloud.gkehub.v1.IGetMembershipRBACRoleBindingRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.gkehub.v1.IGetMembershipRBACRoleBindingRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.gkehub.v1.IRBACRoleBinding, + | protos.google.cloud.gkehub.v1.IGetMembershipRBACRoleBindingRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.gkehub.v1.IRBACRoleBinding, + ( + | protos.google.cloud.gkehub.v1.IGetMembershipRBACRoleBindingRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getMembershipRBACRoleBinding request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.gkehub.v1.IRBACRoleBinding, - protos.google.cloud.gkehub.v1.IGetMembershipRBACRoleBindingRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.gkehub.v1.IRBACRoleBinding, + | protos.google.cloud.gkehub.v1.IGetMembershipRBACRoleBindingRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getMembershipRBACRoleBinding response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getMembershipRbacRoleBinding(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.gkehub.v1.IRBACRoleBinding, - protos.google.cloud.gkehub.v1.IGetMembershipRBACRoleBindingRequest|undefined, - {}|undefined - ]) => { - this._log.info('getMembershipRBACRoleBinding response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getMembershipRbacRoleBinding(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.gkehub.v1.IRBACRoleBinding, + ( + | protos.google.cloud.gkehub.v1.IGetMembershipRBACRoleBindingRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getMembershipRBACRoleBinding response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 YAML of the RBAC policies for the specified - * RoleBinding and its associated impersonation resources. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent (project and location) where the RBACRoleBinding will - * be created. Specified in the format `projects/* /locations/* /memberships/*`. - * @param {string} request.rbacrolebindingId - * Required. Client chosen ID for the RBACRoleBinding. `rbacrolebinding_id` - * must be a valid RFC 1123 compliant DNS label: - * - * 1. At most 63 characters in length - * 2. It must consist of lower case alphanumeric characters or `-` - * 3. It must start and end with an alphanumeric character - * - * Which can be expressed as the regex: `[a-z0-9]([-a-z0-9]*[a-z0-9])?`, - * with a maximum length of 63 characters. - * @param {google.cloud.gkehub.v1.RBACRoleBinding} request.rbacrolebinding - * Required. The rbacrolebindings to generate the YAML 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 an object representing {@link protos.google.cloud.gkehub.v1.GenerateMembershipRBACRoleBindingYAMLResponse|GenerateMembershipRBACRoleBindingYAMLResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_hub.generate_membership_r_b_a_c_role_binding_y_a_m_l.js - * region_tag:gkehub_v1_generated_GkeHub_GenerateMembershipRBACRoleBindingYAML_async - */ - generateMembershipRBACRoleBindingYAML( - request?: protos.google.cloud.gkehub.v1.IGenerateMembershipRBACRoleBindingYAMLRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gkehub.v1.IGenerateMembershipRBACRoleBindingYAMLResponse, - protos.google.cloud.gkehub.v1.IGenerateMembershipRBACRoleBindingYAMLRequest|undefined, {}|undefined - ]>; - generateMembershipRBACRoleBindingYAML( - request: protos.google.cloud.gkehub.v1.IGenerateMembershipRBACRoleBindingYAMLRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.gkehub.v1.IGenerateMembershipRBACRoleBindingYAMLResponse, - protos.google.cloud.gkehub.v1.IGenerateMembershipRBACRoleBindingYAMLRequest|null|undefined, - {}|null|undefined>): void; - generateMembershipRBACRoleBindingYAML( - request: protos.google.cloud.gkehub.v1.IGenerateMembershipRBACRoleBindingYAMLRequest, - callback: Callback< - protos.google.cloud.gkehub.v1.IGenerateMembershipRBACRoleBindingYAMLResponse, - protos.google.cloud.gkehub.v1.IGenerateMembershipRBACRoleBindingYAMLRequest|null|undefined, - {}|null|undefined>): void; + /** + * Generates a YAML of the RBAC policies for the specified + * RoleBinding and its associated impersonation resources. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent (project and location) where the RBACRoleBinding will + * be created. Specified in the format `projects/* /locations/* /memberships/*`. + * @param {string} request.rbacrolebindingId + * Required. Client chosen ID for the RBACRoleBinding. `rbacrolebinding_id` + * must be a valid RFC 1123 compliant DNS label: + * + * 1. At most 63 characters in length + * 2. It must consist of lower case alphanumeric characters or `-` + * 3. It must start and end with an alphanumeric character + * + * Which can be expressed as the regex: `[a-z0-9]([-a-z0-9]*[a-z0-9])?`, + * with a maximum length of 63 characters. + * @param {google.cloud.gkehub.v1.RBACRoleBinding} request.rbacrolebinding + * Required. The rbacrolebindings to generate the YAML 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 an object representing {@link protos.google.cloud.gkehub.v1.GenerateMembershipRBACRoleBindingYAMLResponse|GenerateMembershipRBACRoleBindingYAMLResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_hub.generate_membership_r_b_a_c_role_binding_y_a_m_l.js + * region_tag:gkehub_v1_generated_GkeHub_GenerateMembershipRBACRoleBindingYAML_async + */ generateMembershipRBACRoleBindingYAML( - request?: protos.google.cloud.gkehub.v1.IGenerateMembershipRBACRoleBindingYAMLRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.gkehub.v1.IGenerateMembershipRBACRoleBindingYAMLResponse, - protos.google.cloud.gkehub.v1.IGenerateMembershipRBACRoleBindingYAMLRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.gkehub.v1.IGenerateMembershipRBACRoleBindingYAMLRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gkehub.v1.IGenerateMembershipRBACRoleBindingYAMLResponse, + ( + | protos.google.cloud.gkehub.v1.IGenerateMembershipRBACRoleBindingYAMLRequest + | undefined + ), + {} | undefined, + ] + >; + generateMembershipRBACRoleBindingYAML( + request: protos.google.cloud.gkehub.v1.IGenerateMembershipRBACRoleBindingYAMLRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.gkehub.v1.IGenerateMembershipRBACRoleBindingYAMLResponse, + | protos.google.cloud.gkehub.v1.IGenerateMembershipRBACRoleBindingYAMLRequest + | null + | undefined, + {} | null | undefined + >, + ): void; + generateMembershipRBACRoleBindingYAML( + request: protos.google.cloud.gkehub.v1.IGenerateMembershipRBACRoleBindingYAMLRequest, + callback: Callback< + protos.google.cloud.gkehub.v1.IGenerateMembershipRBACRoleBindingYAMLResponse, + | protos.google.cloud.gkehub.v1.IGenerateMembershipRBACRoleBindingYAMLRequest + | null + | undefined, + {} | null | undefined + >, + ): void; + generateMembershipRBACRoleBindingYAML( + request?: protos.google.cloud.gkehub.v1.IGenerateMembershipRBACRoleBindingYAMLRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.gkehub.v1.IGenerateMembershipRBACRoleBindingYAMLResponse, - protos.google.cloud.gkehub.v1.IGenerateMembershipRBACRoleBindingYAMLRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.gkehub.v1.IGenerateMembershipRBACRoleBindingYAMLResponse, - protos.google.cloud.gkehub.v1.IGenerateMembershipRBACRoleBindingYAMLRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.gkehub.v1.IGenerateMembershipRBACRoleBindingYAMLRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.gkehub.v1.IGenerateMembershipRBACRoleBindingYAMLResponse, + | protos.google.cloud.gkehub.v1.IGenerateMembershipRBACRoleBindingYAMLRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.gkehub.v1.IGenerateMembershipRBACRoleBindingYAMLResponse, + ( + | protos.google.cloud.gkehub.v1.IGenerateMembershipRBACRoleBindingYAMLRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.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('generateMembershipRBACRoleBindingYAML request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.gkehub.v1.IGenerateMembershipRBACRoleBindingYAMLResponse, - protos.google.cloud.gkehub.v1.IGenerateMembershipRBACRoleBindingYAMLRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.gkehub.v1.IGenerateMembershipRBACRoleBindingYAMLResponse, + | protos.google.cloud.gkehub.v1.IGenerateMembershipRBACRoleBindingYAMLRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { - this._log.info('generateMembershipRBACRoleBindingYAML response %j', response); + this._log.info( + 'generateMembershipRBACRoleBindingYAML response %j', + response, + ); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.generateMembershipRbacRoleBindingYamL(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.gkehub.v1.IGenerateMembershipRBACRoleBindingYAMLResponse, - protos.google.cloud.gkehub.v1.IGenerateMembershipRBACRoleBindingYAMLRequest|undefined, - {}|undefined - ]) => { - this._log.info('generateMembershipRBACRoleBindingYAML response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .generateMembershipRbacRoleBindingYamL(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.gkehub.v1.IGenerateMembershipRBACRoleBindingYAMLResponse, + ( + | protos.google.cloud.gkehub.v1.IGenerateMembershipRBACRoleBindingYAMLRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info( + 'generateMembershipRBACRoleBindingYAML response %j', + response, + ); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 Membership. - * - * **This is currently only supported for GKE clusters on Google Cloud**. - * To register other clusters, follow the instructions at - * https://cloud.google.com/anthos/multicluster-management/connect/registering-a-cluster. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent (project and location) where the Memberships will be - * created. Specified in the format `projects/* /locations/*`. - * @param {string} request.membershipId - * Required. Client chosen ID for the membership. `membership_id` must be a - * valid RFC 1123 compliant DNS label: - * - * 1. At most 63 characters in length - * 2. It must consist of lower case alphanumeric characters or `-` - * 3. It must start and end with an alphanumeric character - * - * Which can be expressed as the regex: `[a-z0-9]([-a-z0-9]*[a-z0-9])?`, - * with a maximum length of 63 characters. - * @param {google.cloud.gkehub.v1.Membership} request.resource - * Required. The membership to create. - * @param {string} [request.requestId] - * Optional. A request ID to identify requests. Specify a unique request ID - * so that if you must retry your request, the server will know to ignore - * the request if it has already been completed. The server will guarantee - * that for at least 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_hub.create_membership.js - * region_tag:gkehub_v1_generated_GkeHub_CreateMembership_async - */ + /** + * Creates a new Membership. + * + * **This is currently only supported for GKE clusters on Google Cloud**. + * To register other clusters, follow the instructions at + * https://cloud.google.com/anthos/multicluster-management/connect/registering-a-cluster. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent (project and location) where the Memberships will be + * created. Specified in the format `projects/* /locations/*`. + * @param {string} request.membershipId + * Required. Client chosen ID for the membership. `membership_id` must be a + * valid RFC 1123 compliant DNS label: + * + * 1. At most 63 characters in length + * 2. It must consist of lower case alphanumeric characters or `-` + * 3. It must start and end with an alphanumeric character + * + * Which can be expressed as the regex: `[a-z0-9]([-a-z0-9]*[a-z0-9])?`, + * with a maximum length of 63 characters. + * @param {google.cloud.gkehub.v1.Membership} request.resource + * Required. The membership to create. + * @param {string} [request.requestId] + * Optional. A request ID to identify requests. Specify a unique request ID + * so that if you must retry your request, the server will know to ignore + * the request if it has already been completed. The server will guarantee + * that for at least 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_hub.create_membership.js + * region_tag:gkehub_v1_generated_GkeHub_CreateMembership_async + */ createMembership( - request?: protos.google.cloud.gkehub.v1.ICreateMembershipRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkehub.v1.ICreateMembershipRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.gkehub.v1.IMembership, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createMembership( - request: protos.google.cloud.gkehub.v1.ICreateMembershipRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.ICreateMembershipRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.gkehub.v1.IMembership, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createMembership( - request: protos.google.cloud.gkehub.v1.ICreateMembershipRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.ICreateMembershipRequest, + callback: Callback< + LROperation< + protos.google.cloud.gkehub.v1.IMembership, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createMembership( - request?: protos.google.cloud.gkehub.v1.ICreateMembershipRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.gkehub.v1.ICreateMembershipRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.gkehub.v1.IMembership, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.gkehub.v1.IMembership, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.gkehub.v1.IMembership, + protos.google.cloud.gkehub.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.gkehub.v1.IMembership, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createMembership response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createMembership request %j', request); - return this.innerApiCalls.createMembership(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createMembership response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createMembership(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.gkehub.v1.IMembership, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createMembership response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createMembership()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_hub.create_membership.js - * region_tag:gkehub_v1_generated_GkeHub_CreateMembership_async - */ - async checkCreateMembershipProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createMembership()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_hub.create_membership.js + * region_tag:gkehub_v1_generated_GkeHub_CreateMembership_async + */ + async checkCreateMembershipProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.gkehub.v1.Membership, + protos.google.cloud.gkehub.v1.OperationMetadata + > + > { this._log.info('createMembership long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createMembership, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createMembership, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.gkehub.v1.Membership, + protos.google.cloud.gkehub.v1.OperationMetadata + >; } -/** - * Adds a new Feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent (project and location) where the Feature will be - * created. Specified in the format `projects/* /locations/*`. - * @param {string} request.featureId - * The ID of the feature to create. - * @param {google.cloud.gkehub.v1.Feature} request.resource - * The Feature resource to create. - * @param {string} request.requestId - * A request ID to identify requests. Specify a unique request ID - * so that if you must retry your request, the server will know to ignore - * the request if it has already been completed. The server will guarantee - * that for at least 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_hub.create_feature.js - * region_tag:gkehub_v1_generated_GkeHub_CreateFeature_async - */ + /** + * Adds a new Feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent (project and location) where the Feature will be + * created. Specified in the format `projects/* /locations/*`. + * @param {string} request.featureId + * The ID of the feature to create. + * @param {google.cloud.gkehub.v1.Feature} request.resource + * The Feature resource to create. + * @param {string} request.requestId + * A request ID to identify requests. Specify a unique request ID + * so that if you must retry your request, the server will know to ignore + * the request if it has already been completed. The server will guarantee + * that for at least 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_hub.create_feature.js + * region_tag:gkehub_v1_generated_GkeHub_CreateFeature_async + */ createFeature( - request?: protos.google.cloud.gkehub.v1.ICreateFeatureRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkehub.v1.ICreateFeatureRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.gkehub.v1.IFeature, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createFeature( - request: protos.google.cloud.gkehub.v1.ICreateFeatureRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.ICreateFeatureRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.gkehub.v1.IFeature, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createFeature( - request: protos.google.cloud.gkehub.v1.ICreateFeatureRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.ICreateFeatureRequest, + callback: Callback< + LROperation< + protos.google.cloud.gkehub.v1.IFeature, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createFeature( - request?: protos.google.cloud.gkehub.v1.ICreateFeatureRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.gkehub.v1.ICreateFeatureRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.gkehub.v1.IFeature, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.gkehub.v1.IFeature, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.gkehub.v1.IFeature, + protos.google.cloud.gkehub.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.gkehub.v1.IFeature, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createFeature response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createFeature request %j', request); - return this.innerApiCalls.createFeature(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createFeature response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createFeature(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.gkehub.v1.IFeature, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createFeature response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createFeature()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_hub.create_feature.js - * region_tag:gkehub_v1_generated_GkeHub_CreateFeature_async - */ - async checkCreateFeatureProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createFeature()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_hub.create_feature.js + * region_tag:gkehub_v1_generated_GkeHub_CreateFeature_async + */ + async checkCreateFeatureProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.gkehub.v1.Feature, + protos.google.cloud.gkehub.v1.OperationMetadata + > + > { this._log.info('createFeature long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createFeature, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createFeature, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.gkehub.v1.Feature, + protos.google.cloud.gkehub.v1.OperationMetadata + >; } -/** - * Removes a Membership. - * - * **This is currently only supported for GKE clusters on Google Cloud**. - * To unregister other clusters, follow the instructions at - * https://cloud.google.com/anthos/multicluster-management/connect/unregistering-a-cluster. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The Membership resource name in the format - * `projects/* /locations/* /memberships/*`. - * @param {string} [request.requestId] - * Optional. A request ID to identify requests. Specify a unique request ID - * so that if you must retry your request, the server will know to ignore - * the request if it has already been completed. The server will guarantee - * that for at least 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @param {boolean} [request.force] - * Optional. If set to true, any subresource from this Membership will also be - * deleted. Otherwise, the request will only work if the Membership has no - * subresource. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_hub.delete_membership.js - * region_tag:gkehub_v1_generated_GkeHub_DeleteMembership_async - */ + /** + * Removes a Membership. + * + * **This is currently only supported for GKE clusters on Google Cloud**. + * To unregister other clusters, follow the instructions at + * https://cloud.google.com/anthos/multicluster-management/connect/unregistering-a-cluster. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The Membership resource name in the format + * `projects/* /locations/* /memberships/*`. + * @param {string} [request.requestId] + * Optional. A request ID to identify requests. Specify a unique request ID + * so that if you must retry your request, the server will know to ignore + * the request if it has already been completed. The server will guarantee + * that for at least 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @param {boolean} [request.force] + * Optional. If set to true, any subresource from this Membership will also be + * deleted. Otherwise, the request will only work if the Membership has no + * subresource. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_hub.delete_membership.js + * region_tag:gkehub_v1_generated_GkeHub_DeleteMembership_async + */ deleteMembership( - request?: protos.google.cloud.gkehub.v1.IDeleteMembershipRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkehub.v1.IDeleteMembershipRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteMembership( - request: protos.google.cloud.gkehub.v1.IDeleteMembershipRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.IDeleteMembershipRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteMembership( - request: protos.google.cloud.gkehub.v1.IDeleteMembershipRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.IDeleteMembershipRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteMembership( - request?: protos.google.cloud.gkehub.v1.IDeleteMembershipRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.gkehub.v1.IDeleteMembershipRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.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.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteMembership response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteMembership request %j', request); - return this.innerApiCalls.deleteMembership(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteMembership response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteMembership(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteMembership response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteMembership()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_hub.delete_membership.js - * region_tag:gkehub_v1_generated_GkeHub_DeleteMembership_async - */ - async checkDeleteMembershipProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteMembership()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_hub.delete_membership.js + * region_tag:gkehub_v1_generated_GkeHub_DeleteMembership_async + */ + async checkDeleteMembershipProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.gkehub.v1.OperationMetadata + > + > { this._log.info('deleteMembership long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteMembership, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteMembership, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.gkehub.v1.OperationMetadata + >; } -/** - * Removes a Feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The Feature resource name in the format - * `projects/* /locations/* /features/*`. - * @param {boolean} request.force - * If set to true, the delete will ignore any outstanding resources for - * this Feature (that is, `FeatureState.has_resources` is set to true). These - * resources will NOT be cleaned up or modified in any way. - * @param {string} [request.requestId] - * Optional. A request ID to identify requests. Specify a unique request ID - * so that if you must retry your request, the server will know to ignore - * the request if it has already been completed. The server will guarantee - * that for at least 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_hub.delete_feature.js - * region_tag:gkehub_v1_generated_GkeHub_DeleteFeature_async - */ + /** + * Removes a Feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The Feature resource name in the format + * `projects/* /locations/* /features/*`. + * @param {boolean} request.force + * If set to true, the delete will ignore any outstanding resources for + * this Feature (that is, `FeatureState.has_resources` is set to true). These + * resources will NOT be cleaned up or modified in any way. + * @param {string} [request.requestId] + * Optional. A request ID to identify requests. Specify a unique request ID + * so that if you must retry your request, the server will know to ignore + * the request if it has already been completed. The server will guarantee + * that for at least 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_hub.delete_feature.js + * region_tag:gkehub_v1_generated_GkeHub_DeleteFeature_async + */ deleteFeature( - request?: protos.google.cloud.gkehub.v1.IDeleteFeatureRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkehub.v1.IDeleteFeatureRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteFeature( - request: protos.google.cloud.gkehub.v1.IDeleteFeatureRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.IDeleteFeatureRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteFeature( - request: protos.google.cloud.gkehub.v1.IDeleteFeatureRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.IDeleteFeatureRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteFeature( - request?: protos.google.cloud.gkehub.v1.IDeleteFeatureRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.gkehub.v1.IDeleteFeatureRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.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.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteFeature response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteFeature request %j', request); - return this.innerApiCalls.deleteFeature(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteFeature response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteFeature(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteFeature response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteFeature()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_hub.delete_feature.js - * region_tag:gkehub_v1_generated_GkeHub_DeleteFeature_async - */ - async checkDeleteFeatureProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteFeature()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_hub.delete_feature.js + * region_tag:gkehub_v1_generated_GkeHub_DeleteFeature_async + */ + async checkDeleteFeatureProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.gkehub.v1.OperationMetadata + > + > { this._log.info('deleteFeature long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteFeature, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteFeature, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.gkehub.v1.OperationMetadata + >; } -/** - * Updates an existing Membership. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The Membership resource name in the format - * `projects/* /locations/* /memberships/*`. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. Mask of fields to update. - * @param {google.cloud.gkehub.v1.Membership} request.resource - * Required. Only fields specified in update_mask are updated. - * If you specify a field in the update_mask but don't specify its value here - * that field will be deleted. - * If you are updating a map field, set the value of a key to null or empty - * string to delete the key from the map. It's not possible to update a key's - * value to the empty string. - * If you specify the update_mask to be a special path "*", fully replaces all - * user-modifiable fields to match `resource`. - * @param {string} [request.requestId] - * Optional. A request ID to identify requests. Specify a unique request ID - * so that if you must retry your request, the server will know to ignore - * the request if it has already been completed. The server will guarantee - * that for at least 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_hub.update_membership.js - * region_tag:gkehub_v1_generated_GkeHub_UpdateMembership_async - */ + /** + * Updates an existing Membership. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The Membership resource name in the format + * `projects/* /locations/* /memberships/*`. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. Mask of fields to update. + * @param {google.cloud.gkehub.v1.Membership} request.resource + * Required. Only fields specified in update_mask are updated. + * If you specify a field in the update_mask but don't specify its value here + * that field will be deleted. + * If you are updating a map field, set the value of a key to null or empty + * string to delete the key from the map. It's not possible to update a key's + * value to the empty string. + * If you specify the update_mask to be a special path "*", fully replaces all + * user-modifiable fields to match `resource`. + * @param {string} [request.requestId] + * Optional. A request ID to identify requests. Specify a unique request ID + * so that if you must retry your request, the server will know to ignore + * the request if it has already been completed. The server will guarantee + * that for at least 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_hub.update_membership.js + * region_tag:gkehub_v1_generated_GkeHub_UpdateMembership_async + */ updateMembership( - request?: protos.google.cloud.gkehub.v1.IUpdateMembershipRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkehub.v1.IUpdateMembershipRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.gkehub.v1.IMembership, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateMembership( - request: protos.google.cloud.gkehub.v1.IUpdateMembershipRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.IUpdateMembershipRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.gkehub.v1.IMembership, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateMembership( - request: protos.google.cloud.gkehub.v1.IUpdateMembershipRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.IUpdateMembershipRequest, + callback: Callback< + LROperation< + protos.google.cloud.gkehub.v1.IMembership, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateMembership( - request?: protos.google.cloud.gkehub.v1.IUpdateMembershipRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.gkehub.v1.IUpdateMembershipRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.gkehub.v1.IMembership, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.gkehub.v1.IMembership, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.gkehub.v1.IMembership, + protos.google.cloud.gkehub.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.gkehub.v1.IMembership, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateMembership response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateMembership request %j', request); - return this.innerApiCalls.updateMembership(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateMembership response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateMembership(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.gkehub.v1.IMembership, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateMembership response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateMembership()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_hub.update_membership.js - * region_tag:gkehub_v1_generated_GkeHub_UpdateMembership_async - */ - async checkUpdateMembershipProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateMembership()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_hub.update_membership.js + * region_tag:gkehub_v1_generated_GkeHub_UpdateMembership_async + */ + async checkUpdateMembershipProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.gkehub.v1.Membership, + protos.google.cloud.gkehub.v1.OperationMetadata + > + > { this._log.info('updateMembership long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.updateMembership, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateMembership, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.gkehub.v1.Membership, + protos.google.cloud.gkehub.v1.OperationMetadata + >; } -/** - * Updates an existing Feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The Feature resource name in the format - * `projects/* /locations/* /features/*`. - * @param {google.protobuf.FieldMask} request.updateMask - * Mask of fields to update. - * @param {google.cloud.gkehub.v1.Feature} request.resource - * Only fields specified in update_mask are updated. - * If you specify a field in the update_mask but don't specify its value here - * that field will be deleted. - * If you are updating a map field, set the value of a key to null or empty - * string to delete the key from the map. It's not possible to update a key's - * value to the empty string. - * If you specify the update_mask to be a special path "*", fully replaces all - * user-modifiable fields to match `resource`. - * @param {string} request.requestId - * A request ID to identify requests. Specify a unique request ID - * so that if you must retry your request, the server will know to ignore - * the request if it has already been completed. The server will guarantee - * that for at least 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_hub.update_feature.js - * region_tag:gkehub_v1_generated_GkeHub_UpdateFeature_async - */ + /** + * Updates an existing Feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The Feature resource name in the format + * `projects/* /locations/* /features/*`. + * @param {google.protobuf.FieldMask} request.updateMask + * Mask of fields to update. + * @param {google.cloud.gkehub.v1.Feature} request.resource + * Only fields specified in update_mask are updated. + * If you specify a field in the update_mask but don't specify its value here + * that field will be deleted. + * If you are updating a map field, set the value of a key to null or empty + * string to delete the key from the map. It's not possible to update a key's + * value to the empty string. + * If you specify the update_mask to be a special path "*", fully replaces all + * user-modifiable fields to match `resource`. + * @param {string} request.requestId + * A request ID to identify requests. Specify a unique request ID + * so that if you must retry your request, the server will know to ignore + * the request if it has already been completed. The server will guarantee + * that for at least 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_hub.update_feature.js + * region_tag:gkehub_v1_generated_GkeHub_UpdateFeature_async + */ updateFeature( - request?: protos.google.cloud.gkehub.v1.IUpdateFeatureRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkehub.v1.IUpdateFeatureRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.gkehub.v1.IFeature, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateFeature( - request: protos.google.cloud.gkehub.v1.IUpdateFeatureRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.IUpdateFeatureRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.gkehub.v1.IFeature, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateFeature( - request: protos.google.cloud.gkehub.v1.IUpdateFeatureRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.IUpdateFeatureRequest, + callback: Callback< + LROperation< + protos.google.cloud.gkehub.v1.IFeature, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateFeature( - request?: protos.google.cloud.gkehub.v1.IUpdateFeatureRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.gkehub.v1.IUpdateFeatureRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.gkehub.v1.IFeature, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.gkehub.v1.IFeature, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.gkehub.v1.IFeature, + protos.google.cloud.gkehub.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.gkehub.v1.IFeature, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateFeature response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateFeature request %j', request); - return this.innerApiCalls.updateFeature(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateFeature response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateFeature(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.gkehub.v1.IFeature, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateFeature response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateFeature()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_hub.update_feature.js - * region_tag:gkehub_v1_generated_GkeHub_UpdateFeature_async - */ - async checkUpdateFeatureProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateFeature()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_hub.update_feature.js + * region_tag:gkehub_v1_generated_GkeHub_UpdateFeature_async + */ + async checkUpdateFeatureProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.gkehub.v1.Feature, + protos.google.cloud.gkehub.v1.OperationMetadata + > + > { this._log.info('updateFeature long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.updateFeature, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateFeature, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.gkehub.v1.Feature, + protos.google.cloud.gkehub.v1.OperationMetadata + >; } -/** - * Creates a fleet. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent (project and location) where the Fleet will be - * created. Specified in the format `projects/* /locations/*`. - * @param {google.cloud.gkehub.v1.Fleet} request.fleet - * Required. The fleet 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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_hub.create_fleet.js - * region_tag:gkehub_v1_generated_GkeHub_CreateFleet_async - */ + /** + * Creates a fleet. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent (project and location) where the Fleet will be + * created. Specified in the format `projects/* /locations/*`. + * @param {google.cloud.gkehub.v1.Fleet} request.fleet + * Required. The fleet 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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_hub.create_fleet.js + * region_tag:gkehub_v1_generated_GkeHub_CreateFleet_async + */ createFleet( - request?: protos.google.cloud.gkehub.v1.ICreateFleetRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkehub.v1.ICreateFleetRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.gkehub.v1.IFleet, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createFleet( - request: protos.google.cloud.gkehub.v1.ICreateFleetRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.ICreateFleetRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.gkehub.v1.IFleet, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createFleet( - request: protos.google.cloud.gkehub.v1.ICreateFleetRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.ICreateFleetRequest, + callback: Callback< + LROperation< + protos.google.cloud.gkehub.v1.IFleet, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createFleet( - request?: protos.google.cloud.gkehub.v1.ICreateFleetRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.gkehub.v1.ICreateFleetRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.gkehub.v1.IFleet, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.gkehub.v1.IFleet, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.gkehub.v1.IFleet, + protos.google.cloud.gkehub.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.gkehub.v1.IFleet, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createFleet response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createFleet request %j', request); - return this.innerApiCalls.createFleet(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createFleet response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createFleet(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.gkehub.v1.IFleet, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createFleet response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createFleet()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_hub.create_fleet.js - * region_tag:gkehub_v1_generated_GkeHub_CreateFleet_async - */ - async checkCreateFleetProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createFleet()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_hub.create_fleet.js + * region_tag:gkehub_v1_generated_GkeHub_CreateFleet_async + */ + async checkCreateFleetProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.gkehub.v1.Fleet, + protos.google.cloud.gkehub.v1.OperationMetadata + > + > { this._log.info('createFleet long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createFleet, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createFleet, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.gkehub.v1.Fleet, + protos.google.cloud.gkehub.v1.OperationMetadata + >; } -/** - * Updates a fleet. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.gkehub.v1.Fleet} request.fleet - * Required. The Fleet to update. - * - * The `name` field of the Fleet object identifies which fleet will be - * updated. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. The 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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_hub.update_fleet.js - * region_tag:gkehub_v1_generated_GkeHub_UpdateFleet_async - */ + /** + * Updates a fleet. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.gkehub.v1.Fleet} request.fleet + * Required. The Fleet to update. + * + * The `name` field of the Fleet object identifies which fleet will be + * updated. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. The 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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_hub.update_fleet.js + * region_tag:gkehub_v1_generated_GkeHub_UpdateFleet_async + */ updateFleet( - request?: protos.google.cloud.gkehub.v1.IUpdateFleetRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkehub.v1.IUpdateFleetRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.gkehub.v1.IFleet, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateFleet( - request: protos.google.cloud.gkehub.v1.IUpdateFleetRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.IUpdateFleetRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.gkehub.v1.IFleet, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateFleet( - request: protos.google.cloud.gkehub.v1.IUpdateFleetRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.IUpdateFleetRequest, + callback: Callback< + LROperation< + protos.google.cloud.gkehub.v1.IFleet, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateFleet( - request?: protos.google.cloud.gkehub.v1.IUpdateFleetRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.gkehub.v1.IUpdateFleetRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.gkehub.v1.IFleet, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.gkehub.v1.IFleet, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.gkehub.v1.IFleet, + protos.google.cloud.gkehub.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({ - 'fleet.name': request.fleet!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'fleet.name': request.fleet!.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.gkehub.v1.IFleet, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateFleet response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateFleet request %j', request); - return this.innerApiCalls.updateFleet(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateFleet response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateFleet(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.gkehub.v1.IFleet, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateFleet response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateFleet()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_hub.update_fleet.js - * region_tag:gkehub_v1_generated_GkeHub_UpdateFleet_async - */ - async checkUpdateFleetProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateFleet()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_hub.update_fleet.js + * region_tag:gkehub_v1_generated_GkeHub_UpdateFleet_async + */ + async checkUpdateFleetProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.gkehub.v1.Fleet, + protos.google.cloud.gkehub.v1.OperationMetadata + > + > { this._log.info('updateFleet long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.updateFleet, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateFleet, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.gkehub.v1.Fleet, + protos.google.cloud.gkehub.v1.OperationMetadata + >; } -/** - * Removes a Fleet. There must be no memberships remaining in the Fleet. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The Fleet resource name in the format - * `projects/* /locations/* /fleets/*`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_hub.delete_fleet.js - * region_tag:gkehub_v1_generated_GkeHub_DeleteFleet_async - */ + /** + * Removes a Fleet. There must be no memberships remaining in the Fleet. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The Fleet resource name in the format + * `projects/* /locations/* /fleets/*`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_hub.delete_fleet.js + * region_tag:gkehub_v1_generated_GkeHub_DeleteFleet_async + */ deleteFleet( - request?: protos.google.cloud.gkehub.v1.IDeleteFleetRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkehub.v1.IDeleteFleetRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteFleet( - request: protos.google.cloud.gkehub.v1.IDeleteFleetRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.IDeleteFleetRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteFleet( - request: protos.google.cloud.gkehub.v1.IDeleteFleetRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.IDeleteFleetRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteFleet( - request?: protos.google.cloud.gkehub.v1.IDeleteFleetRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.gkehub.v1.IDeleteFleetRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.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.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteFleet response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteFleet request %j', request); - return this.innerApiCalls.deleteFleet(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteFleet response %j', rawResponse); - return [response, rawResponse, _]; - }); - } -/** - * Check the status of the long running operation returned by `deleteFleet()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_hub.delete_fleet.js - * region_tag:gkehub_v1_generated_GkeHub_DeleteFleet_async - */ - async checkDeleteFleetProgress(name: string): Promise>{ + return this.innerApiCalls + .deleteFleet(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteFleet response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); + } + /** + * Check the status of the long running operation returned by `deleteFleet()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_hub.delete_fleet.js + * region_tag:gkehub_v1_generated_GkeHub_DeleteFleet_async + */ + async checkDeleteFleetProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.gkehub.v1.OperationMetadata + > + > { this._log.info('deleteFleet long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteFleet, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteFleet, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.gkehub.v1.OperationMetadata + >; } -/** - * Creates a fleet namespace. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent (project and location) where the Namespace will be - * created. Specified in the format `projects/* /locations/* /scopes/*`. - * @param {string} request.scopeNamespaceId - * Required. Client chosen ID for the Namespace. `namespace_id` must be a - * valid RFC 1123 compliant DNS label: - * - * 1. At most 63 characters in length - * 2. It must consist of lower case alphanumeric characters or `-` - * 3. It must start and end with an alphanumeric character - * - * Which can be expressed as the regex: `[a-z0-9]([-a-z0-9]*[a-z0-9])?`, - * with a maximum length of 63 characters. - * @param {google.cloud.gkehub.v1.Namespace} request.scopeNamespace - * Required. The fleet namespace 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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_hub.create_scope_namespace.js - * region_tag:gkehub_v1_generated_GkeHub_CreateScopeNamespace_async - */ + /** + * Creates a fleet namespace. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent (project and location) where the Namespace will be + * created. Specified in the format `projects/* /locations/* /scopes/*`. + * @param {string} request.scopeNamespaceId + * Required. Client chosen ID for the Namespace. `namespace_id` must be a + * valid RFC 1123 compliant DNS label: + * + * 1. At most 63 characters in length + * 2. It must consist of lower case alphanumeric characters or `-` + * 3. It must start and end with an alphanumeric character + * + * Which can be expressed as the regex: `[a-z0-9]([-a-z0-9]*[a-z0-9])?`, + * with a maximum length of 63 characters. + * @param {google.cloud.gkehub.v1.Namespace} request.scopeNamespace + * Required. The fleet namespace 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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_hub.create_scope_namespace.js + * region_tag:gkehub_v1_generated_GkeHub_CreateScopeNamespace_async + */ createScopeNamespace( - request?: protos.google.cloud.gkehub.v1.ICreateScopeNamespaceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkehub.v1.ICreateScopeNamespaceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.gkehub.v1.INamespace, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createScopeNamespace( - request: protos.google.cloud.gkehub.v1.ICreateScopeNamespaceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.ICreateScopeNamespaceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.gkehub.v1.INamespace, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createScopeNamespace( - request: protos.google.cloud.gkehub.v1.ICreateScopeNamespaceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.ICreateScopeNamespaceRequest, + callback: Callback< + LROperation< + protos.google.cloud.gkehub.v1.INamespace, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createScopeNamespace( - request?: protos.google.cloud.gkehub.v1.ICreateScopeNamespaceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.gkehub.v1.ICreateScopeNamespaceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.gkehub.v1.INamespace, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.gkehub.v1.INamespace, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.gkehub.v1.INamespace, + protos.google.cloud.gkehub.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.gkehub.v1.INamespace, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createScopeNamespace response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createScopeNamespace request %j', request); - return this.innerApiCalls.createScopeNamespace(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createScopeNamespace response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createScopeNamespace(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.gkehub.v1.INamespace, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createScopeNamespace response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createScopeNamespace()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_hub.create_scope_namespace.js - * region_tag:gkehub_v1_generated_GkeHub_CreateScopeNamespace_async - */ - async checkCreateScopeNamespaceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createScopeNamespace()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_hub.create_scope_namespace.js + * region_tag:gkehub_v1_generated_GkeHub_CreateScopeNamespace_async + */ + async checkCreateScopeNamespaceProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.gkehub.v1.Namespace, + protos.google.cloud.gkehub.v1.OperationMetadata + > + > { this._log.info('createScopeNamespace long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createScopeNamespace, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createScopeNamespace, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.gkehub.v1.Namespace, + protos.google.cloud.gkehub.v1.OperationMetadata + >; } -/** - * Updates a fleet namespace. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.gkehub.v1.Namespace} request.scopeNamespace - * Required. A namespace with fields updated. The 'name' field in this - * namespace is used to identify the resource to update. Given 'updated' - * prefix to follow go/proto-best-practices-checkers#keyword_conflict - * @param {google.protobuf.FieldMask} request.updateMask - * Required. The 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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_hub.update_scope_namespace.js - * region_tag:gkehub_v1_generated_GkeHub_UpdateScopeNamespace_async - */ + /** + * Updates a fleet namespace. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.gkehub.v1.Namespace} request.scopeNamespace + * Required. A namespace with fields updated. The 'name' field in this + * namespace is used to identify the resource to update. Given 'updated' + * prefix to follow go/proto-best-practices-checkers#keyword_conflict + * @param {google.protobuf.FieldMask} request.updateMask + * Required. The 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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_hub.update_scope_namespace.js + * region_tag:gkehub_v1_generated_GkeHub_UpdateScopeNamespace_async + */ updateScopeNamespace( - request?: protos.google.cloud.gkehub.v1.IUpdateScopeNamespaceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkehub.v1.IUpdateScopeNamespaceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.gkehub.v1.INamespace, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateScopeNamespace( - request: protos.google.cloud.gkehub.v1.IUpdateScopeNamespaceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.IUpdateScopeNamespaceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.gkehub.v1.INamespace, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateScopeNamespace( - request: protos.google.cloud.gkehub.v1.IUpdateScopeNamespaceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.IUpdateScopeNamespaceRequest, + callback: Callback< + LROperation< + protos.google.cloud.gkehub.v1.INamespace, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateScopeNamespace( - request?: protos.google.cloud.gkehub.v1.IUpdateScopeNamespaceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.gkehub.v1.IUpdateScopeNamespaceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.gkehub.v1.INamespace, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.gkehub.v1.INamespace, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.gkehub.v1.INamespace, + protos.google.cloud.gkehub.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({ - 'scope_namespace.name': request.scopeNamespace!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'scope_namespace.name': request.scopeNamespace!.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.gkehub.v1.INamespace, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateScopeNamespace response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateScopeNamespace request %j', request); - return this.innerApiCalls.updateScopeNamespace(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateScopeNamespace response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateScopeNamespace(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.gkehub.v1.INamespace, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateScopeNamespace response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateScopeNamespace()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_hub.update_scope_namespace.js - * region_tag:gkehub_v1_generated_GkeHub_UpdateScopeNamespace_async - */ - async checkUpdateScopeNamespaceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateScopeNamespace()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_hub.update_scope_namespace.js + * region_tag:gkehub_v1_generated_GkeHub_UpdateScopeNamespace_async + */ + async checkUpdateScopeNamespaceProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.gkehub.v1.Namespace, + protos.google.cloud.gkehub.v1.OperationMetadata + > + > { this._log.info('updateScopeNamespace long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.updateScopeNamespace, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateScopeNamespace, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.gkehub.v1.Namespace, + protos.google.cloud.gkehub.v1.OperationMetadata + >; } -/** - * Deletes a fleet namespace. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The Namespace resource name in the format - * `projects/* /locations/* /scopes/* /namespaces/*`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_hub.delete_scope_namespace.js - * region_tag:gkehub_v1_generated_GkeHub_DeleteScopeNamespace_async - */ + /** + * Deletes a fleet namespace. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The Namespace resource name in the format + * `projects/* /locations/* /scopes/* /namespaces/*`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_hub.delete_scope_namespace.js + * region_tag:gkehub_v1_generated_GkeHub_DeleteScopeNamespace_async + */ deleteScopeNamespace( - request?: protos.google.cloud.gkehub.v1.IDeleteScopeNamespaceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkehub.v1.IDeleteScopeNamespaceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteScopeNamespace( - request: protos.google.cloud.gkehub.v1.IDeleteScopeNamespaceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.IDeleteScopeNamespaceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteScopeNamespace( - request: protos.google.cloud.gkehub.v1.IDeleteScopeNamespaceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.IDeleteScopeNamespaceRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteScopeNamespace( - request?: protos.google.cloud.gkehub.v1.IDeleteScopeNamespaceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.gkehub.v1.IDeleteScopeNamespaceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.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.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteScopeNamespace response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteScopeNamespace request %j', request); - return this.innerApiCalls.deleteScopeNamespace(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteScopeNamespace response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteScopeNamespace(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteScopeNamespace response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteScopeNamespace()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_hub.delete_scope_namespace.js - * region_tag:gkehub_v1_generated_GkeHub_DeleteScopeNamespace_async - */ - async checkDeleteScopeNamespaceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteScopeNamespace()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_hub.delete_scope_namespace.js + * region_tag:gkehub_v1_generated_GkeHub_DeleteScopeNamespace_async + */ + async checkDeleteScopeNamespaceProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.gkehub.v1.OperationMetadata + > + > { this._log.info('deleteScopeNamespace long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteScopeNamespace, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteScopeNamespace, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.gkehub.v1.OperationMetadata + >; } -/** - * Creates a Scope RBACRoleBinding. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent (project and location) where the RBACRoleBinding will - * be created. Specified in the format `projects/* /locations/* /scopes/*`. - * @param {string} request.rbacrolebindingId - * Required. Client chosen ID for the RBACRoleBinding. `rbacrolebinding_id` - * must be a valid RFC 1123 compliant DNS label: - * - * 1. At most 63 characters in length - * 2. It must consist of lower case alphanumeric characters or `-` - * 3. It must start and end with an alphanumeric character - * - * Which can be expressed as the regex: `[a-z0-9]([-a-z0-9]*[a-z0-9])?`, - * with a maximum length of 63 characters. - * @param {google.cloud.gkehub.v1.RBACRoleBinding} request.rbacrolebinding - * Required. The rbacrolebindings 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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_hub.create_scope_r_b_a_c_role_binding.js - * region_tag:gkehub_v1_generated_GkeHub_CreateScopeRBACRoleBinding_async - */ + /** + * Creates a Scope RBACRoleBinding. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent (project and location) where the RBACRoleBinding will + * be created. Specified in the format `projects/* /locations/* /scopes/*`. + * @param {string} request.rbacrolebindingId + * Required. Client chosen ID for the RBACRoleBinding. `rbacrolebinding_id` + * must be a valid RFC 1123 compliant DNS label: + * + * 1. At most 63 characters in length + * 2. It must consist of lower case alphanumeric characters or `-` + * 3. It must start and end with an alphanumeric character + * + * Which can be expressed as the regex: `[a-z0-9]([-a-z0-9]*[a-z0-9])?`, + * with a maximum length of 63 characters. + * @param {google.cloud.gkehub.v1.RBACRoleBinding} request.rbacrolebinding + * Required. The rbacrolebindings 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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_hub.create_scope_r_b_a_c_role_binding.js + * region_tag:gkehub_v1_generated_GkeHub_CreateScopeRBACRoleBinding_async + */ createScopeRBACRoleBinding( - request?: protos.google.cloud.gkehub.v1.ICreateScopeRBACRoleBindingRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkehub.v1.ICreateScopeRBACRoleBindingRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.gkehub.v1.IRBACRoleBinding, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createScopeRBACRoleBinding( - request: protos.google.cloud.gkehub.v1.ICreateScopeRBACRoleBindingRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.ICreateScopeRBACRoleBindingRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.gkehub.v1.IRBACRoleBinding, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createScopeRBACRoleBinding( - request: protos.google.cloud.gkehub.v1.ICreateScopeRBACRoleBindingRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.ICreateScopeRBACRoleBindingRequest, + callback: Callback< + LROperation< + protos.google.cloud.gkehub.v1.IRBACRoleBinding, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createScopeRBACRoleBinding( - request?: protos.google.cloud.gkehub.v1.ICreateScopeRBACRoleBindingRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.gkehub.v1.ICreateScopeRBACRoleBindingRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.gkehub.v1.IRBACRoleBinding, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.gkehub.v1.IRBACRoleBinding, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.gkehub.v1.IRBACRoleBinding, + protos.google.cloud.gkehub.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.gkehub.v1.IRBACRoleBinding, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createScopeRBACRoleBinding response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createScopeRBACRoleBinding request %j', request); - return this.innerApiCalls.createScopeRbacRoleBinding(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createScopeRBACRoleBinding response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createScopeRbacRoleBinding(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.gkehub.v1.IRBACRoleBinding, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createScopeRBACRoleBinding response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createScopeRBACRoleBinding()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_hub.create_scope_r_b_a_c_role_binding.js - * region_tag:gkehub_v1_generated_GkeHub_CreateScopeRBACRoleBinding_async - */ - async checkCreateScopeRBACRoleBindingProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createScopeRBACRoleBinding()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_hub.create_scope_r_b_a_c_role_binding.js + * region_tag:gkehub_v1_generated_GkeHub_CreateScopeRBACRoleBinding_async + */ + async checkCreateScopeRBACRoleBindingProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.gkehub.v1.RBACRoleBinding, + protos.google.cloud.gkehub.v1.OperationMetadata + > + > { this._log.info('createScopeRBACRoleBinding long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createScopeRBACRoleBinding, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createScopeRBACRoleBinding, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.gkehub.v1.RBACRoleBinding, + protos.google.cloud.gkehub.v1.OperationMetadata + >; } -/** - * Updates a Scope RBACRoleBinding. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.gkehub.v1.RBACRoleBinding} request.rbacrolebinding - * Required. A rbacrolebinding with fields updated. The 'name' field in this - * rbacrolebinding is used to identify the resource to update. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. The 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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_hub.update_scope_r_b_a_c_role_binding.js - * region_tag:gkehub_v1_generated_GkeHub_UpdateScopeRBACRoleBinding_async - */ + /** + * Updates a Scope RBACRoleBinding. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.gkehub.v1.RBACRoleBinding} request.rbacrolebinding + * Required. A rbacrolebinding with fields updated. The 'name' field in this + * rbacrolebinding is used to identify the resource to update. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. The 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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_hub.update_scope_r_b_a_c_role_binding.js + * region_tag:gkehub_v1_generated_GkeHub_UpdateScopeRBACRoleBinding_async + */ updateScopeRBACRoleBinding( - request?: protos.google.cloud.gkehub.v1.IUpdateScopeRBACRoleBindingRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkehub.v1.IUpdateScopeRBACRoleBindingRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.gkehub.v1.IRBACRoleBinding, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateScopeRBACRoleBinding( - request: protos.google.cloud.gkehub.v1.IUpdateScopeRBACRoleBindingRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.IUpdateScopeRBACRoleBindingRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.gkehub.v1.IRBACRoleBinding, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateScopeRBACRoleBinding( - request: protos.google.cloud.gkehub.v1.IUpdateScopeRBACRoleBindingRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.IUpdateScopeRBACRoleBindingRequest, + callback: Callback< + LROperation< + protos.google.cloud.gkehub.v1.IRBACRoleBinding, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateScopeRBACRoleBinding( - request?: protos.google.cloud.gkehub.v1.IUpdateScopeRBACRoleBindingRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.gkehub.v1.IUpdateScopeRBACRoleBindingRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.gkehub.v1.IRBACRoleBinding, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.gkehub.v1.IRBACRoleBinding, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.gkehub.v1.IRBACRoleBinding, + protos.google.cloud.gkehub.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({ - 'rbacrolebinding.name': request.rbacrolebinding!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'rbacrolebinding.name': request.rbacrolebinding!.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.gkehub.v1.IRBACRoleBinding, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateScopeRBACRoleBinding response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateScopeRBACRoleBinding request %j', request); - return this.innerApiCalls.updateScopeRbacRoleBinding(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateScopeRBACRoleBinding response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateScopeRbacRoleBinding(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.gkehub.v1.IRBACRoleBinding, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateScopeRBACRoleBinding response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateScopeRBACRoleBinding()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_hub.update_scope_r_b_a_c_role_binding.js - * region_tag:gkehub_v1_generated_GkeHub_UpdateScopeRBACRoleBinding_async - */ - async checkUpdateScopeRBACRoleBindingProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateScopeRBACRoleBinding()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_hub.update_scope_r_b_a_c_role_binding.js + * region_tag:gkehub_v1_generated_GkeHub_UpdateScopeRBACRoleBinding_async + */ + async checkUpdateScopeRBACRoleBindingProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.gkehub.v1.RBACRoleBinding, + protos.google.cloud.gkehub.v1.OperationMetadata + > + > { this._log.info('updateScopeRBACRoleBinding long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.updateScopeRBACRoleBinding, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateScopeRBACRoleBinding, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.gkehub.v1.RBACRoleBinding, + protos.google.cloud.gkehub.v1.OperationMetadata + >; } -/** - * Deletes a Scope RBACRoleBinding. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The RBACRoleBinding resource name in the format - * `projects/* /locations/* /scopes/* /rbacrolebindings/*`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_hub.delete_scope_r_b_a_c_role_binding.js - * region_tag:gkehub_v1_generated_GkeHub_DeleteScopeRBACRoleBinding_async - */ + /** + * Deletes a Scope RBACRoleBinding. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The RBACRoleBinding resource name in the format + * `projects/* /locations/* /scopes/* /rbacrolebindings/*`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_hub.delete_scope_r_b_a_c_role_binding.js + * region_tag:gkehub_v1_generated_GkeHub_DeleteScopeRBACRoleBinding_async + */ deleteScopeRBACRoleBinding( - request?: protos.google.cloud.gkehub.v1.IDeleteScopeRBACRoleBindingRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkehub.v1.IDeleteScopeRBACRoleBindingRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteScopeRBACRoleBinding( - request: protos.google.cloud.gkehub.v1.IDeleteScopeRBACRoleBindingRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.IDeleteScopeRBACRoleBindingRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteScopeRBACRoleBinding( - request: protos.google.cloud.gkehub.v1.IDeleteScopeRBACRoleBindingRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.IDeleteScopeRBACRoleBindingRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteScopeRBACRoleBinding( - request?: protos.google.cloud.gkehub.v1.IDeleteScopeRBACRoleBindingRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.gkehub.v1.IDeleteScopeRBACRoleBindingRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.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.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteScopeRBACRoleBinding response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteScopeRBACRoleBinding request %j', request); - return this.innerApiCalls.deleteScopeRbacRoleBinding(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteScopeRBACRoleBinding response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteScopeRbacRoleBinding(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteScopeRBACRoleBinding response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteScopeRBACRoleBinding()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_hub.delete_scope_r_b_a_c_role_binding.js - * region_tag:gkehub_v1_generated_GkeHub_DeleteScopeRBACRoleBinding_async - */ - async checkDeleteScopeRBACRoleBindingProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteScopeRBACRoleBinding()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_hub.delete_scope_r_b_a_c_role_binding.js + * region_tag:gkehub_v1_generated_GkeHub_DeleteScopeRBACRoleBinding_async + */ + async checkDeleteScopeRBACRoleBindingProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.gkehub.v1.OperationMetadata + > + > { this._log.info('deleteScopeRBACRoleBinding long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteScopeRBACRoleBinding, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteScopeRBACRoleBinding, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.gkehub.v1.OperationMetadata + >; } -/** - * Creates a Scope. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent (project and location) where the Scope will be - * created. Specified in the format `projects/* /locations/*`. - * @param {string} request.scopeId - * Required. Client chosen ID for the Scope. `scope_id` must be a - * ???? - * @param {google.cloud.gkehub.v1.Scope} request.scope - * Required. The Scope 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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_hub.create_scope.js - * region_tag:gkehub_v1_generated_GkeHub_CreateScope_async - */ + /** + * Creates a Scope. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent (project and location) where the Scope will be + * created. Specified in the format `projects/* /locations/*`. + * @param {string} request.scopeId + * Required. Client chosen ID for the Scope. `scope_id` must be a + * ???? + * @param {google.cloud.gkehub.v1.Scope} request.scope + * Required. The Scope 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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_hub.create_scope.js + * region_tag:gkehub_v1_generated_GkeHub_CreateScope_async + */ createScope( - request?: protos.google.cloud.gkehub.v1.ICreateScopeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkehub.v1.ICreateScopeRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.gkehub.v1.IScope, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createScope( - request: protos.google.cloud.gkehub.v1.ICreateScopeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.ICreateScopeRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.gkehub.v1.IScope, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createScope( - request: protos.google.cloud.gkehub.v1.ICreateScopeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.ICreateScopeRequest, + callback: Callback< + LROperation< + protos.google.cloud.gkehub.v1.IScope, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createScope( - request?: protos.google.cloud.gkehub.v1.ICreateScopeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.gkehub.v1.ICreateScopeRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.gkehub.v1.IScope, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.gkehub.v1.IScope, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.gkehub.v1.IScope, + protos.google.cloud.gkehub.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.gkehub.v1.IScope, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createScope response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createScope request %j', request); - return this.innerApiCalls.createScope(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createScope response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createScope(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.gkehub.v1.IScope, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createScope response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createScope()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_hub.create_scope.js - * region_tag:gkehub_v1_generated_GkeHub_CreateScope_async - */ - async checkCreateScopeProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createScope()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_hub.create_scope.js + * region_tag:gkehub_v1_generated_GkeHub_CreateScope_async + */ + async checkCreateScopeProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.gkehub.v1.Scope, + protos.google.cloud.gkehub.v1.OperationMetadata + > + > { this._log.info('createScope long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createScope, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createScope, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.gkehub.v1.Scope, + protos.google.cloud.gkehub.v1.OperationMetadata + >; } -/** - * Updates a scopes. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.gkehub.v1.Scope} request.scope - * Required. A Scope with fields updated. The 'name' field in this - * namespace is used to identify the resource to update. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. The 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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_hub.update_scope.js - * region_tag:gkehub_v1_generated_GkeHub_UpdateScope_async - */ + /** + * Updates a scopes. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.gkehub.v1.Scope} request.scope + * Required. A Scope with fields updated. The 'name' field in this + * namespace is used to identify the resource to update. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. The 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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_hub.update_scope.js + * region_tag:gkehub_v1_generated_GkeHub_UpdateScope_async + */ updateScope( - request?: protos.google.cloud.gkehub.v1.IUpdateScopeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkehub.v1.IUpdateScopeRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.gkehub.v1.IScope, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateScope( - request: protos.google.cloud.gkehub.v1.IUpdateScopeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.IUpdateScopeRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.gkehub.v1.IScope, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateScope( - request: protos.google.cloud.gkehub.v1.IUpdateScopeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.IUpdateScopeRequest, + callback: Callback< + LROperation< + protos.google.cloud.gkehub.v1.IScope, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateScope( - request?: protos.google.cloud.gkehub.v1.IUpdateScopeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.gkehub.v1.IUpdateScopeRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.gkehub.v1.IScope, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.gkehub.v1.IScope, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.gkehub.v1.IScope, + protos.google.cloud.gkehub.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({ - 'scope.name': request.scope!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'scope.name': request.scope!.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.gkehub.v1.IScope, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateScope response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateScope request %j', request); - return this.innerApiCalls.updateScope(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateScope response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateScope(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.gkehub.v1.IScope, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateScope response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateScope()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_hub.update_scope.js - * region_tag:gkehub_v1_generated_GkeHub_UpdateScope_async - */ - async checkUpdateScopeProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateScope()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_hub.update_scope.js + * region_tag:gkehub_v1_generated_GkeHub_UpdateScope_async + */ + async checkUpdateScopeProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.gkehub.v1.Scope, + protos.google.cloud.gkehub.v1.OperationMetadata + > + > { this._log.info('updateScope long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.updateScope, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateScope, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.gkehub.v1.Scope, + protos.google.cloud.gkehub.v1.OperationMetadata + >; } -/** - * Deletes a Scope. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The Scope resource name in the format - * `projects/* /locations/* /scopes/*`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_hub.delete_scope.js - * region_tag:gkehub_v1_generated_GkeHub_DeleteScope_async - */ + /** + * Deletes a Scope. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The Scope resource name in the format + * `projects/* /locations/* /scopes/*`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_hub.delete_scope.js + * region_tag:gkehub_v1_generated_GkeHub_DeleteScope_async + */ deleteScope( - request?: protos.google.cloud.gkehub.v1.IDeleteScopeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkehub.v1.IDeleteScopeRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteScope( - request: protos.google.cloud.gkehub.v1.IDeleteScopeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.IDeleteScopeRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteScope( - request: protos.google.cloud.gkehub.v1.IDeleteScopeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.IDeleteScopeRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteScope( - request?: protos.google.cloud.gkehub.v1.IDeleteScopeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.gkehub.v1.IDeleteScopeRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.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.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteScope response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteScope request %j', request); - return this.innerApiCalls.deleteScope(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteScope response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteScope(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteScope response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteScope()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_hub.delete_scope.js - * region_tag:gkehub_v1_generated_GkeHub_DeleteScope_async - */ - async checkDeleteScopeProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteScope()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_hub.delete_scope.js + * region_tag:gkehub_v1_generated_GkeHub_DeleteScope_async + */ + async checkDeleteScopeProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.gkehub.v1.OperationMetadata + > + > { this._log.info('deleteScope long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteScope, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteScope, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.gkehub.v1.OperationMetadata + >; } -/** - * Creates a MembershipBinding. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent (project and location) where the MembershipBinding - * will be created. Specified in the format - * `projects/* /locations/* /memberships/*`. - * @param {google.cloud.gkehub.v1.MembershipBinding} request.membershipBinding - * Required. The MembershipBinding to create. - * @param {string} request.membershipBindingId - * Required. The ID to use for the MembershipBinding. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_hub.create_membership_binding.js - * region_tag:gkehub_v1_generated_GkeHub_CreateMembershipBinding_async - */ + /** + * Creates a MembershipBinding. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent (project and location) where the MembershipBinding + * will be created. Specified in the format + * `projects/* /locations/* /memberships/*`. + * @param {google.cloud.gkehub.v1.MembershipBinding} request.membershipBinding + * Required. The MembershipBinding to create. + * @param {string} request.membershipBindingId + * Required. The ID to use for the MembershipBinding. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_hub.create_membership_binding.js + * region_tag:gkehub_v1_generated_GkeHub_CreateMembershipBinding_async + */ createMembershipBinding( - request?: protos.google.cloud.gkehub.v1.ICreateMembershipBindingRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkehub.v1.ICreateMembershipBindingRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.gkehub.v1.IMembershipBinding, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createMembershipBinding( - request: protos.google.cloud.gkehub.v1.ICreateMembershipBindingRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.ICreateMembershipBindingRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.gkehub.v1.IMembershipBinding, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createMembershipBinding( - request: protos.google.cloud.gkehub.v1.ICreateMembershipBindingRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.ICreateMembershipBindingRequest, + callback: Callback< + LROperation< + protos.google.cloud.gkehub.v1.IMembershipBinding, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createMembershipBinding( - request?: protos.google.cloud.gkehub.v1.ICreateMembershipBindingRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.gkehub.v1.ICreateMembershipBindingRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.gkehub.v1.IMembershipBinding, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.gkehub.v1.IMembershipBinding, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.gkehub.v1.IMembershipBinding, + protos.google.cloud.gkehub.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.gkehub.v1.IMembershipBinding, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createMembershipBinding response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createMembershipBinding request %j', request); - return this.innerApiCalls.createMembershipBinding(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createMembershipBinding response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createMembershipBinding(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.gkehub.v1.IMembershipBinding, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createMembershipBinding response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createMembershipBinding()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_hub.create_membership_binding.js - * region_tag:gkehub_v1_generated_GkeHub_CreateMembershipBinding_async - */ - async checkCreateMembershipBindingProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createMembershipBinding()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_hub.create_membership_binding.js + * region_tag:gkehub_v1_generated_GkeHub_CreateMembershipBinding_async + */ + async checkCreateMembershipBindingProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.gkehub.v1.MembershipBinding, + protos.google.cloud.gkehub.v1.OperationMetadata + > + > { this._log.info('createMembershipBinding long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createMembershipBinding, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createMembershipBinding, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.gkehub.v1.MembershipBinding, + protos.google.cloud.gkehub.v1.OperationMetadata + >; } -/** - * Updates a MembershipBinding. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.gkehub.v1.MembershipBinding} request.membershipBinding - * Required. The MembershipBinding object with fields updated. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. The 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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_hub.update_membership_binding.js - * region_tag:gkehub_v1_generated_GkeHub_UpdateMembershipBinding_async - */ - updateMembershipBinding( - request?: protos.google.cloud.gkehub.v1.IUpdateMembershipBindingRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + /** + * Updates a MembershipBinding. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.gkehub.v1.MembershipBinding} request.membershipBinding + * Required. The MembershipBinding object with fields updated. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. The 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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_hub.update_membership_binding.js + * region_tag:gkehub_v1_generated_GkeHub_UpdateMembershipBinding_async + */ + updateMembershipBinding( + request?: protos.google.cloud.gkehub.v1.IUpdateMembershipBindingRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.gkehub.v1.IMembershipBinding, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateMembershipBinding( - request: protos.google.cloud.gkehub.v1.IUpdateMembershipBindingRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.IUpdateMembershipBindingRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.gkehub.v1.IMembershipBinding, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateMembershipBinding( - request: protos.google.cloud.gkehub.v1.IUpdateMembershipBindingRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.IUpdateMembershipBindingRequest, + callback: Callback< + LROperation< + protos.google.cloud.gkehub.v1.IMembershipBinding, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateMembershipBinding( - request?: protos.google.cloud.gkehub.v1.IUpdateMembershipBindingRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.gkehub.v1.IUpdateMembershipBindingRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.gkehub.v1.IMembershipBinding, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.gkehub.v1.IMembershipBinding, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.gkehub.v1.IMembershipBinding, + protos.google.cloud.gkehub.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({ - 'membership_binding.name': request.membershipBinding!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'membership_binding.name': request.membershipBinding!.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.gkehub.v1.IMembershipBinding, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateMembershipBinding response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateMembershipBinding request %j', request); - return this.innerApiCalls.updateMembershipBinding(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateMembershipBinding response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateMembershipBinding(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.gkehub.v1.IMembershipBinding, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateMembershipBinding response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateMembershipBinding()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_hub.update_membership_binding.js - * region_tag:gkehub_v1_generated_GkeHub_UpdateMembershipBinding_async - */ - async checkUpdateMembershipBindingProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateMembershipBinding()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_hub.update_membership_binding.js + * region_tag:gkehub_v1_generated_GkeHub_UpdateMembershipBinding_async + */ + async checkUpdateMembershipBindingProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.gkehub.v1.MembershipBinding, + protos.google.cloud.gkehub.v1.OperationMetadata + > + > { this._log.info('updateMembershipBinding long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.updateMembershipBinding, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateMembershipBinding, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.gkehub.v1.MembershipBinding, + protos.google.cloud.gkehub.v1.OperationMetadata + >; } -/** - * Deletes a MembershipBinding. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The MembershipBinding resource name in the format - * `projects/* /locations/* /memberships/* /bindings/*`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_hub.delete_membership_binding.js - * region_tag:gkehub_v1_generated_GkeHub_DeleteMembershipBinding_async - */ + /** + * Deletes a MembershipBinding. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The MembershipBinding resource name in the format + * `projects/* /locations/* /memberships/* /bindings/*`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_hub.delete_membership_binding.js + * region_tag:gkehub_v1_generated_GkeHub_DeleteMembershipBinding_async + */ deleteMembershipBinding( - request?: protos.google.cloud.gkehub.v1.IDeleteMembershipBindingRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkehub.v1.IDeleteMembershipBindingRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteMembershipBinding( - request: protos.google.cloud.gkehub.v1.IDeleteMembershipBindingRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.IDeleteMembershipBindingRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteMembershipBinding( - request: protos.google.cloud.gkehub.v1.IDeleteMembershipBindingRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.IDeleteMembershipBindingRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteMembershipBinding( - request?: protos.google.cloud.gkehub.v1.IDeleteMembershipBindingRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.gkehub.v1.IDeleteMembershipBindingRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.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.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteMembershipBinding response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteMembershipBinding request %j', request); - return this.innerApiCalls.deleteMembershipBinding(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteMembershipBinding response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteMembershipBinding(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteMembershipBinding response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteMembershipBinding()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_hub.delete_membership_binding.js - * region_tag:gkehub_v1_generated_GkeHub_DeleteMembershipBinding_async - */ - async checkDeleteMembershipBindingProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteMembershipBinding()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_hub.delete_membership_binding.js + * region_tag:gkehub_v1_generated_GkeHub_DeleteMembershipBinding_async + */ + async checkDeleteMembershipBindingProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.gkehub.v1.OperationMetadata + > + > { this._log.info('deleteMembershipBinding long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteMembershipBinding, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteMembershipBinding, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.gkehub.v1.OperationMetadata + >; } -/** - * Creates a Membership RBACRoleBinding. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent (project and location) where the RBACRoleBinding will - * be created. Specified in the format `projects/* /locations/* /memberships/*`. - * @param {string} request.rbacrolebindingId - * Required. Client chosen ID for the RBACRoleBinding. `rbacrolebinding_id` - * must be a valid RFC 1123 compliant DNS label: - * - * 1. At most 63 characters in length - * 2. It must consist of lower case alphanumeric characters or `-` - * 3. It must start and end with an alphanumeric character - * - * Which can be expressed as the regex: `[a-z0-9]([-a-z0-9]*[a-z0-9])?`, - * with a maximum length of 63 characters. - * @param {google.cloud.gkehub.v1.RBACRoleBinding} request.rbacrolebinding - * Required. The rbacrolebindings 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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_hub.create_membership_r_b_a_c_role_binding.js - * region_tag:gkehub_v1_generated_GkeHub_CreateMembershipRBACRoleBinding_async - */ + /** + * Creates a Membership RBACRoleBinding. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent (project and location) where the RBACRoleBinding will + * be created. Specified in the format `projects/* /locations/* /memberships/*`. + * @param {string} request.rbacrolebindingId + * Required. Client chosen ID for the RBACRoleBinding. `rbacrolebinding_id` + * must be a valid RFC 1123 compliant DNS label: + * + * 1. At most 63 characters in length + * 2. It must consist of lower case alphanumeric characters or `-` + * 3. It must start and end with an alphanumeric character + * + * Which can be expressed as the regex: `[a-z0-9]([-a-z0-9]*[a-z0-9])?`, + * with a maximum length of 63 characters. + * @param {google.cloud.gkehub.v1.RBACRoleBinding} request.rbacrolebinding + * Required. The rbacrolebindings 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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_hub.create_membership_r_b_a_c_role_binding.js + * region_tag:gkehub_v1_generated_GkeHub_CreateMembershipRBACRoleBinding_async + */ createMembershipRBACRoleBinding( - request?: protos.google.cloud.gkehub.v1.ICreateMembershipRBACRoleBindingRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkehub.v1.ICreateMembershipRBACRoleBindingRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.gkehub.v1.IRBACRoleBinding, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createMembershipRBACRoleBinding( - request: protos.google.cloud.gkehub.v1.ICreateMembershipRBACRoleBindingRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.ICreateMembershipRBACRoleBindingRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.gkehub.v1.IRBACRoleBinding, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createMembershipRBACRoleBinding( - request: protos.google.cloud.gkehub.v1.ICreateMembershipRBACRoleBindingRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.ICreateMembershipRBACRoleBindingRequest, + callback: Callback< + LROperation< + protos.google.cloud.gkehub.v1.IRBACRoleBinding, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createMembershipRBACRoleBinding( - request?: protos.google.cloud.gkehub.v1.ICreateMembershipRBACRoleBindingRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.gkehub.v1.ICreateMembershipRBACRoleBindingRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.gkehub.v1.IRBACRoleBinding, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.gkehub.v1.IRBACRoleBinding, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.gkehub.v1.IRBACRoleBinding, + protos.google.cloud.gkehub.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.gkehub.v1.IRBACRoleBinding, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { - this._log.info('createMembershipRBACRoleBinding response %j', rawResponse); + this._log.info( + 'createMembershipRBACRoleBinding response %j', + rawResponse, + ); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createMembershipRBACRoleBinding request %j', request); - return this.innerApiCalls.createMembershipRbacRoleBinding(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createMembershipRBACRoleBinding response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createMembershipRbacRoleBinding(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.gkehub.v1.IRBACRoleBinding, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info( + 'createMembershipRBACRoleBinding response %j', + rawResponse, + ); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createMembershipRBACRoleBinding()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_hub.create_membership_r_b_a_c_role_binding.js - * region_tag:gkehub_v1_generated_GkeHub_CreateMembershipRBACRoleBinding_async - */ - async checkCreateMembershipRBACRoleBindingProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createMembershipRBACRoleBinding()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_hub.create_membership_r_b_a_c_role_binding.js + * region_tag:gkehub_v1_generated_GkeHub_CreateMembershipRBACRoleBinding_async + */ + async checkCreateMembershipRBACRoleBindingProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.gkehub.v1.RBACRoleBinding, + protos.google.cloud.gkehub.v1.OperationMetadata + > + > { this._log.info('createMembershipRBACRoleBinding long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createMembershipRBACRoleBinding, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createMembershipRBACRoleBinding, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.gkehub.v1.RBACRoleBinding, + protos.google.cloud.gkehub.v1.OperationMetadata + >; } -/** - * Updates a Membership RBACRoleBinding. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.gkehub.v1.RBACRoleBinding} request.rbacrolebinding - * Required. A rbacrolebinding with fields updated. The 'name' field in this - * rbacrolebinding is used to identify the resource to update. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. The 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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_hub.update_membership_r_b_a_c_role_binding.js - * region_tag:gkehub_v1_generated_GkeHub_UpdateMembershipRBACRoleBinding_async - */ + /** + * Updates a Membership RBACRoleBinding. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.gkehub.v1.RBACRoleBinding} request.rbacrolebinding + * Required. A rbacrolebinding with fields updated. The 'name' field in this + * rbacrolebinding is used to identify the resource to update. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. The 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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_hub.update_membership_r_b_a_c_role_binding.js + * region_tag:gkehub_v1_generated_GkeHub_UpdateMembershipRBACRoleBinding_async + */ updateMembershipRBACRoleBinding( - request?: protos.google.cloud.gkehub.v1.IUpdateMembershipRBACRoleBindingRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkehub.v1.IUpdateMembershipRBACRoleBindingRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.gkehub.v1.IRBACRoleBinding, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateMembershipRBACRoleBinding( - request: protos.google.cloud.gkehub.v1.IUpdateMembershipRBACRoleBindingRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.IUpdateMembershipRBACRoleBindingRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.gkehub.v1.IRBACRoleBinding, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateMembershipRBACRoleBinding( - request: protos.google.cloud.gkehub.v1.IUpdateMembershipRBACRoleBindingRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.IUpdateMembershipRBACRoleBindingRequest, + callback: Callback< + LROperation< + protos.google.cloud.gkehub.v1.IRBACRoleBinding, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateMembershipRBACRoleBinding( - request?: protos.google.cloud.gkehub.v1.IUpdateMembershipRBACRoleBindingRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.gkehub.v1.IUpdateMembershipRBACRoleBindingRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.gkehub.v1.IRBACRoleBinding, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.gkehub.v1.IRBACRoleBinding, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.gkehub.v1.IRBACRoleBinding, + protos.google.cloud.gkehub.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({ - 'rbacrolebinding.name': request.rbacrolebinding!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'rbacrolebinding.name': request.rbacrolebinding!.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.gkehub.v1.IRBACRoleBinding, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { - this._log.info('updateMembershipRBACRoleBinding response %j', rawResponse); + this._log.info( + 'updateMembershipRBACRoleBinding response %j', + rawResponse, + ); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateMembershipRBACRoleBinding request %j', request); - return this.innerApiCalls.updateMembershipRbacRoleBinding(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateMembershipRBACRoleBinding response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateMembershipRbacRoleBinding(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.gkehub.v1.IRBACRoleBinding, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info( + 'updateMembershipRBACRoleBinding response %j', + rawResponse, + ); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateMembershipRBACRoleBinding()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_hub.update_membership_r_b_a_c_role_binding.js - * region_tag:gkehub_v1_generated_GkeHub_UpdateMembershipRBACRoleBinding_async - */ - async checkUpdateMembershipRBACRoleBindingProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateMembershipRBACRoleBinding()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_hub.update_membership_r_b_a_c_role_binding.js + * region_tag:gkehub_v1_generated_GkeHub_UpdateMembershipRBACRoleBinding_async + */ + async checkUpdateMembershipRBACRoleBindingProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.gkehub.v1.RBACRoleBinding, + protos.google.cloud.gkehub.v1.OperationMetadata + > + > { this._log.info('updateMembershipRBACRoleBinding long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.updateMembershipRBACRoleBinding, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateMembershipRBACRoleBinding, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.gkehub.v1.RBACRoleBinding, + protos.google.cloud.gkehub.v1.OperationMetadata + >; } -/** - * Deletes a Membership RBACRoleBinding. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The RBACRoleBinding resource name in the format - * `projects/* /locations/* /memberships/* /rbacrolebindings/*`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_hub.delete_membership_r_b_a_c_role_binding.js - * region_tag:gkehub_v1_generated_GkeHub_DeleteMembershipRBACRoleBinding_async - */ + /** + * Deletes a Membership RBACRoleBinding. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The RBACRoleBinding resource name in the format + * `projects/* /locations/* /memberships/* /rbacrolebindings/*`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_hub.delete_membership_r_b_a_c_role_binding.js + * region_tag:gkehub_v1_generated_GkeHub_DeleteMembershipRBACRoleBinding_async + */ deleteMembershipRBACRoleBinding( - request?: protos.google.cloud.gkehub.v1.IDeleteMembershipRBACRoleBindingRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkehub.v1.IDeleteMembershipRBACRoleBindingRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteMembershipRBACRoleBinding( - request: protos.google.cloud.gkehub.v1.IDeleteMembershipRBACRoleBindingRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.IDeleteMembershipRBACRoleBindingRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteMembershipRBACRoleBinding( - request: protos.google.cloud.gkehub.v1.IDeleteMembershipRBACRoleBindingRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1.IDeleteMembershipRBACRoleBindingRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteMembershipRBACRoleBinding( - request?: protos.google.cloud.gkehub.v1.IDeleteMembershipRBACRoleBindingRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.gkehub.v1.IDeleteMembershipRBACRoleBindingRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.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.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { - this._log.info('deleteMembershipRBACRoleBinding response %j', rawResponse); + this._log.info( + 'deleteMembershipRBACRoleBinding response %j', + rawResponse, + ); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteMembershipRBACRoleBinding request %j', request); - return this.innerApiCalls.deleteMembershipRbacRoleBinding(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteMembershipRBACRoleBinding response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteMembershipRbacRoleBinding(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info( + 'deleteMembershipRBACRoleBinding response %j', + rawResponse, + ); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteMembershipRBACRoleBinding()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_hub.delete_membership_r_b_a_c_role_binding.js - * region_tag:gkehub_v1_generated_GkeHub_DeleteMembershipRBACRoleBinding_async - */ - async checkDeleteMembershipRBACRoleBindingProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteMembershipRBACRoleBinding()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_hub.delete_membership_r_b_a_c_role_binding.js + * region_tag:gkehub_v1_generated_GkeHub_DeleteMembershipRBACRoleBinding_async + */ + async checkDeleteMembershipRBACRoleBindingProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.gkehub.v1.OperationMetadata + > + > { this._log.info('deleteMembershipRBACRoleBinding long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteMembershipRBACRoleBinding, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteMembershipRBACRoleBinding, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.gkehub.v1.OperationMetadata + >; } - /** - * Lists Memberships in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent (project and location) where the Memberships will be - * listed. Specified in the format `projects/* /locations/*`. - * `projects/* /locations/-` list memberships in all the regions. - * @param {number} [request.pageSize] - * Optional. When requesting a 'page' of resources, `page_size` specifies - * number of resources to return. If unspecified or set to 0, all resources - * will be returned. - * @param {string} [request.pageToken] - * Optional. Token returned by previous call to `ListMemberships` which - * specifies the position in the list from where to continue listing the - * resources. - * @param {string} [request.filter] - * Optional. Lists Memberships that match the filter expression, following the - * syntax outlined in https://google.aip.dev/160. - * - * Examples: - * - * - Name is `bar` in project `foo-proj` and location `global`: - * - * name = "projects/foo-proj/locations/global/membership/bar" - * - * - Memberships that have a label called `foo`: - * - * labels.foo:* - * - * - Memberships that have a label called `foo` whose value is `bar`: - * - * labels.foo = bar - * - * - Memberships in the CREATING state: - * - * state = CREATING - * @param {string} [request.orderBy] - * Optional. One or more fields to compare and use to sort the output. - * See https://google.aip.dev/132#ordering. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link protos.google.cloud.gkehub.v1.Membership|Membership}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listMembershipsAsync()` - * method described below for async iteration which you can stop as 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 Memberships in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent (project and location) where the Memberships will be + * listed. Specified in the format `projects/* /locations/*`. + * `projects/* /locations/-` list memberships in all the regions. + * @param {number} [request.pageSize] + * Optional. When requesting a 'page' of resources, `page_size` specifies + * number of resources to return. If unspecified or set to 0, all resources + * will be returned. + * @param {string} [request.pageToken] + * Optional. Token returned by previous call to `ListMemberships` which + * specifies the position in the list from where to continue listing the + * resources. + * @param {string} [request.filter] + * Optional. Lists Memberships that match the filter expression, following the + * syntax outlined in https://google.aip.dev/160. + * + * Examples: + * + * - Name is `bar` in project `foo-proj` and location `global`: + * + * name = "projects/foo-proj/locations/global/membership/bar" + * + * - Memberships that have a label called `foo`: + * + * labels.foo:* + * + * - Memberships that have a label called `foo` whose value is `bar`: + * + * labels.foo = bar + * + * - Memberships in the CREATING state: + * + * state = CREATING + * @param {string} [request.orderBy] + * Optional. One or more fields to compare and use to sort the output. + * See https://google.aip.dev/132#ordering. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.gkehub.v1.Membership|Membership}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listMembershipsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listMemberships( - request?: protos.google.cloud.gkehub.v1.IListMembershipsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gkehub.v1.IMembership[], - protos.google.cloud.gkehub.v1.IListMembershipsRequest|null, - protos.google.cloud.gkehub.v1.IListMembershipsResponse - ]>; + request?: protos.google.cloud.gkehub.v1.IListMembershipsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gkehub.v1.IMembership[], + protos.google.cloud.gkehub.v1.IListMembershipsRequest | null, + protos.google.cloud.gkehub.v1.IListMembershipsResponse, + ] + >; listMemberships( - request: protos.google.cloud.gkehub.v1.IListMembershipsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.gkehub.v1.IListMembershipsRequest, - protos.google.cloud.gkehub.v1.IListMembershipsResponse|null|undefined, - protos.google.cloud.gkehub.v1.IMembership>): void; + request: protos.google.cloud.gkehub.v1.IListMembershipsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.gkehub.v1.IListMembershipsRequest, + protos.google.cloud.gkehub.v1.IListMembershipsResponse | null | undefined, + protos.google.cloud.gkehub.v1.IMembership + >, + ): void; listMemberships( - request: protos.google.cloud.gkehub.v1.IListMembershipsRequest, - callback: PaginationCallback< - protos.google.cloud.gkehub.v1.IListMembershipsRequest, - protos.google.cloud.gkehub.v1.IListMembershipsResponse|null|undefined, - protos.google.cloud.gkehub.v1.IMembership>): void; + request: protos.google.cloud.gkehub.v1.IListMembershipsRequest, + callback: PaginationCallback< + protos.google.cloud.gkehub.v1.IListMembershipsRequest, + protos.google.cloud.gkehub.v1.IListMembershipsResponse | null | undefined, + protos.google.cloud.gkehub.v1.IMembership + >, + ): void; listMemberships( - request?: protos.google.cloud.gkehub.v1.IListMembershipsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.gkehub.v1.IListMembershipsRequest, - protos.google.cloud.gkehub.v1.IListMembershipsResponse|null|undefined, - protos.google.cloud.gkehub.v1.IMembership>, - callback?: PaginationCallback< + request?: protos.google.cloud.gkehub.v1.IListMembershipsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.gkehub.v1.IListMembershipsRequest, - protos.google.cloud.gkehub.v1.IListMembershipsResponse|null|undefined, - protos.google.cloud.gkehub.v1.IMembership>): - Promise<[ - protos.google.cloud.gkehub.v1.IMembership[], - protos.google.cloud.gkehub.v1.IListMembershipsRequest|null, - protos.google.cloud.gkehub.v1.IListMembershipsResponse - ]>|void { + | protos.google.cloud.gkehub.v1.IListMembershipsResponse + | null + | undefined, + protos.google.cloud.gkehub.v1.IMembership + >, + callback?: PaginationCallback< + protos.google.cloud.gkehub.v1.IListMembershipsRequest, + protos.google.cloud.gkehub.v1.IListMembershipsResponse | null | undefined, + protos.google.cloud.gkehub.v1.IMembership + >, + ): Promise< + [ + protos.google.cloud.gkehub.v1.IMembership[], + protos.google.cloud.gkehub.v1.IListMembershipsRequest | null, + protos.google.cloud.gkehub.v1.IListMembershipsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-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.gkehub.v1.IListMembershipsRequest, - protos.google.cloud.gkehub.v1.IListMembershipsResponse|null|undefined, - protos.google.cloud.gkehub.v1.IMembership>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.gkehub.v1.IListMembershipsRequest, + | protos.google.cloud.gkehub.v1.IListMembershipsResponse + | null + | undefined, + protos.google.cloud.gkehub.v1.IMembership + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listMemberships values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -4521,261 +6733,290 @@ export class GkeHubClient { this._log.info('listMemberships request %j', request); return this.innerApiCalls .listMemberships(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.gkehub.v1.IMembership[], - protos.google.cloud.gkehub.v1.IListMembershipsRequest|null, - protos.google.cloud.gkehub.v1.IListMembershipsResponse - ]) => { - this._log.info('listMemberships values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.gkehub.v1.IMembership[], + protos.google.cloud.gkehub.v1.IListMembershipsRequest | null, + protos.google.cloud.gkehub.v1.IListMembershipsResponse, + ]) => { + this._log.info('listMemberships values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listMemberships`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent (project and location) where the Memberships will be - * listed. Specified in the format `projects/* /locations/*`. - * `projects/* /locations/-` list memberships in all the regions. - * @param {number} [request.pageSize] - * Optional. When requesting a 'page' of resources, `page_size` specifies - * number of resources to return. If unspecified or set to 0, all resources - * will be returned. - * @param {string} [request.pageToken] - * Optional. Token returned by previous call to `ListMemberships` which - * specifies the position in the list from where to continue listing the - * resources. - * @param {string} [request.filter] - * Optional. Lists Memberships that match the filter expression, following the - * syntax outlined in https://google.aip.dev/160. - * - * Examples: - * - * - Name is `bar` in project `foo-proj` and location `global`: - * - * name = "projects/foo-proj/locations/global/membership/bar" - * - * - Memberships that have a label called `foo`: - * - * labels.foo:* - * - * - Memberships that have a label called `foo` whose value is `bar`: - * - * labels.foo = bar - * - * - Memberships in the CREATING state: - * - * state = CREATING - * @param {string} [request.orderBy] - * Optional. One or more fields to compare and use to sort the output. - * See https://google.aip.dev/132#ordering. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.gkehub.v1.Membership|Membership} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listMembershipsAsync()` - * method described below for async iteration which you can stop as 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 `listMemberships`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent (project and location) where the Memberships will be + * listed. Specified in the format `projects/* /locations/*`. + * `projects/* /locations/-` list memberships in all the regions. + * @param {number} [request.pageSize] + * Optional. When requesting a 'page' of resources, `page_size` specifies + * number of resources to return. If unspecified or set to 0, all resources + * will be returned. + * @param {string} [request.pageToken] + * Optional. Token returned by previous call to `ListMemberships` which + * specifies the position in the list from where to continue listing the + * resources. + * @param {string} [request.filter] + * Optional. Lists Memberships that match the filter expression, following the + * syntax outlined in https://google.aip.dev/160. + * + * Examples: + * + * - Name is `bar` in project `foo-proj` and location `global`: + * + * name = "projects/foo-proj/locations/global/membership/bar" + * + * - Memberships that have a label called `foo`: + * + * labels.foo:* + * + * - Memberships that have a label called `foo` whose value is `bar`: + * + * labels.foo = bar + * + * - Memberships in the CREATING state: + * + * state = CREATING + * @param {string} [request.orderBy] + * Optional. One or more fields to compare and use to sort the output. + * See https://google.aip.dev/132#ordering. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.gkehub.v1.Membership|Membership} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listMembershipsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listMembershipsStream( - request?: protos.google.cloud.gkehub.v1.IListMembershipsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.gkehub.v1.IListMembershipsRequest, + 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['listMemberships']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listMemberships stream %j', request); return this.descriptors.page.listMemberships.createStream( this.innerApiCalls.listMemberships as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listMemberships`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used 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 (project and location) where the Memberships will be - * listed. Specified in the format `projects/* /locations/*`. - * `projects/* /locations/-` list memberships in all the regions. - * @param {number} [request.pageSize] - * Optional. When requesting a 'page' of resources, `page_size` specifies - * number of resources to return. If unspecified or set to 0, all resources - * will be returned. - * @param {string} [request.pageToken] - * Optional. Token returned by previous call to `ListMemberships` which - * specifies the position in the list from where to continue listing the - * resources. - * @param {string} [request.filter] - * Optional. Lists Memberships that match the filter expression, following the - * syntax outlined in https://google.aip.dev/160. - * - * Examples: - * - * - Name is `bar` in project `foo-proj` and location `global`: - * - * name = "projects/foo-proj/locations/global/membership/bar" - * - * - Memberships that have a label called `foo`: - * - * labels.foo:* - * - * - Memberships that have a label called `foo` whose value is `bar`: - * - * labels.foo = bar - * - * - Memberships in the CREATING state: - * - * state = CREATING - * @param {string} [request.orderBy] - * Optional. One or more fields to compare and use to sort the output. - * See https://google.aip.dev/132#ordering. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.gkehub.v1.Membership|Membership}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@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/gke_hub.list_memberships.js - * region_tag:gkehub_v1_generated_GkeHub_ListMemberships_async - */ + /** + * Equivalent to `listMemberships`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used 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 (project and location) where the Memberships will be + * listed. Specified in the format `projects/* /locations/*`. + * `projects/* /locations/-` list memberships in all the regions. + * @param {number} [request.pageSize] + * Optional. When requesting a 'page' of resources, `page_size` specifies + * number of resources to return. If unspecified or set to 0, all resources + * will be returned. + * @param {string} [request.pageToken] + * Optional. Token returned by previous call to `ListMemberships` which + * specifies the position in the list from where to continue listing the + * resources. + * @param {string} [request.filter] + * Optional. Lists Memberships that match the filter expression, following the + * syntax outlined in https://google.aip.dev/160. + * + * Examples: + * + * - Name is `bar` in project `foo-proj` and location `global`: + * + * name = "projects/foo-proj/locations/global/membership/bar" + * + * - Memberships that have a label called `foo`: + * + * labels.foo:* + * + * - Memberships that have a label called `foo` whose value is `bar`: + * + * labels.foo = bar + * + * - Memberships in the CREATING state: + * + * state = CREATING + * @param {string} [request.orderBy] + * Optional. One or more fields to compare and use to sort the output. + * See https://google.aip.dev/132#ordering. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.gkehub.v1.Membership|Membership}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@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/gke_hub.list_memberships.js + * region_tag:gkehub_v1_generated_GkeHub_ListMemberships_async + */ listMembershipsAsync( - request?: protos.google.cloud.gkehub.v1.IListMembershipsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.gkehub.v1.IListMembershipsRequest, + 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['listMemberships']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listMemberships iterate %j', request); return this.descriptors.page.listMemberships.asyncIterate( this.innerApiCalls['listMemberships'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists Memberships bound to a Scope. The response includes relevant - * Memberships from all regions. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.scopeName - * Required. Name of the Scope, in the format - * `projects/* /locations/global/scopes/*`, to which the Memberships are bound. - * @param {string} [request.filter] - * Optional. Lists Memberships that match the filter expression, following the - * syntax outlined in https://google.aip.dev/160. Currently, filtering - * can be done only based on Memberships's `name`, `labels`, `create_time`, - * `update_time`, and `unique_id`. - * @param {number} [request.pageSize] - * Optional. When requesting a 'page' of resources, `page_size` specifies - * number of resources to return. If unspecified or set to 0, all resources - * will be returned. Pagination is currently not supported; therefore, setting - * this field does not have any impact for now. - * @param {string} [request.pageToken] - * Optional. Token returned by previous call to `ListBoundMemberships` which - * specifies the position in the list from where to continue listing the - * resources. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link protos.google.cloud.gkehub.v1.Membership|Membership}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listBoundMembershipsAsync()` - * method described below for async iteration which you can stop as 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 Memberships bound to a Scope. The response includes relevant + * Memberships from all regions. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.scopeName + * Required. Name of the Scope, in the format + * `projects/* /locations/global/scopes/*`, to which the Memberships are bound. + * @param {string} [request.filter] + * Optional. Lists Memberships that match the filter expression, following the + * syntax outlined in https://google.aip.dev/160. Currently, filtering + * can be done only based on Memberships's `name`, `labels`, `create_time`, + * `update_time`, and `unique_id`. + * @param {number} [request.pageSize] + * Optional. When requesting a 'page' of resources, `page_size` specifies + * number of resources to return. If unspecified or set to 0, all resources + * will be returned. Pagination is currently not supported; therefore, setting + * this field does not have any impact for now. + * @param {string} [request.pageToken] + * Optional. Token returned by previous call to `ListBoundMemberships` which + * specifies the position in the list from where to continue listing the + * resources. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.gkehub.v1.Membership|Membership}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listBoundMembershipsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listBoundMemberships( - request?: protos.google.cloud.gkehub.v1.IListBoundMembershipsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gkehub.v1.IMembership[], - protos.google.cloud.gkehub.v1.IListBoundMembershipsRequest|null, - protos.google.cloud.gkehub.v1.IListBoundMembershipsResponse - ]>; + request?: protos.google.cloud.gkehub.v1.IListBoundMembershipsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gkehub.v1.IMembership[], + protos.google.cloud.gkehub.v1.IListBoundMembershipsRequest | null, + protos.google.cloud.gkehub.v1.IListBoundMembershipsResponse, + ] + >; listBoundMemberships( - request: protos.google.cloud.gkehub.v1.IListBoundMembershipsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.gkehub.v1.IListBoundMembershipsRequest, - protos.google.cloud.gkehub.v1.IListBoundMembershipsResponse|null|undefined, - protos.google.cloud.gkehub.v1.IMembership>): void; + request: protos.google.cloud.gkehub.v1.IListBoundMembershipsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.gkehub.v1.IListBoundMembershipsRequest, + | protos.google.cloud.gkehub.v1.IListBoundMembershipsResponse + | null + | undefined, + protos.google.cloud.gkehub.v1.IMembership + >, + ): void; listBoundMemberships( - request: protos.google.cloud.gkehub.v1.IListBoundMembershipsRequest, - callback: PaginationCallback< - protos.google.cloud.gkehub.v1.IListBoundMembershipsRequest, - protos.google.cloud.gkehub.v1.IListBoundMembershipsResponse|null|undefined, - protos.google.cloud.gkehub.v1.IMembership>): void; + request: protos.google.cloud.gkehub.v1.IListBoundMembershipsRequest, + callback: PaginationCallback< + protos.google.cloud.gkehub.v1.IListBoundMembershipsRequest, + | protos.google.cloud.gkehub.v1.IListBoundMembershipsResponse + | null + | undefined, + protos.google.cloud.gkehub.v1.IMembership + >, + ): void; listBoundMemberships( - request?: protos.google.cloud.gkehub.v1.IListBoundMembershipsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.gkehub.v1.IListBoundMembershipsRequest, - protos.google.cloud.gkehub.v1.IListBoundMembershipsResponse|null|undefined, - protos.google.cloud.gkehub.v1.IMembership>, - callback?: PaginationCallback< + request?: protos.google.cloud.gkehub.v1.IListBoundMembershipsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.gkehub.v1.IListBoundMembershipsRequest, - protos.google.cloud.gkehub.v1.IListBoundMembershipsResponse|null|undefined, - protos.google.cloud.gkehub.v1.IMembership>): - Promise<[ - protos.google.cloud.gkehub.v1.IMembership[], - protos.google.cloud.gkehub.v1.IListBoundMembershipsRequest|null, - protos.google.cloud.gkehub.v1.IListBoundMembershipsResponse - ]>|void { + | protos.google.cloud.gkehub.v1.IListBoundMembershipsResponse + | null + | undefined, + protos.google.cloud.gkehub.v1.IMembership + >, + callback?: PaginationCallback< + protos.google.cloud.gkehub.v1.IListBoundMembershipsRequest, + | protos.google.cloud.gkehub.v1.IListBoundMembershipsResponse + | null + | undefined, + protos.google.cloud.gkehub.v1.IMembership + >, + ): Promise< + [ + protos.google.cloud.gkehub.v1.IMembership[], + protos.google.cloud.gkehub.v1.IListBoundMembershipsRequest | null, + protos.google.cloud.gkehub.v1.IListBoundMembershipsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'scope_name': request.scopeName ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + scope_name: request.scopeName ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.gkehub.v1.IListBoundMembershipsRequest, - protos.google.cloud.gkehub.v1.IListBoundMembershipsResponse|null|undefined, - protos.google.cloud.gkehub.v1.IMembership>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.gkehub.v1.IListBoundMembershipsRequest, + | protos.google.cloud.gkehub.v1.IListBoundMembershipsResponse + | null + | undefined, + protos.google.cloud.gkehub.v1.IMembership + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listBoundMemberships values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -4784,241 +7025,264 @@ export class GkeHubClient { this._log.info('listBoundMemberships request %j', request); return this.innerApiCalls .listBoundMemberships(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.gkehub.v1.IMembership[], - protos.google.cloud.gkehub.v1.IListBoundMembershipsRequest|null, - protos.google.cloud.gkehub.v1.IListBoundMembershipsResponse - ]) => { - this._log.info('listBoundMemberships values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.gkehub.v1.IMembership[], + protos.google.cloud.gkehub.v1.IListBoundMembershipsRequest | null, + protos.google.cloud.gkehub.v1.IListBoundMembershipsResponse, + ]) => { + this._log.info('listBoundMemberships values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listBoundMemberships`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.scopeName - * Required. Name of the Scope, in the format - * `projects/* /locations/global/scopes/*`, to which the Memberships are bound. - * @param {string} [request.filter] - * Optional. Lists Memberships that match the filter expression, following the - * syntax outlined in https://google.aip.dev/160. Currently, filtering - * can be done only based on Memberships's `name`, `labels`, `create_time`, - * `update_time`, and `unique_id`. - * @param {number} [request.pageSize] - * Optional. When requesting a 'page' of resources, `page_size` specifies - * number of resources to return. If unspecified or set to 0, all resources - * will be returned. Pagination is currently not supported; therefore, setting - * this field does not have any impact for now. - * @param {string} [request.pageToken] - * Optional. Token returned by previous call to `ListBoundMemberships` which - * specifies the position in the list from where to continue listing the - * resources. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.gkehub.v1.Membership|Membership} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listBoundMembershipsAsync()` - * method described below for async iteration which you can stop as 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 `listBoundMemberships`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.scopeName + * Required. Name of the Scope, in the format + * `projects/* /locations/global/scopes/*`, to which the Memberships are bound. + * @param {string} [request.filter] + * Optional. Lists Memberships that match the filter expression, following the + * syntax outlined in https://google.aip.dev/160. Currently, filtering + * can be done only based on Memberships's `name`, `labels`, `create_time`, + * `update_time`, and `unique_id`. + * @param {number} [request.pageSize] + * Optional. When requesting a 'page' of resources, `page_size` specifies + * number of resources to return. If unspecified or set to 0, all resources + * will be returned. Pagination is currently not supported; therefore, setting + * this field does not have any impact for now. + * @param {string} [request.pageToken] + * Optional. Token returned by previous call to `ListBoundMemberships` which + * specifies the position in the list from where to continue listing the + * resources. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.gkehub.v1.Membership|Membership} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listBoundMembershipsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listBoundMembershipsStream( - request?: protos.google.cloud.gkehub.v1.IListBoundMembershipsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.gkehub.v1.IListBoundMembershipsRequest, + 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({ - 'scope_name': request.scopeName ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + scope_name: request.scopeName ?? '', + }); const defaultCallSettings = this._defaults['listBoundMemberships']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listBoundMemberships stream %j', request); return this.descriptors.page.listBoundMemberships.createStream( this.innerApiCalls.listBoundMemberships as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listBoundMemberships`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.scopeName - * Required. Name of the Scope, in the format - * `projects/* /locations/global/scopes/*`, to which the Memberships are bound. - * @param {string} [request.filter] - * Optional. Lists Memberships that match the filter expression, following the - * syntax outlined in https://google.aip.dev/160. Currently, filtering - * can be done only based on Memberships's `name`, `labels`, `create_time`, - * `update_time`, and `unique_id`. - * @param {number} [request.pageSize] - * Optional. When requesting a 'page' of resources, `page_size` specifies - * number of resources to return. If unspecified or set to 0, all resources - * will be returned. Pagination is currently not supported; therefore, setting - * this field does not have any impact for now. - * @param {string} [request.pageToken] - * Optional. Token returned by previous call to `ListBoundMemberships` which - * specifies the position in the list from where to continue listing the - * resources. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.gkehub.v1.Membership|Membership}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@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/gke_hub.list_bound_memberships.js - * region_tag:gkehub_v1_generated_GkeHub_ListBoundMemberships_async - */ + /** + * Equivalent to `listBoundMemberships`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.scopeName + * Required. Name of the Scope, in the format + * `projects/* /locations/global/scopes/*`, to which the Memberships are bound. + * @param {string} [request.filter] + * Optional. Lists Memberships that match the filter expression, following the + * syntax outlined in https://google.aip.dev/160. Currently, filtering + * can be done only based on Memberships's `name`, `labels`, `create_time`, + * `update_time`, and `unique_id`. + * @param {number} [request.pageSize] + * Optional. When requesting a 'page' of resources, `page_size` specifies + * number of resources to return. If unspecified or set to 0, all resources + * will be returned. Pagination is currently not supported; therefore, setting + * this field does not have any impact for now. + * @param {string} [request.pageToken] + * Optional. Token returned by previous call to `ListBoundMemberships` which + * specifies the position in the list from where to continue listing the + * resources. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.gkehub.v1.Membership|Membership}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@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/gke_hub.list_bound_memberships.js + * region_tag:gkehub_v1_generated_GkeHub_ListBoundMemberships_async + */ listBoundMembershipsAsync( - request?: protos.google.cloud.gkehub.v1.IListBoundMembershipsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.gkehub.v1.IListBoundMembershipsRequest, + 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({ - 'scope_name': request.scopeName ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + scope_name: request.scopeName ?? '', + }); const defaultCallSettings = this._defaults['listBoundMemberships']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listBoundMemberships iterate %j', request); return this.descriptors.page.listBoundMemberships.asyncIterate( this.innerApiCalls['listBoundMemberships'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists Features in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent (project and location) where the Features will be - * listed. Specified in the format `projects/* /locations/*`. - * @param {number} request.pageSize - * When requesting a 'page' of resources, `page_size` specifies number of - * resources to return. If unspecified or set to 0, all resources will - * be returned. - * @param {string} request.pageToken - * Token returned by previous call to `ListFeatures` which - * specifies the position in the list from where to continue listing the - * resources. - * @param {string} request.filter - * Lists Features that match the filter expression, following the syntax - * outlined in https://google.aip.dev/160. - * - * Examples: - * - * - Feature with the name "servicemesh" in project "foo-proj": - * - * name = "projects/foo-proj/locations/global/features/servicemesh" - * - * - Features that have a label called `foo`: - * - * labels.foo:* - * - * - Features that have a label called `foo` whose value is `bar`: - * - * labels.foo = bar - * @param {string} request.orderBy - * One or more fields to compare and use to sort the output. - * See https://google.aip.dev/132#ordering. - * @param {boolean} [request.returnPartialSuccess] - * Optional. If set to true, the response will return partial results when - * some regions are unreachable and the unreachable field in Feature proto - * will be populated. If set to false, the request will fail when some regions - * are unreachable. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link protos.google.cloud.gkehub.v1.Feature|Feature}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listFeaturesAsync()` - * method described below for async iteration which you can stop as 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 Features in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent (project and location) where the Features will be + * listed. Specified in the format `projects/* /locations/*`. + * @param {number} request.pageSize + * When requesting a 'page' of resources, `page_size` specifies number of + * resources to return. If unspecified or set to 0, all resources will + * be returned. + * @param {string} request.pageToken + * Token returned by previous call to `ListFeatures` which + * specifies the position in the list from where to continue listing the + * resources. + * @param {string} request.filter + * Lists Features that match the filter expression, following the syntax + * outlined in https://google.aip.dev/160. + * + * Examples: + * + * - Feature with the name "servicemesh" in project "foo-proj": + * + * name = "projects/foo-proj/locations/global/features/servicemesh" + * + * - Features that have a label called `foo`: + * + * labels.foo:* + * + * - Features that have a label called `foo` whose value is `bar`: + * + * labels.foo = bar + * @param {string} request.orderBy + * One or more fields to compare and use to sort the output. + * See https://google.aip.dev/132#ordering. + * @param {boolean} [request.returnPartialSuccess] + * Optional. If set to true, the response will return partial results when + * some regions are unreachable and the unreachable field in Feature proto + * will be populated. If set to false, the request will fail when some regions + * are unreachable. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.gkehub.v1.Feature|Feature}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listFeaturesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listFeatures( - request?: protos.google.cloud.gkehub.v1.IListFeaturesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gkehub.v1.IFeature[], - protos.google.cloud.gkehub.v1.IListFeaturesRequest|null, - protos.google.cloud.gkehub.v1.IListFeaturesResponse - ]>; + request?: protos.google.cloud.gkehub.v1.IListFeaturesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gkehub.v1.IFeature[], + protos.google.cloud.gkehub.v1.IListFeaturesRequest | null, + protos.google.cloud.gkehub.v1.IListFeaturesResponse, + ] + >; listFeatures( - request: protos.google.cloud.gkehub.v1.IListFeaturesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.gkehub.v1.IListFeaturesRequest, - protos.google.cloud.gkehub.v1.IListFeaturesResponse|null|undefined, - protos.google.cloud.gkehub.v1.IFeature>): void; + request: protos.google.cloud.gkehub.v1.IListFeaturesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.gkehub.v1.IListFeaturesRequest, + protos.google.cloud.gkehub.v1.IListFeaturesResponse | null | undefined, + protos.google.cloud.gkehub.v1.IFeature + >, + ): void; listFeatures( - request: protos.google.cloud.gkehub.v1.IListFeaturesRequest, - callback: PaginationCallback< - protos.google.cloud.gkehub.v1.IListFeaturesRequest, - protos.google.cloud.gkehub.v1.IListFeaturesResponse|null|undefined, - protos.google.cloud.gkehub.v1.IFeature>): void; + request: protos.google.cloud.gkehub.v1.IListFeaturesRequest, + callback: PaginationCallback< + protos.google.cloud.gkehub.v1.IListFeaturesRequest, + protos.google.cloud.gkehub.v1.IListFeaturesResponse | null | undefined, + protos.google.cloud.gkehub.v1.IFeature + >, + ): void; listFeatures( - request?: protos.google.cloud.gkehub.v1.IListFeaturesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.gkehub.v1.IListFeaturesRequest, - protos.google.cloud.gkehub.v1.IListFeaturesResponse|null|undefined, - protos.google.cloud.gkehub.v1.IFeature>, - callback?: PaginationCallback< + request?: protos.google.cloud.gkehub.v1.IListFeaturesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.gkehub.v1.IListFeaturesRequest, - protos.google.cloud.gkehub.v1.IListFeaturesResponse|null|undefined, - protos.google.cloud.gkehub.v1.IFeature>): - Promise<[ - protos.google.cloud.gkehub.v1.IFeature[], - protos.google.cloud.gkehub.v1.IListFeaturesRequest|null, - protos.google.cloud.gkehub.v1.IListFeaturesResponse - ]>|void { + | protos.google.cloud.gkehub.v1.IListFeaturesResponse + | null + | undefined, + protos.google.cloud.gkehub.v1.IFeature + >, + callback?: PaginationCallback< + protos.google.cloud.gkehub.v1.IListFeaturesRequest, + protos.google.cloud.gkehub.v1.IListFeaturesResponse | null | undefined, + protos.google.cloud.gkehub.v1.IFeature + >, + ): Promise< + [ + protos.google.cloud.gkehub.v1.IFeature[], + protos.google.cloud.gkehub.v1.IListFeaturesRequest | null, + protos.google.cloud.gkehub.v1.IListFeaturesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-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.gkehub.v1.IListFeaturesRequest, - protos.google.cloud.gkehub.v1.IListFeaturesResponse|null|undefined, - protos.google.cloud.gkehub.v1.IFeature>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.gkehub.v1.IListFeaturesRequest, + | protos.google.cloud.gkehub.v1.IListFeaturesResponse + | null + | undefined, + protos.google.cloud.gkehub.v1.IFeature + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listFeatures values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -5027,257 +7291,276 @@ export class GkeHubClient { this._log.info('listFeatures request %j', request); return this.innerApiCalls .listFeatures(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.gkehub.v1.IFeature[], - protos.google.cloud.gkehub.v1.IListFeaturesRequest|null, - protos.google.cloud.gkehub.v1.IListFeaturesResponse - ]) => { - this._log.info('listFeatures values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.gkehub.v1.IFeature[], + protos.google.cloud.gkehub.v1.IListFeaturesRequest | null, + protos.google.cloud.gkehub.v1.IListFeaturesResponse, + ]) => { + this._log.info('listFeatures values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listFeatures`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent (project and location) where the Features will be - * listed. Specified in the format `projects/* /locations/*`. - * @param {number} request.pageSize - * When requesting a 'page' of resources, `page_size` specifies number of - * resources to return. If unspecified or set to 0, all resources will - * be returned. - * @param {string} request.pageToken - * Token returned by previous call to `ListFeatures` which - * specifies the position in the list from where to continue listing the - * resources. - * @param {string} request.filter - * Lists Features that match the filter expression, following the syntax - * outlined in https://google.aip.dev/160. - * - * Examples: - * - * - Feature with the name "servicemesh" in project "foo-proj": - * - * name = "projects/foo-proj/locations/global/features/servicemesh" - * - * - Features that have a label called `foo`: - * - * labels.foo:* - * - * - Features that have a label called `foo` whose value is `bar`: - * - * labels.foo = bar - * @param {string} request.orderBy - * One or more fields to compare and use to sort the output. - * See https://google.aip.dev/132#ordering. - * @param {boolean} [request.returnPartialSuccess] - * Optional. If set to true, the response will return partial results when - * some regions are unreachable and the unreachable field in Feature proto - * will be populated. If set to false, the request will fail when some regions - * are unreachable. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.gkehub.v1.Feature|Feature} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listFeaturesAsync()` - * method described below for async iteration which you can stop as 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 `listFeatures`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent (project and location) where the Features will be + * listed. Specified in the format `projects/* /locations/*`. + * @param {number} request.pageSize + * When requesting a 'page' of resources, `page_size` specifies number of + * resources to return. If unspecified or set to 0, all resources will + * be returned. + * @param {string} request.pageToken + * Token returned by previous call to `ListFeatures` which + * specifies the position in the list from where to continue listing the + * resources. + * @param {string} request.filter + * Lists Features that match the filter expression, following the syntax + * outlined in https://google.aip.dev/160. + * + * Examples: + * + * - Feature with the name "servicemesh" in project "foo-proj": + * + * name = "projects/foo-proj/locations/global/features/servicemesh" + * + * - Features that have a label called `foo`: + * + * labels.foo:* + * + * - Features that have a label called `foo` whose value is `bar`: + * + * labels.foo = bar + * @param {string} request.orderBy + * One or more fields to compare and use to sort the output. + * See https://google.aip.dev/132#ordering. + * @param {boolean} [request.returnPartialSuccess] + * Optional. If set to true, the response will return partial results when + * some regions are unreachable and the unreachable field in Feature proto + * will be populated. If set to false, the request will fail when some regions + * are unreachable. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.gkehub.v1.Feature|Feature} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listFeaturesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listFeaturesStream( - request?: protos.google.cloud.gkehub.v1.IListFeaturesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.gkehub.v1.IListFeaturesRequest, + 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['listFeatures']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listFeatures stream %j', request); return this.descriptors.page.listFeatures.createStream( this.innerApiCalls.listFeatures as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listFeatures`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used 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 (project and location) where the Features will be - * listed. Specified in the format `projects/* /locations/*`. - * @param {number} request.pageSize - * When requesting a 'page' of resources, `page_size` specifies number of - * resources to return. If unspecified or set to 0, all resources will - * be returned. - * @param {string} request.pageToken - * Token returned by previous call to `ListFeatures` which - * specifies the position in the list from where to continue listing the - * resources. - * @param {string} request.filter - * Lists Features that match the filter expression, following the syntax - * outlined in https://google.aip.dev/160. - * - * Examples: - * - * - Feature with the name "servicemesh" in project "foo-proj": - * - * name = "projects/foo-proj/locations/global/features/servicemesh" - * - * - Features that have a label called `foo`: - * - * labels.foo:* - * - * - Features that have a label called `foo` whose value is `bar`: - * - * labels.foo = bar - * @param {string} request.orderBy - * One or more fields to compare and use to sort the output. - * See https://google.aip.dev/132#ordering. - * @param {boolean} [request.returnPartialSuccess] - * Optional. If set to true, the response will return partial results when - * some regions are unreachable and the unreachable field in Feature proto - * will be populated. If set to false, the request will fail when some regions - * are unreachable. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.gkehub.v1.Feature|Feature}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@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/gke_hub.list_features.js - * region_tag:gkehub_v1_generated_GkeHub_ListFeatures_async - */ + /** + * Equivalent to `listFeatures`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used 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 (project and location) where the Features will be + * listed. Specified in the format `projects/* /locations/*`. + * @param {number} request.pageSize + * When requesting a 'page' of resources, `page_size` specifies number of + * resources to return. If unspecified or set to 0, all resources will + * be returned. + * @param {string} request.pageToken + * Token returned by previous call to `ListFeatures` which + * specifies the position in the list from where to continue listing the + * resources. + * @param {string} request.filter + * Lists Features that match the filter expression, following the syntax + * outlined in https://google.aip.dev/160. + * + * Examples: + * + * - Feature with the name "servicemesh" in project "foo-proj": + * + * name = "projects/foo-proj/locations/global/features/servicemesh" + * + * - Features that have a label called `foo`: + * + * labels.foo:* + * + * - Features that have a label called `foo` whose value is `bar`: + * + * labels.foo = bar + * @param {string} request.orderBy + * One or more fields to compare and use to sort the output. + * See https://google.aip.dev/132#ordering. + * @param {boolean} [request.returnPartialSuccess] + * Optional. If set to true, the response will return partial results when + * some regions are unreachable and the unreachable field in Feature proto + * will be populated. If set to false, the request will fail when some regions + * are unreachable. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.gkehub.v1.Feature|Feature}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@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/gke_hub.list_features.js + * region_tag:gkehub_v1_generated_GkeHub_ListFeatures_async + */ listFeaturesAsync( - request?: protos.google.cloud.gkehub.v1.IListFeaturesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.gkehub.v1.IListFeaturesRequest, + 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['listFeatures']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listFeatures iterate %j', request); return this.descriptors.page.listFeatures.asyncIterate( this.innerApiCalls['listFeatures'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Returns all fleets within an organization or a project that the caller has - * access to. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The organization or project to list for Fleets under, in the - * format `organizations/* /locations/*` or `projects/* /locations/*`. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListFleets` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListFleets` must match - * the call that provided the page token. - * @param {number} [request.pageSize] - * Optional. The maximum number of fleets to return. The service may return - * fewer than this value. If unspecified, at most 200 fleets will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link protos.google.cloud.gkehub.v1.Fleet|Fleet}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listFleetsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Returns all fleets within an organization or a project that the caller has + * access to. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The organization or project to list for Fleets under, in the + * format `organizations/* /locations/*` or `projects/* /locations/*`. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListFleets` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListFleets` must match + * the call that provided the page token. + * @param {number} [request.pageSize] + * Optional. The maximum number of fleets to return. The service may return + * fewer than this value. If unspecified, at most 200 fleets will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.gkehub.v1.Fleet|Fleet}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listFleetsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listFleets( - request?: protos.google.cloud.gkehub.v1.IListFleetsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gkehub.v1.IFleet[], - protos.google.cloud.gkehub.v1.IListFleetsRequest|null, - protos.google.cloud.gkehub.v1.IListFleetsResponse - ]>; + request?: protos.google.cloud.gkehub.v1.IListFleetsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gkehub.v1.IFleet[], + protos.google.cloud.gkehub.v1.IListFleetsRequest | null, + protos.google.cloud.gkehub.v1.IListFleetsResponse, + ] + >; listFleets( - request: protos.google.cloud.gkehub.v1.IListFleetsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.gkehub.v1.IListFleetsRequest, - protos.google.cloud.gkehub.v1.IListFleetsResponse|null|undefined, - protos.google.cloud.gkehub.v1.IFleet>): void; + request: protos.google.cloud.gkehub.v1.IListFleetsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.gkehub.v1.IListFleetsRequest, + protos.google.cloud.gkehub.v1.IListFleetsResponse | null | undefined, + protos.google.cloud.gkehub.v1.IFleet + >, + ): void; listFleets( - request: protos.google.cloud.gkehub.v1.IListFleetsRequest, - callback: PaginationCallback< - protos.google.cloud.gkehub.v1.IListFleetsRequest, - protos.google.cloud.gkehub.v1.IListFleetsResponse|null|undefined, - protos.google.cloud.gkehub.v1.IFleet>): void; + request: protos.google.cloud.gkehub.v1.IListFleetsRequest, + callback: PaginationCallback< + protos.google.cloud.gkehub.v1.IListFleetsRequest, + protos.google.cloud.gkehub.v1.IListFleetsResponse | null | undefined, + protos.google.cloud.gkehub.v1.IFleet + >, + ): void; listFleets( - request?: protos.google.cloud.gkehub.v1.IListFleetsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< + request?: protos.google.cloud.gkehub.v1.IListFleetsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.gkehub.v1.IListFleetsRequest, - protos.google.cloud.gkehub.v1.IListFleetsResponse|null|undefined, - protos.google.cloud.gkehub.v1.IFleet>, - callback?: PaginationCallback< - protos.google.cloud.gkehub.v1.IListFleetsRequest, - protos.google.cloud.gkehub.v1.IListFleetsResponse|null|undefined, - protos.google.cloud.gkehub.v1.IFleet>): - Promise<[ - protos.google.cloud.gkehub.v1.IFleet[], - protos.google.cloud.gkehub.v1.IListFleetsRequest|null, - protos.google.cloud.gkehub.v1.IListFleetsResponse - ]>|void { + protos.google.cloud.gkehub.v1.IListFleetsResponse | null | undefined, + protos.google.cloud.gkehub.v1.IFleet + >, + callback?: PaginationCallback< + protos.google.cloud.gkehub.v1.IListFleetsRequest, + protos.google.cloud.gkehub.v1.IListFleetsResponse | null | undefined, + protos.google.cloud.gkehub.v1.IFleet + >, + ): Promise< + [ + protos.google.cloud.gkehub.v1.IFleet[], + protos.google.cloud.gkehub.v1.IListFleetsRequest | null, + protos.google.cloud.gkehub.v1.IListFleetsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-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.gkehub.v1.IListFleetsRequest, - protos.google.cloud.gkehub.v1.IListFleetsResponse|null|undefined, - protos.google.cloud.gkehub.v1.IFleet>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.gkehub.v1.IListFleetsRequest, + protos.google.cloud.gkehub.v1.IListFleetsResponse | null | undefined, + protos.google.cloud.gkehub.v1.IFleet + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listFleets values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -5286,208 +7569,237 @@ export class GkeHubClient { this._log.info('listFleets request %j', request); return this.innerApiCalls .listFleets(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.gkehub.v1.IFleet[], - protos.google.cloud.gkehub.v1.IListFleetsRequest|null, - protos.google.cloud.gkehub.v1.IListFleetsResponse - ]) => { - this._log.info('listFleets values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.gkehub.v1.IFleet[], + protos.google.cloud.gkehub.v1.IListFleetsRequest | null, + protos.google.cloud.gkehub.v1.IListFleetsResponse, + ]) => { + this._log.info('listFleets values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listFleets`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The organization or project to list for Fleets under, in the - * format `organizations/* /locations/*` or `projects/* /locations/*`. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListFleets` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListFleets` must match - * the call that provided the page token. - * @param {number} [request.pageSize] - * Optional. The maximum number of fleets to return. The service may return - * fewer than this value. If unspecified, at most 200 fleets will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.gkehub.v1.Fleet|Fleet} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listFleetsAsync()` - * method described below for async iteration which you can stop as 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 `listFleets`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The organization or project to list for Fleets under, in the + * format `organizations/* /locations/*` or `projects/* /locations/*`. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListFleets` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListFleets` must match + * the call that provided the page token. + * @param {number} [request.pageSize] + * Optional. The maximum number of fleets to return. The service may return + * fewer than this value. If unspecified, at most 200 fleets will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.gkehub.v1.Fleet|Fleet} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listFleetsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listFleetsStream( - request?: protos.google.cloud.gkehub.v1.IListFleetsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.gkehub.v1.IListFleetsRequest, + 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['listFleets']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listFleets stream %j', request); return this.descriptors.page.listFleets.createStream( this.innerApiCalls.listFleets as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listFleets`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used 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 organization or project to list for Fleets under, in the - * format `organizations/* /locations/*` or `projects/* /locations/*`. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListFleets` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListFleets` must match - * the call that provided the page token. - * @param {number} [request.pageSize] - * Optional. The maximum number of fleets to return. The service may return - * fewer than this value. If unspecified, at most 200 fleets will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.gkehub.v1.Fleet|Fleet}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@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/gke_hub.list_fleets.js - * region_tag:gkehub_v1_generated_GkeHub_ListFleets_async - */ + /** + * Equivalent to `listFleets`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used 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 organization or project to list for Fleets under, in the + * format `organizations/* /locations/*` or `projects/* /locations/*`. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListFleets` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListFleets` must match + * the call that provided the page token. + * @param {number} [request.pageSize] + * Optional. The maximum number of fleets to return. The service may return + * fewer than this value. If unspecified, at most 200 fleets will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.gkehub.v1.Fleet|Fleet}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@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/gke_hub.list_fleets.js + * region_tag:gkehub_v1_generated_GkeHub_ListFleets_async + */ listFleetsAsync( - request?: protos.google.cloud.gkehub.v1.IListFleetsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.gkehub.v1.IListFleetsRequest, + 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['listFleets']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listFleets iterate %j', request); return this.descriptors.page.listFleets.asyncIterate( this.innerApiCalls['listFleets'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists fleet namespaces. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent (project and location) where the Features will be - * listed. Specified in the format `projects/* /locations/* /scopes/*`. - * @param {number} [request.pageSize] - * Optional. When requesting a 'page' of resources, `page_size` specifies - * number of resources to return. If unspecified or set to 0, all resources - * will be returned. - * @param {string} [request.pageToken] - * Optional. Token returned by previous call to `ListFeatures` which - * specifies the position in the list from where to continue listing the - * resources. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link protos.google.cloud.gkehub.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 `listScopeNamespacesAsync()` - * method described below for async iteration which you can stop as 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 fleet namespaces. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent (project and location) where the Features will be + * listed. Specified in the format `projects/* /locations/* /scopes/*`. + * @param {number} [request.pageSize] + * Optional. When requesting a 'page' of resources, `page_size` specifies + * number of resources to return. If unspecified or set to 0, all resources + * will be returned. + * @param {string} [request.pageToken] + * Optional. Token returned by previous call to `ListFeatures` which + * specifies the position in the list from where to continue listing the + * resources. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.gkehub.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 `listScopeNamespacesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listScopeNamespaces( - request?: protos.google.cloud.gkehub.v1.IListScopeNamespacesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gkehub.v1.INamespace[], - protos.google.cloud.gkehub.v1.IListScopeNamespacesRequest|null, - protos.google.cloud.gkehub.v1.IListScopeNamespacesResponse - ]>; + request?: protos.google.cloud.gkehub.v1.IListScopeNamespacesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gkehub.v1.INamespace[], + protos.google.cloud.gkehub.v1.IListScopeNamespacesRequest | null, + protos.google.cloud.gkehub.v1.IListScopeNamespacesResponse, + ] + >; listScopeNamespaces( - request: protos.google.cloud.gkehub.v1.IListScopeNamespacesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.gkehub.v1.IListScopeNamespacesRequest, - protos.google.cloud.gkehub.v1.IListScopeNamespacesResponse|null|undefined, - protos.google.cloud.gkehub.v1.INamespace>): void; + request: protos.google.cloud.gkehub.v1.IListScopeNamespacesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.gkehub.v1.IListScopeNamespacesRequest, + | protos.google.cloud.gkehub.v1.IListScopeNamespacesResponse + | null + | undefined, + protos.google.cloud.gkehub.v1.INamespace + >, + ): void; listScopeNamespaces( - request: protos.google.cloud.gkehub.v1.IListScopeNamespacesRequest, - callback: PaginationCallback< - protos.google.cloud.gkehub.v1.IListScopeNamespacesRequest, - protos.google.cloud.gkehub.v1.IListScopeNamespacesResponse|null|undefined, - protos.google.cloud.gkehub.v1.INamespace>): void; + request: protos.google.cloud.gkehub.v1.IListScopeNamespacesRequest, + callback: PaginationCallback< + protos.google.cloud.gkehub.v1.IListScopeNamespacesRequest, + | protos.google.cloud.gkehub.v1.IListScopeNamespacesResponse + | null + | undefined, + protos.google.cloud.gkehub.v1.INamespace + >, + ): void; listScopeNamespaces( - request?: protos.google.cloud.gkehub.v1.IListScopeNamespacesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.gkehub.v1.IListScopeNamespacesRequest, - protos.google.cloud.gkehub.v1.IListScopeNamespacesResponse|null|undefined, - protos.google.cloud.gkehub.v1.INamespace>, - callback?: PaginationCallback< + request?: protos.google.cloud.gkehub.v1.IListScopeNamespacesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.gkehub.v1.IListScopeNamespacesRequest, - protos.google.cloud.gkehub.v1.IListScopeNamespacesResponse|null|undefined, - protos.google.cloud.gkehub.v1.INamespace>): - Promise<[ - protos.google.cloud.gkehub.v1.INamespace[], - protos.google.cloud.gkehub.v1.IListScopeNamespacesRequest|null, - protos.google.cloud.gkehub.v1.IListScopeNamespacesResponse - ]>|void { + | protos.google.cloud.gkehub.v1.IListScopeNamespacesResponse + | null + | undefined, + protos.google.cloud.gkehub.v1.INamespace + >, + callback?: PaginationCallback< + protos.google.cloud.gkehub.v1.IListScopeNamespacesRequest, + | protos.google.cloud.gkehub.v1.IListScopeNamespacesResponse + | null + | undefined, + protos.google.cloud.gkehub.v1.INamespace + >, + ): Promise< + [ + protos.google.cloud.gkehub.v1.INamespace[], + protos.google.cloud.gkehub.v1.IListScopeNamespacesRequest | null, + protos.google.cloud.gkehub.v1.IListScopeNamespacesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-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.gkehub.v1.IListScopeNamespacesRequest, - protos.google.cloud.gkehub.v1.IListScopeNamespacesResponse|null|undefined, - protos.google.cloud.gkehub.v1.INamespace>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.gkehub.v1.IListScopeNamespacesRequest, + | protos.google.cloud.gkehub.v1.IListScopeNamespacesResponse + | null + | undefined, + protos.google.cloud.gkehub.v1.INamespace + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listScopeNamespaces values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -5496,204 +7808,233 @@ export class GkeHubClient { this._log.info('listScopeNamespaces request %j', request); return this.innerApiCalls .listScopeNamespaces(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.gkehub.v1.INamespace[], - protos.google.cloud.gkehub.v1.IListScopeNamespacesRequest|null, - protos.google.cloud.gkehub.v1.IListScopeNamespacesResponse - ]) => { - this._log.info('listScopeNamespaces values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.gkehub.v1.INamespace[], + protos.google.cloud.gkehub.v1.IListScopeNamespacesRequest | null, + protos.google.cloud.gkehub.v1.IListScopeNamespacesResponse, + ]) => { + this._log.info('listScopeNamespaces values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listScopeNamespaces`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent (project and location) where the Features will be - * listed. Specified in the format `projects/* /locations/* /scopes/*`. - * @param {number} [request.pageSize] - * Optional. When requesting a 'page' of resources, `page_size` specifies - * number of resources to return. If unspecified or set to 0, all resources - * will be returned. - * @param {string} [request.pageToken] - * Optional. Token returned by previous call to `ListFeatures` which - * specifies the position in the list from where to continue listing the - * resources. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.gkehub.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 `listScopeNamespacesAsync()` - * method described below for async iteration which you can stop as 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 `listScopeNamespaces`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent (project and location) where the Features will be + * listed. Specified in the format `projects/* /locations/* /scopes/*`. + * @param {number} [request.pageSize] + * Optional. When requesting a 'page' of resources, `page_size` specifies + * number of resources to return. If unspecified or set to 0, all resources + * will be returned. + * @param {string} [request.pageToken] + * Optional. Token returned by previous call to `ListFeatures` which + * specifies the position in the list from where to continue listing the + * resources. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.gkehub.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 `listScopeNamespacesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listScopeNamespacesStream( - request?: protos.google.cloud.gkehub.v1.IListScopeNamespacesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.gkehub.v1.IListScopeNamespacesRequest, + 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['listScopeNamespaces']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listScopeNamespaces stream %j', request); return this.descriptors.page.listScopeNamespaces.createStream( this.innerApiCalls.listScopeNamespaces as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listScopeNamespaces`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used 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 (project and location) where the Features will be - * listed. Specified in the format `projects/* /locations/* /scopes/*`. - * @param {number} [request.pageSize] - * Optional. When requesting a 'page' of resources, `page_size` specifies - * number of resources to return. If unspecified or set to 0, all resources - * will be returned. - * @param {string} [request.pageToken] - * Optional. Token returned by previous call to `ListFeatures` which - * specifies the position in the list from where to continue listing the - * resources. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.gkehub.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/gke_hub.list_scope_namespaces.js - * region_tag:gkehub_v1_generated_GkeHub_ListScopeNamespaces_async - */ + /** + * Equivalent to `listScopeNamespaces`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used 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 (project and location) where the Features will be + * listed. Specified in the format `projects/* /locations/* /scopes/*`. + * @param {number} [request.pageSize] + * Optional. When requesting a 'page' of resources, `page_size` specifies + * number of resources to return. If unspecified or set to 0, all resources + * will be returned. + * @param {string} [request.pageToken] + * Optional. Token returned by previous call to `ListFeatures` which + * specifies the position in the list from where to continue listing the + * resources. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.gkehub.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/gke_hub.list_scope_namespaces.js + * region_tag:gkehub_v1_generated_GkeHub_ListScopeNamespaces_async + */ listScopeNamespacesAsync( - request?: protos.google.cloud.gkehub.v1.IListScopeNamespacesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.gkehub.v1.IListScopeNamespacesRequest, + 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['listScopeNamespaces']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listScopeNamespaces iterate %j', request); return this.descriptors.page.listScopeNamespaces.asyncIterate( this.innerApiCalls['listScopeNamespaces'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists all Scope RBACRoleBindings. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent (project and location) where the Features will be - * listed. Specified in the format `projects/* /locations/* /scopes/*`. - * @param {number} [request.pageSize] - * Optional. When requesting a 'page' of resources, `page_size` specifies - * number of resources to return. If unspecified or set to 0, all resources - * will be returned. - * @param {string} [request.pageToken] - * Optional. Token returned by previous call to `ListScopeRBACRoleBindings` - * which specifies the position in the list from where to continue listing the - * resources. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link protos.google.cloud.gkehub.v1.RBACRoleBinding|RBACRoleBinding}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listScopeRBACRoleBindingsAsync()` - * method described below for async iteration which you can stop as 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 Scope RBACRoleBindings. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent (project and location) where the Features will be + * listed. Specified in the format `projects/* /locations/* /scopes/*`. + * @param {number} [request.pageSize] + * Optional. When requesting a 'page' of resources, `page_size` specifies + * number of resources to return. If unspecified or set to 0, all resources + * will be returned. + * @param {string} [request.pageToken] + * Optional. Token returned by previous call to `ListScopeRBACRoleBindings` + * which specifies the position in the list from where to continue listing the + * resources. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.gkehub.v1.RBACRoleBinding|RBACRoleBinding}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listScopeRBACRoleBindingsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listScopeRBACRoleBindings( - request?: protos.google.cloud.gkehub.v1.IListScopeRBACRoleBindingsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gkehub.v1.IRBACRoleBinding[], - protos.google.cloud.gkehub.v1.IListScopeRBACRoleBindingsRequest|null, - protos.google.cloud.gkehub.v1.IListScopeRBACRoleBindingsResponse - ]>; + request?: protos.google.cloud.gkehub.v1.IListScopeRBACRoleBindingsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gkehub.v1.IRBACRoleBinding[], + protos.google.cloud.gkehub.v1.IListScopeRBACRoleBindingsRequest | null, + protos.google.cloud.gkehub.v1.IListScopeRBACRoleBindingsResponse, + ] + >; listScopeRBACRoleBindings( - request: protos.google.cloud.gkehub.v1.IListScopeRBACRoleBindingsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.gkehub.v1.IListScopeRBACRoleBindingsRequest, - protos.google.cloud.gkehub.v1.IListScopeRBACRoleBindingsResponse|null|undefined, - protos.google.cloud.gkehub.v1.IRBACRoleBinding>): void; + request: protos.google.cloud.gkehub.v1.IListScopeRBACRoleBindingsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.gkehub.v1.IListScopeRBACRoleBindingsRequest, + | protos.google.cloud.gkehub.v1.IListScopeRBACRoleBindingsResponse + | null + | undefined, + protos.google.cloud.gkehub.v1.IRBACRoleBinding + >, + ): void; listScopeRBACRoleBindings( - request: protos.google.cloud.gkehub.v1.IListScopeRBACRoleBindingsRequest, - callback: PaginationCallback< - protos.google.cloud.gkehub.v1.IListScopeRBACRoleBindingsRequest, - protos.google.cloud.gkehub.v1.IListScopeRBACRoleBindingsResponse|null|undefined, - protos.google.cloud.gkehub.v1.IRBACRoleBinding>): void; + request: protos.google.cloud.gkehub.v1.IListScopeRBACRoleBindingsRequest, + callback: PaginationCallback< + protos.google.cloud.gkehub.v1.IListScopeRBACRoleBindingsRequest, + | protos.google.cloud.gkehub.v1.IListScopeRBACRoleBindingsResponse + | null + | undefined, + protos.google.cloud.gkehub.v1.IRBACRoleBinding + >, + ): void; listScopeRBACRoleBindings( - request?: protos.google.cloud.gkehub.v1.IListScopeRBACRoleBindingsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< + request?: protos.google.cloud.gkehub.v1.IListScopeRBACRoleBindingsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.gkehub.v1.IListScopeRBACRoleBindingsRequest, - protos.google.cloud.gkehub.v1.IListScopeRBACRoleBindingsResponse|null|undefined, - protos.google.cloud.gkehub.v1.IRBACRoleBinding>, - callback?: PaginationCallback< - protos.google.cloud.gkehub.v1.IListScopeRBACRoleBindingsRequest, - protos.google.cloud.gkehub.v1.IListScopeRBACRoleBindingsResponse|null|undefined, - protos.google.cloud.gkehub.v1.IRBACRoleBinding>): - Promise<[ - protos.google.cloud.gkehub.v1.IRBACRoleBinding[], - protos.google.cloud.gkehub.v1.IListScopeRBACRoleBindingsRequest|null, - protos.google.cloud.gkehub.v1.IListScopeRBACRoleBindingsResponse - ]>|void { + | protos.google.cloud.gkehub.v1.IListScopeRBACRoleBindingsResponse + | null + | undefined, + protos.google.cloud.gkehub.v1.IRBACRoleBinding + >, + callback?: PaginationCallback< + protos.google.cloud.gkehub.v1.IListScopeRBACRoleBindingsRequest, + | protos.google.cloud.gkehub.v1.IListScopeRBACRoleBindingsResponse + | null + | undefined, + protos.google.cloud.gkehub.v1.IRBACRoleBinding + >, + ): Promise< + [ + protos.google.cloud.gkehub.v1.IRBACRoleBinding[], + protos.google.cloud.gkehub.v1.IListScopeRBACRoleBindingsRequest | null, + protos.google.cloud.gkehub.v1.IListScopeRBACRoleBindingsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-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.gkehub.v1.IListScopeRBACRoleBindingsRequest, - protos.google.cloud.gkehub.v1.IListScopeRBACRoleBindingsResponse|null|undefined, - protos.google.cloud.gkehub.v1.IRBACRoleBinding>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.gkehub.v1.IListScopeRBACRoleBindingsRequest, + | protos.google.cloud.gkehub.v1.IListScopeRBACRoleBindingsResponse + | null + | undefined, + protos.google.cloud.gkehub.v1.IRBACRoleBinding + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listScopeRBACRoleBindings values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -5702,204 +8043,223 @@ export class GkeHubClient { this._log.info('listScopeRBACRoleBindings request %j', request); return this.innerApiCalls .listScopeRbacRoleBindings(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.gkehub.v1.IRBACRoleBinding[], - protos.google.cloud.gkehub.v1.IListScopeRBACRoleBindingsRequest|null, - protos.google.cloud.gkehub.v1.IListScopeRBACRoleBindingsResponse - ]) => { - this._log.info('listScopeRBACRoleBindings values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.gkehub.v1.IRBACRoleBinding[], + protos.google.cloud.gkehub.v1.IListScopeRBACRoleBindingsRequest | null, + protos.google.cloud.gkehub.v1.IListScopeRBACRoleBindingsResponse, + ]) => { + this._log.info('listScopeRBACRoleBindings values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listScopeRBACRoleBindings`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent (project and location) where the Features will be - * listed. Specified in the format `projects/* /locations/* /scopes/*`. - * @param {number} [request.pageSize] - * Optional. When requesting a 'page' of resources, `page_size` specifies - * number of resources to return. If unspecified or set to 0, all resources - * will be returned. - * @param {string} [request.pageToken] - * Optional. Token returned by previous call to `ListScopeRBACRoleBindings` - * which specifies the position in the list from where to continue listing the - * resources. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.gkehub.v1.RBACRoleBinding|RBACRoleBinding} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listScopeRBACRoleBindingsAsync()` - * method described below for async iteration which you can stop as 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 `listScopeRBACRoleBindings`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent (project and location) where the Features will be + * listed. Specified in the format `projects/* /locations/* /scopes/*`. + * @param {number} [request.pageSize] + * Optional. When requesting a 'page' of resources, `page_size` specifies + * number of resources to return. If unspecified or set to 0, all resources + * will be returned. + * @param {string} [request.pageToken] + * Optional. Token returned by previous call to `ListScopeRBACRoleBindings` + * which specifies the position in the list from where to continue listing the + * resources. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.gkehub.v1.RBACRoleBinding|RBACRoleBinding} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listScopeRBACRoleBindingsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listScopeRBACRoleBindingsStream( - request?: protos.google.cloud.gkehub.v1.IListScopeRBACRoleBindingsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.gkehub.v1.IListScopeRBACRoleBindingsRequest, + 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['listScopeRbacRoleBindings']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listScopeRBACRoleBindings stream %j', request); return this.descriptors.page.listScopeRBACRoleBindings.createStream( this.innerApiCalls.listScopeRbacRoleBindings as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listScopeRBACRoleBindings`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used 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 (project and location) where the Features will be - * listed. Specified in the format `projects/* /locations/* /scopes/*`. - * @param {number} [request.pageSize] - * Optional. When requesting a 'page' of resources, `page_size` specifies - * number of resources to return. If unspecified or set to 0, all resources - * will be returned. - * @param {string} [request.pageToken] - * Optional. Token returned by previous call to `ListScopeRBACRoleBindings` - * which specifies the position in the list from where to continue listing the - * resources. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.gkehub.v1.RBACRoleBinding|RBACRoleBinding}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@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/gke_hub.list_scope_r_b_a_c_role_bindings.js - * region_tag:gkehub_v1_generated_GkeHub_ListScopeRBACRoleBindings_async - */ + /** + * Equivalent to `listScopeRBACRoleBindings`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used 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 (project and location) where the Features will be + * listed. Specified in the format `projects/* /locations/* /scopes/*`. + * @param {number} [request.pageSize] + * Optional. When requesting a 'page' of resources, `page_size` specifies + * number of resources to return. If unspecified or set to 0, all resources + * will be returned. + * @param {string} [request.pageToken] + * Optional. Token returned by previous call to `ListScopeRBACRoleBindings` + * which specifies the position in the list from where to continue listing the + * resources. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.gkehub.v1.RBACRoleBinding|RBACRoleBinding}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@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/gke_hub.list_scope_r_b_a_c_role_bindings.js + * region_tag:gkehub_v1_generated_GkeHub_ListScopeRBACRoleBindings_async + */ listScopeRBACRoleBindingsAsync( - request?: protos.google.cloud.gkehub.v1.IListScopeRBACRoleBindingsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.gkehub.v1.IListScopeRBACRoleBindingsRequest, + 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['listScopeRbacRoleBindings']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listScopeRBACRoleBindings iterate %j', request); return this.descriptors.page.listScopeRBACRoleBindings.asyncIterate( this.innerApiCalls['listScopeRbacRoleBindings'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists Scopes. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent (project and location) where the Scope will be listed. - * Specified in the format `projects/* /locations/*`. - * @param {number} [request.pageSize] - * Optional. When requesting a 'page' of resources, `page_size` specifies - * number of resources to return. If unspecified or set to 0, all resources - * will be returned. - * @param {string} [request.pageToken] - * Optional. Token returned by previous call to `ListScopes` which - * specifies the position in the list from where to continue listing the - * resources. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link protos.google.cloud.gkehub.v1.Scope|Scope}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listScopesAsync()` - * method described below for async iteration which you can stop as 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 Scopes. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent (project and location) where the Scope will be listed. + * Specified in the format `projects/* /locations/*`. + * @param {number} [request.pageSize] + * Optional. When requesting a 'page' of resources, `page_size` specifies + * number of resources to return. If unspecified or set to 0, all resources + * will be returned. + * @param {string} [request.pageToken] + * Optional. Token returned by previous call to `ListScopes` which + * specifies the position in the list from where to continue listing the + * resources. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.gkehub.v1.Scope|Scope}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listScopesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listScopes( - request?: protos.google.cloud.gkehub.v1.IListScopesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gkehub.v1.IScope[], - protos.google.cloud.gkehub.v1.IListScopesRequest|null, - protos.google.cloud.gkehub.v1.IListScopesResponse - ]>; + request?: protos.google.cloud.gkehub.v1.IListScopesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gkehub.v1.IScope[], + protos.google.cloud.gkehub.v1.IListScopesRequest | null, + protos.google.cloud.gkehub.v1.IListScopesResponse, + ] + >; listScopes( - request: protos.google.cloud.gkehub.v1.IListScopesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.gkehub.v1.IListScopesRequest, - protos.google.cloud.gkehub.v1.IListScopesResponse|null|undefined, - protos.google.cloud.gkehub.v1.IScope>): void; + request: protos.google.cloud.gkehub.v1.IListScopesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.gkehub.v1.IListScopesRequest, + protos.google.cloud.gkehub.v1.IListScopesResponse | null | undefined, + protos.google.cloud.gkehub.v1.IScope + >, + ): void; listScopes( - request: protos.google.cloud.gkehub.v1.IListScopesRequest, - callback: PaginationCallback< - protos.google.cloud.gkehub.v1.IListScopesRequest, - protos.google.cloud.gkehub.v1.IListScopesResponse|null|undefined, - protos.google.cloud.gkehub.v1.IScope>): void; + request: protos.google.cloud.gkehub.v1.IListScopesRequest, + callback: PaginationCallback< + protos.google.cloud.gkehub.v1.IListScopesRequest, + protos.google.cloud.gkehub.v1.IListScopesResponse | null | undefined, + protos.google.cloud.gkehub.v1.IScope + >, + ): void; listScopes( - request?: protos.google.cloud.gkehub.v1.IListScopesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.gkehub.v1.IListScopesRequest, - protos.google.cloud.gkehub.v1.IListScopesResponse|null|undefined, - protos.google.cloud.gkehub.v1.IScope>, - callback?: PaginationCallback< + request?: protos.google.cloud.gkehub.v1.IListScopesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.gkehub.v1.IListScopesRequest, - protos.google.cloud.gkehub.v1.IListScopesResponse|null|undefined, - protos.google.cloud.gkehub.v1.IScope>): - Promise<[ - protos.google.cloud.gkehub.v1.IScope[], - protos.google.cloud.gkehub.v1.IListScopesRequest|null, - protos.google.cloud.gkehub.v1.IListScopesResponse - ]>|void { + protos.google.cloud.gkehub.v1.IListScopesResponse | null | undefined, + protos.google.cloud.gkehub.v1.IScope + >, + callback?: PaginationCallback< + protos.google.cloud.gkehub.v1.IListScopesRequest, + protos.google.cloud.gkehub.v1.IListScopesResponse | null | undefined, + protos.google.cloud.gkehub.v1.IScope + >, + ): Promise< + [ + protos.google.cloud.gkehub.v1.IScope[], + protos.google.cloud.gkehub.v1.IListScopesRequest | null, + protos.google.cloud.gkehub.v1.IListScopesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-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.gkehub.v1.IListScopesRequest, - protos.google.cloud.gkehub.v1.IListScopesResponse|null|undefined, - protos.google.cloud.gkehub.v1.IScope>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.gkehub.v1.IListScopesRequest, + protos.google.cloud.gkehub.v1.IListScopesResponse | null | undefined, + protos.google.cloud.gkehub.v1.IScope + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listScopes values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -5908,204 +8268,233 @@ export class GkeHubClient { this._log.info('listScopes request %j', request); return this.innerApiCalls .listScopes(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.gkehub.v1.IScope[], - protos.google.cloud.gkehub.v1.IListScopesRequest|null, - protos.google.cloud.gkehub.v1.IListScopesResponse - ]) => { - this._log.info('listScopes values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.gkehub.v1.IScope[], + protos.google.cloud.gkehub.v1.IListScopesRequest | null, + protos.google.cloud.gkehub.v1.IListScopesResponse, + ]) => { + this._log.info('listScopes values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listScopes`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent (project and location) where the Scope will be listed. - * Specified in the format `projects/* /locations/*`. - * @param {number} [request.pageSize] - * Optional. When requesting a 'page' of resources, `page_size` specifies - * number of resources to return. If unspecified or set to 0, all resources - * will be returned. - * @param {string} [request.pageToken] - * Optional. Token returned by previous call to `ListScopes` which - * specifies the position in the list from where to continue listing the - * resources. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.gkehub.v1.Scope|Scope} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listScopesAsync()` - * method described below for async iteration which you can stop as 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 `listScopes`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent (project and location) where the Scope will be listed. + * Specified in the format `projects/* /locations/*`. + * @param {number} [request.pageSize] + * Optional. When requesting a 'page' of resources, `page_size` specifies + * number of resources to return. If unspecified or set to 0, all resources + * will be returned. + * @param {string} [request.pageToken] + * Optional. Token returned by previous call to `ListScopes` which + * specifies the position in the list from where to continue listing the + * resources. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.gkehub.v1.Scope|Scope} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listScopesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listScopesStream( - request?: protos.google.cloud.gkehub.v1.IListScopesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.gkehub.v1.IListScopesRequest, + 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['listScopes']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listScopes stream %j', request); return this.descriptors.page.listScopes.createStream( this.innerApiCalls.listScopes as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listScopes`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used 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 (project and location) where the Scope will be listed. - * Specified in the format `projects/* /locations/*`. - * @param {number} [request.pageSize] - * Optional. When requesting a 'page' of resources, `page_size` specifies - * number of resources to return. If unspecified or set to 0, all resources - * will be returned. - * @param {string} [request.pageToken] - * Optional. Token returned by previous call to `ListScopes` which - * specifies the position in the list from where to continue listing the - * resources. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.gkehub.v1.Scope|Scope}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@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/gke_hub.list_scopes.js - * region_tag:gkehub_v1_generated_GkeHub_ListScopes_async - */ + /** + * Equivalent to `listScopes`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used 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 (project and location) where the Scope will be listed. + * Specified in the format `projects/* /locations/*`. + * @param {number} [request.pageSize] + * Optional. When requesting a 'page' of resources, `page_size` specifies + * number of resources to return. If unspecified or set to 0, all resources + * will be returned. + * @param {string} [request.pageToken] + * Optional. Token returned by previous call to `ListScopes` which + * specifies the position in the list from where to continue listing the + * resources. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.gkehub.v1.Scope|Scope}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@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/gke_hub.list_scopes.js + * region_tag:gkehub_v1_generated_GkeHub_ListScopes_async + */ listScopesAsync( - request?: protos.google.cloud.gkehub.v1.IListScopesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.gkehub.v1.IListScopesRequest, + 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['listScopes']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listScopes iterate %j', request); return this.descriptors.page.listScopes.asyncIterate( this.innerApiCalls['listScopes'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists permitted Scopes. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent (project and location) where the Scope will be listed. - * Specified in the format `projects/* /locations/*`. - * @param {number} [request.pageSize] - * Optional. When requesting a 'page' of resources, `page_size` specifies - * number of resources to return. If unspecified or set to 0, all resources - * will be returned. - * @param {string} [request.pageToken] - * Optional. Token returned by previous call to `ListPermittedScopes` which - * specifies the position in the list from where to continue listing the - * resources. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link protos.google.cloud.gkehub.v1.Scope|Scope}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listPermittedScopesAsync()` - * method described below for async iteration which you can stop as 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 permitted Scopes. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent (project and location) where the Scope will be listed. + * Specified in the format `projects/* /locations/*`. + * @param {number} [request.pageSize] + * Optional. When requesting a 'page' of resources, `page_size` specifies + * number of resources to return. If unspecified or set to 0, all resources + * will be returned. + * @param {string} [request.pageToken] + * Optional. Token returned by previous call to `ListPermittedScopes` which + * specifies the position in the list from where to continue listing the + * resources. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.gkehub.v1.Scope|Scope}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listPermittedScopesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listPermittedScopes( - request?: protos.google.cloud.gkehub.v1.IListPermittedScopesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gkehub.v1.IScope[], - protos.google.cloud.gkehub.v1.IListPermittedScopesRequest|null, - protos.google.cloud.gkehub.v1.IListPermittedScopesResponse - ]>; + request?: protos.google.cloud.gkehub.v1.IListPermittedScopesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gkehub.v1.IScope[], + protos.google.cloud.gkehub.v1.IListPermittedScopesRequest | null, + protos.google.cloud.gkehub.v1.IListPermittedScopesResponse, + ] + >; listPermittedScopes( - request: protos.google.cloud.gkehub.v1.IListPermittedScopesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.gkehub.v1.IListPermittedScopesRequest, - protos.google.cloud.gkehub.v1.IListPermittedScopesResponse|null|undefined, - protos.google.cloud.gkehub.v1.IScope>): void; + request: protos.google.cloud.gkehub.v1.IListPermittedScopesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.gkehub.v1.IListPermittedScopesRequest, + | protos.google.cloud.gkehub.v1.IListPermittedScopesResponse + | null + | undefined, + protos.google.cloud.gkehub.v1.IScope + >, + ): void; listPermittedScopes( - request: protos.google.cloud.gkehub.v1.IListPermittedScopesRequest, - callback: PaginationCallback< - protos.google.cloud.gkehub.v1.IListPermittedScopesRequest, - protos.google.cloud.gkehub.v1.IListPermittedScopesResponse|null|undefined, - protos.google.cloud.gkehub.v1.IScope>): void; + request: protos.google.cloud.gkehub.v1.IListPermittedScopesRequest, + callback: PaginationCallback< + protos.google.cloud.gkehub.v1.IListPermittedScopesRequest, + | protos.google.cloud.gkehub.v1.IListPermittedScopesResponse + | null + | undefined, + protos.google.cloud.gkehub.v1.IScope + >, + ): void; listPermittedScopes( - request?: protos.google.cloud.gkehub.v1.IListPermittedScopesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< + request?: protos.google.cloud.gkehub.v1.IListPermittedScopesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.gkehub.v1.IListPermittedScopesRequest, - protos.google.cloud.gkehub.v1.IListPermittedScopesResponse|null|undefined, - protos.google.cloud.gkehub.v1.IScope>, - callback?: PaginationCallback< - protos.google.cloud.gkehub.v1.IListPermittedScopesRequest, - protos.google.cloud.gkehub.v1.IListPermittedScopesResponse|null|undefined, - protos.google.cloud.gkehub.v1.IScope>): - Promise<[ - protos.google.cloud.gkehub.v1.IScope[], - protos.google.cloud.gkehub.v1.IListPermittedScopesRequest|null, - protos.google.cloud.gkehub.v1.IListPermittedScopesResponse - ]>|void { + | protos.google.cloud.gkehub.v1.IListPermittedScopesResponse + | null + | undefined, + protos.google.cloud.gkehub.v1.IScope + >, + callback?: PaginationCallback< + protos.google.cloud.gkehub.v1.IListPermittedScopesRequest, + | protos.google.cloud.gkehub.v1.IListPermittedScopesResponse + | null + | undefined, + protos.google.cloud.gkehub.v1.IScope + >, + ): Promise< + [ + protos.google.cloud.gkehub.v1.IScope[], + protos.google.cloud.gkehub.v1.IListPermittedScopesRequest | null, + protos.google.cloud.gkehub.v1.IListPermittedScopesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-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.gkehub.v1.IListPermittedScopesRequest, - protos.google.cloud.gkehub.v1.IListPermittedScopesResponse|null|undefined, - protos.google.cloud.gkehub.v1.IScope>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.gkehub.v1.IListPermittedScopesRequest, + | protos.google.cloud.gkehub.v1.IListPermittedScopesResponse + | null + | undefined, + protos.google.cloud.gkehub.v1.IScope + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listPermittedScopes values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -6114,207 +8503,236 @@ export class GkeHubClient { this._log.info('listPermittedScopes request %j', request); return this.innerApiCalls .listPermittedScopes(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.gkehub.v1.IScope[], - protos.google.cloud.gkehub.v1.IListPermittedScopesRequest|null, - protos.google.cloud.gkehub.v1.IListPermittedScopesResponse - ]) => { - this._log.info('listPermittedScopes values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.gkehub.v1.IScope[], + protos.google.cloud.gkehub.v1.IListPermittedScopesRequest | null, + protos.google.cloud.gkehub.v1.IListPermittedScopesResponse, + ]) => { + this._log.info('listPermittedScopes values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listPermittedScopes`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent (project and location) where the Scope will be listed. - * Specified in the format `projects/* /locations/*`. - * @param {number} [request.pageSize] - * Optional. When requesting a 'page' of resources, `page_size` specifies - * number of resources to return. If unspecified or set to 0, all resources - * will be returned. - * @param {string} [request.pageToken] - * Optional. Token returned by previous call to `ListPermittedScopes` which - * specifies the position in the list from where to continue listing the - * resources. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.gkehub.v1.Scope|Scope} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listPermittedScopesAsync()` - * method described below for async iteration which you can stop as 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 `listPermittedScopes`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent (project and location) where the Scope will be listed. + * Specified in the format `projects/* /locations/*`. + * @param {number} [request.pageSize] + * Optional. When requesting a 'page' of resources, `page_size` specifies + * number of resources to return. If unspecified or set to 0, all resources + * will be returned. + * @param {string} [request.pageToken] + * Optional. Token returned by previous call to `ListPermittedScopes` which + * specifies the position in the list from where to continue listing the + * resources. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.gkehub.v1.Scope|Scope} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listPermittedScopesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listPermittedScopesStream( - request?: protos.google.cloud.gkehub.v1.IListPermittedScopesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.gkehub.v1.IListPermittedScopesRequest, + 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['listPermittedScopes']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listPermittedScopes stream %j', request); return this.descriptors.page.listPermittedScopes.createStream( this.innerApiCalls.listPermittedScopes as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listPermittedScopes`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used 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 (project and location) where the Scope will be listed. - * Specified in the format `projects/* /locations/*`. - * @param {number} [request.pageSize] - * Optional. When requesting a 'page' of resources, `page_size` specifies - * number of resources to return. If unspecified or set to 0, all resources - * will be returned. - * @param {string} [request.pageToken] - * Optional. Token returned by previous call to `ListPermittedScopes` which - * specifies the position in the list from where to continue listing the - * resources. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.gkehub.v1.Scope|Scope}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@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/gke_hub.list_permitted_scopes.js - * region_tag:gkehub_v1_generated_GkeHub_ListPermittedScopes_async - */ + /** + * Equivalent to `listPermittedScopes`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used 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 (project and location) where the Scope will be listed. + * Specified in the format `projects/* /locations/*`. + * @param {number} [request.pageSize] + * Optional. When requesting a 'page' of resources, `page_size` specifies + * number of resources to return. If unspecified or set to 0, all resources + * will be returned. + * @param {string} [request.pageToken] + * Optional. Token returned by previous call to `ListPermittedScopes` which + * specifies the position in the list from where to continue listing the + * resources. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.gkehub.v1.Scope|Scope}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@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/gke_hub.list_permitted_scopes.js + * region_tag:gkehub_v1_generated_GkeHub_ListPermittedScopes_async + */ listPermittedScopesAsync( - request?: protos.google.cloud.gkehub.v1.IListPermittedScopesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.gkehub.v1.IListPermittedScopesRequest, + 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['listPermittedScopes']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listPermittedScopes iterate %j', request); return this.descriptors.page.listPermittedScopes.asyncIterate( this.innerApiCalls['listPermittedScopes'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists MembershipBindings. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent Membership for which the MembershipBindings will be - * listed. Specified in the format `projects/* /locations/* /memberships/*`. - * @param {number} [request.pageSize] - * Optional. When requesting a 'page' of resources, `page_size` specifies - * number of resources to return. If unspecified or set to 0, all resources - * will be returned. - * @param {string} [request.pageToken] - * Optional. Token returned by previous call to `ListMembershipBindings` which - * specifies the position in the list from where to continue listing the - * resources. - * @param {string} [request.filter] - * Optional. Lists MembershipBindings that match the filter expression, - * following the syntax outlined in https://google.aip.dev/160. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link protos.google.cloud.gkehub.v1.MembershipBinding|MembershipBinding}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listMembershipBindingsAsync()` - * method described below for async iteration which you can stop as 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 MembershipBindings. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent Membership for which the MembershipBindings will be + * listed. Specified in the format `projects/* /locations/* /memberships/*`. + * @param {number} [request.pageSize] + * Optional. When requesting a 'page' of resources, `page_size` specifies + * number of resources to return. If unspecified or set to 0, all resources + * will be returned. + * @param {string} [request.pageToken] + * Optional. Token returned by previous call to `ListMembershipBindings` which + * specifies the position in the list from where to continue listing the + * resources. + * @param {string} [request.filter] + * Optional. Lists MembershipBindings that match the filter expression, + * following the syntax outlined in https://google.aip.dev/160. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.gkehub.v1.MembershipBinding|MembershipBinding}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listMembershipBindingsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listMembershipBindings( - request?: protos.google.cloud.gkehub.v1.IListMembershipBindingsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gkehub.v1.IMembershipBinding[], - protos.google.cloud.gkehub.v1.IListMembershipBindingsRequest|null, - protos.google.cloud.gkehub.v1.IListMembershipBindingsResponse - ]>; + request?: protos.google.cloud.gkehub.v1.IListMembershipBindingsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gkehub.v1.IMembershipBinding[], + protos.google.cloud.gkehub.v1.IListMembershipBindingsRequest | null, + protos.google.cloud.gkehub.v1.IListMembershipBindingsResponse, + ] + >; listMembershipBindings( - request: protos.google.cloud.gkehub.v1.IListMembershipBindingsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.gkehub.v1.IListMembershipBindingsRequest, - protos.google.cloud.gkehub.v1.IListMembershipBindingsResponse|null|undefined, - protos.google.cloud.gkehub.v1.IMembershipBinding>): void; + request: protos.google.cloud.gkehub.v1.IListMembershipBindingsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.gkehub.v1.IListMembershipBindingsRequest, + | protos.google.cloud.gkehub.v1.IListMembershipBindingsResponse + | null + | undefined, + protos.google.cloud.gkehub.v1.IMembershipBinding + >, + ): void; listMembershipBindings( - request: protos.google.cloud.gkehub.v1.IListMembershipBindingsRequest, - callback: PaginationCallback< - protos.google.cloud.gkehub.v1.IListMembershipBindingsRequest, - protos.google.cloud.gkehub.v1.IListMembershipBindingsResponse|null|undefined, - protos.google.cloud.gkehub.v1.IMembershipBinding>): void; + request: protos.google.cloud.gkehub.v1.IListMembershipBindingsRequest, + callback: PaginationCallback< + protos.google.cloud.gkehub.v1.IListMembershipBindingsRequest, + | protos.google.cloud.gkehub.v1.IListMembershipBindingsResponse + | null + | undefined, + protos.google.cloud.gkehub.v1.IMembershipBinding + >, + ): void; listMembershipBindings( - request?: protos.google.cloud.gkehub.v1.IListMembershipBindingsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.gkehub.v1.IListMembershipBindingsRequest, - protos.google.cloud.gkehub.v1.IListMembershipBindingsResponse|null|undefined, - protos.google.cloud.gkehub.v1.IMembershipBinding>, - callback?: PaginationCallback< + request?: protos.google.cloud.gkehub.v1.IListMembershipBindingsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.gkehub.v1.IListMembershipBindingsRequest, - protos.google.cloud.gkehub.v1.IListMembershipBindingsResponse|null|undefined, - protos.google.cloud.gkehub.v1.IMembershipBinding>): - Promise<[ - protos.google.cloud.gkehub.v1.IMembershipBinding[], - protos.google.cloud.gkehub.v1.IListMembershipBindingsRequest|null, - protos.google.cloud.gkehub.v1.IListMembershipBindingsResponse - ]>|void { + | protos.google.cloud.gkehub.v1.IListMembershipBindingsResponse + | null + | undefined, + protos.google.cloud.gkehub.v1.IMembershipBinding + >, + callback?: PaginationCallback< + protos.google.cloud.gkehub.v1.IListMembershipBindingsRequest, + | protos.google.cloud.gkehub.v1.IListMembershipBindingsResponse + | null + | undefined, + protos.google.cloud.gkehub.v1.IMembershipBinding + >, + ): Promise< + [ + protos.google.cloud.gkehub.v1.IMembershipBinding[], + protos.google.cloud.gkehub.v1.IListMembershipBindingsRequest | null, + protos.google.cloud.gkehub.v1.IListMembershipBindingsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-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.gkehub.v1.IListMembershipBindingsRequest, - protos.google.cloud.gkehub.v1.IListMembershipBindingsResponse|null|undefined, - protos.google.cloud.gkehub.v1.IMembershipBinding>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.gkehub.v1.IListMembershipBindingsRequest, + | protos.google.cloud.gkehub.v1.IListMembershipBindingsResponse + | null + | undefined, + protos.google.cloud.gkehub.v1.IMembershipBinding + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listMembershipBindings values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -6323,210 +8741,239 @@ export class GkeHubClient { this._log.info('listMembershipBindings request %j', request); return this.innerApiCalls .listMembershipBindings(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.gkehub.v1.IMembershipBinding[], - protos.google.cloud.gkehub.v1.IListMembershipBindingsRequest|null, - protos.google.cloud.gkehub.v1.IListMembershipBindingsResponse - ]) => { - this._log.info('listMembershipBindings values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.gkehub.v1.IMembershipBinding[], + protos.google.cloud.gkehub.v1.IListMembershipBindingsRequest | null, + protos.google.cloud.gkehub.v1.IListMembershipBindingsResponse, + ]) => { + this._log.info('listMembershipBindings values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listMembershipBindings`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent Membership for which the MembershipBindings will be - * listed. Specified in the format `projects/* /locations/* /memberships/*`. - * @param {number} [request.pageSize] - * Optional. When requesting a 'page' of resources, `page_size` specifies - * number of resources to return. If unspecified or set to 0, all resources - * will be returned. - * @param {string} [request.pageToken] - * Optional. Token returned by previous call to `ListMembershipBindings` which - * specifies the position in the list from where to continue listing the - * resources. - * @param {string} [request.filter] - * Optional. Lists MembershipBindings that match the filter expression, - * following the syntax outlined in https://google.aip.dev/160. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.gkehub.v1.MembershipBinding|MembershipBinding} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listMembershipBindingsAsync()` - * method described below for async iteration which you can stop as 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 `listMembershipBindings`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent Membership for which the MembershipBindings will be + * listed. Specified in the format `projects/* /locations/* /memberships/*`. + * @param {number} [request.pageSize] + * Optional. When requesting a 'page' of resources, `page_size` specifies + * number of resources to return. If unspecified or set to 0, all resources + * will be returned. + * @param {string} [request.pageToken] + * Optional. Token returned by previous call to `ListMembershipBindings` which + * specifies the position in the list from where to continue listing the + * resources. + * @param {string} [request.filter] + * Optional. Lists MembershipBindings that match the filter expression, + * following the syntax outlined in https://google.aip.dev/160. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.gkehub.v1.MembershipBinding|MembershipBinding} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listMembershipBindingsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listMembershipBindingsStream( - request?: protos.google.cloud.gkehub.v1.IListMembershipBindingsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.gkehub.v1.IListMembershipBindingsRequest, + 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['listMembershipBindings']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listMembershipBindings stream %j', request); return this.descriptors.page.listMembershipBindings.createStream( this.innerApiCalls.listMembershipBindings as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listMembershipBindings`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used 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 Membership for which the MembershipBindings will be - * listed. Specified in the format `projects/* /locations/* /memberships/*`. - * @param {number} [request.pageSize] - * Optional. When requesting a 'page' of resources, `page_size` specifies - * number of resources to return. If unspecified or set to 0, all resources - * will be returned. - * @param {string} [request.pageToken] - * Optional. Token returned by previous call to `ListMembershipBindings` which - * specifies the position in the list from where to continue listing the - * resources. - * @param {string} [request.filter] - * Optional. Lists MembershipBindings that match the filter expression, - * following the syntax outlined in https://google.aip.dev/160. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.gkehub.v1.MembershipBinding|MembershipBinding}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@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/gke_hub.list_membership_bindings.js - * region_tag:gkehub_v1_generated_GkeHub_ListMembershipBindings_async - */ + /** + * Equivalent to `listMembershipBindings`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used 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 Membership for which the MembershipBindings will be + * listed. Specified in the format `projects/* /locations/* /memberships/*`. + * @param {number} [request.pageSize] + * Optional. When requesting a 'page' of resources, `page_size` specifies + * number of resources to return. If unspecified or set to 0, all resources + * will be returned. + * @param {string} [request.pageToken] + * Optional. Token returned by previous call to `ListMembershipBindings` which + * specifies the position in the list from where to continue listing the + * resources. + * @param {string} [request.filter] + * Optional. Lists MembershipBindings that match the filter expression, + * following the syntax outlined in https://google.aip.dev/160. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.gkehub.v1.MembershipBinding|MembershipBinding}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@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/gke_hub.list_membership_bindings.js + * region_tag:gkehub_v1_generated_GkeHub_ListMembershipBindings_async + */ listMembershipBindingsAsync( - request?: protos.google.cloud.gkehub.v1.IListMembershipBindingsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.gkehub.v1.IListMembershipBindingsRequest, + 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['listMembershipBindings']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listMembershipBindings iterate %j', request); return this.descriptors.page.listMembershipBindings.asyncIterate( this.innerApiCalls['listMembershipBindings'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists all Membership RBACRoleBindings. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent (project and location) where the Features will be - * listed. Specified in the format `projects/* /locations/* /memberships/*`. - * @param {number} [request.pageSize] - * Optional. When requesting a 'page' of resources, `page_size` specifies - * number of resources to return. If unspecified or set to 0, all resources - * will be returned. - * @param {string} [request.pageToken] - * Optional. Token returned by previous call to - * `ListMembershipRBACRoleBindings` which specifies the position in the list - * from where to continue listing the resources. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link protos.google.cloud.gkehub.v1.RBACRoleBinding|RBACRoleBinding}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listMembershipRBACRoleBindingsAsync()` - * method described below for async iteration which you can stop as 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 Membership RBACRoleBindings. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent (project and location) where the Features will be + * listed. Specified in the format `projects/* /locations/* /memberships/*`. + * @param {number} [request.pageSize] + * Optional. When requesting a 'page' of resources, `page_size` specifies + * number of resources to return. If unspecified or set to 0, all resources + * will be returned. + * @param {string} [request.pageToken] + * Optional. Token returned by previous call to + * `ListMembershipRBACRoleBindings` which specifies the position in the list + * from where to continue listing the resources. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.gkehub.v1.RBACRoleBinding|RBACRoleBinding}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listMembershipRBACRoleBindingsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listMembershipRBACRoleBindings( - request?: protos.google.cloud.gkehub.v1.IListMembershipRBACRoleBindingsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gkehub.v1.IRBACRoleBinding[], - protos.google.cloud.gkehub.v1.IListMembershipRBACRoleBindingsRequest|null, - protos.google.cloud.gkehub.v1.IListMembershipRBACRoleBindingsResponse - ]>; + request?: protos.google.cloud.gkehub.v1.IListMembershipRBACRoleBindingsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gkehub.v1.IRBACRoleBinding[], + protos.google.cloud.gkehub.v1.IListMembershipRBACRoleBindingsRequest | null, + protos.google.cloud.gkehub.v1.IListMembershipRBACRoleBindingsResponse, + ] + >; listMembershipRBACRoleBindings( - request: protos.google.cloud.gkehub.v1.IListMembershipRBACRoleBindingsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.gkehub.v1.IListMembershipRBACRoleBindingsRequest, - protos.google.cloud.gkehub.v1.IListMembershipRBACRoleBindingsResponse|null|undefined, - protos.google.cloud.gkehub.v1.IRBACRoleBinding>): void; + request: protos.google.cloud.gkehub.v1.IListMembershipRBACRoleBindingsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.gkehub.v1.IListMembershipRBACRoleBindingsRequest, + | protos.google.cloud.gkehub.v1.IListMembershipRBACRoleBindingsResponse + | null + | undefined, + protos.google.cloud.gkehub.v1.IRBACRoleBinding + >, + ): void; listMembershipRBACRoleBindings( - request: protos.google.cloud.gkehub.v1.IListMembershipRBACRoleBindingsRequest, - callback: PaginationCallback< - protos.google.cloud.gkehub.v1.IListMembershipRBACRoleBindingsRequest, - protos.google.cloud.gkehub.v1.IListMembershipRBACRoleBindingsResponse|null|undefined, - protos.google.cloud.gkehub.v1.IRBACRoleBinding>): void; + request: protos.google.cloud.gkehub.v1.IListMembershipRBACRoleBindingsRequest, + callback: PaginationCallback< + protos.google.cloud.gkehub.v1.IListMembershipRBACRoleBindingsRequest, + | protos.google.cloud.gkehub.v1.IListMembershipRBACRoleBindingsResponse + | null + | undefined, + protos.google.cloud.gkehub.v1.IRBACRoleBinding + >, + ): void; listMembershipRBACRoleBindings( - request?: protos.google.cloud.gkehub.v1.IListMembershipRBACRoleBindingsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< + request?: protos.google.cloud.gkehub.v1.IListMembershipRBACRoleBindingsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.gkehub.v1.IListMembershipRBACRoleBindingsRequest, - protos.google.cloud.gkehub.v1.IListMembershipRBACRoleBindingsResponse|null|undefined, - protos.google.cloud.gkehub.v1.IRBACRoleBinding>, - callback?: PaginationCallback< - protos.google.cloud.gkehub.v1.IListMembershipRBACRoleBindingsRequest, - protos.google.cloud.gkehub.v1.IListMembershipRBACRoleBindingsResponse|null|undefined, - protos.google.cloud.gkehub.v1.IRBACRoleBinding>): - Promise<[ - protos.google.cloud.gkehub.v1.IRBACRoleBinding[], - protos.google.cloud.gkehub.v1.IListMembershipRBACRoleBindingsRequest|null, - protos.google.cloud.gkehub.v1.IListMembershipRBACRoleBindingsResponse - ]>|void { + | protos.google.cloud.gkehub.v1.IListMembershipRBACRoleBindingsResponse + | null + | undefined, + protos.google.cloud.gkehub.v1.IRBACRoleBinding + >, + callback?: PaginationCallback< + protos.google.cloud.gkehub.v1.IListMembershipRBACRoleBindingsRequest, + | protos.google.cloud.gkehub.v1.IListMembershipRBACRoleBindingsResponse + | null + | undefined, + protos.google.cloud.gkehub.v1.IRBACRoleBinding + >, + ): Promise< + [ + protos.google.cloud.gkehub.v1.IRBACRoleBinding[], + protos.google.cloud.gkehub.v1.IListMembershipRBACRoleBindingsRequest | null, + protos.google.cloud.gkehub.v1.IListMembershipRBACRoleBindingsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-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.gkehub.v1.IListMembershipRBACRoleBindingsRequest, - protos.google.cloud.gkehub.v1.IListMembershipRBACRoleBindingsResponse|null|undefined, - protos.google.cloud.gkehub.v1.IRBACRoleBinding>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.gkehub.v1.IListMembershipRBACRoleBindingsRequest, + | protos.google.cloud.gkehub.v1.IListMembershipRBACRoleBindingsResponse + | null + | undefined, + protos.google.cloud.gkehub.v1.IRBACRoleBinding + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listMembershipRBACRoleBindings values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -6535,116 +8982,122 @@ export class GkeHubClient { this._log.info('listMembershipRBACRoleBindings request %j', request); return this.innerApiCalls .listMembershipRbacRoleBindings(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.gkehub.v1.IRBACRoleBinding[], - protos.google.cloud.gkehub.v1.IListMembershipRBACRoleBindingsRequest|null, - protos.google.cloud.gkehub.v1.IListMembershipRBACRoleBindingsResponse - ]) => { - this._log.info('listMembershipRBACRoleBindings values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.gkehub.v1.IRBACRoleBinding[], + protos.google.cloud.gkehub.v1.IListMembershipRBACRoleBindingsRequest | null, + protos.google.cloud.gkehub.v1.IListMembershipRBACRoleBindingsResponse, + ]) => { + this._log.info('listMembershipRBACRoleBindings values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listMembershipRBACRoleBindings`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent (project and location) where the Features will be - * listed. Specified in the format `projects/* /locations/* /memberships/*`. - * @param {number} [request.pageSize] - * Optional. When requesting a 'page' of resources, `page_size` specifies - * number of resources to return. If unspecified or set to 0, all resources - * will be returned. - * @param {string} [request.pageToken] - * Optional. Token returned by previous call to - * `ListMembershipRBACRoleBindings` which specifies the position in the list - * from where to continue listing the resources. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.gkehub.v1.RBACRoleBinding|RBACRoleBinding} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listMembershipRBACRoleBindingsAsync()` - * method described below for async iteration which you can stop as 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 `listMembershipRBACRoleBindings`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent (project and location) where the Features will be + * listed. Specified in the format `projects/* /locations/* /memberships/*`. + * @param {number} [request.pageSize] + * Optional. When requesting a 'page' of resources, `page_size` specifies + * number of resources to return. If unspecified or set to 0, all resources + * will be returned. + * @param {string} [request.pageToken] + * Optional. Token returned by previous call to + * `ListMembershipRBACRoleBindings` which specifies the position in the list + * from where to continue listing the resources. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.gkehub.v1.RBACRoleBinding|RBACRoleBinding} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listMembershipRBACRoleBindingsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listMembershipRBACRoleBindingsStream( - request?: protos.google.cloud.gkehub.v1.IListMembershipRBACRoleBindingsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.gkehub.v1.IListMembershipRBACRoleBindingsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listMembershipRbacRoleBindings']; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = + this._defaults['listMembershipRbacRoleBindings']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listMembershipRBACRoleBindings stream %j', request); return this.descriptors.page.listMembershipRBACRoleBindings.createStream( this.innerApiCalls.listMembershipRbacRoleBindings as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listMembershipRBACRoleBindings`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used 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 (project and location) where the Features will be - * listed. Specified in the format `projects/* /locations/* /memberships/*`. - * @param {number} [request.pageSize] - * Optional. When requesting a 'page' of resources, `page_size` specifies - * number of resources to return. If unspecified or set to 0, all resources - * will be returned. - * @param {string} [request.pageToken] - * Optional. Token returned by previous call to - * `ListMembershipRBACRoleBindings` which specifies the position in the list - * from where to continue listing the resources. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.gkehub.v1.RBACRoleBinding|RBACRoleBinding}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@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/gke_hub.list_membership_r_b_a_c_role_bindings.js - * region_tag:gkehub_v1_generated_GkeHub_ListMembershipRBACRoleBindings_async - */ + /** + * Equivalent to `listMembershipRBACRoleBindings`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used 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 (project and location) where the Features will be + * listed. Specified in the format `projects/* /locations/* /memberships/*`. + * @param {number} [request.pageSize] + * Optional. When requesting a 'page' of resources, `page_size` specifies + * number of resources to return. If unspecified or set to 0, all resources + * will be returned. + * @param {string} [request.pageToken] + * Optional. Token returned by previous call to + * `ListMembershipRBACRoleBindings` which specifies the position in the list + * from where to continue listing the resources. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.gkehub.v1.RBACRoleBinding|RBACRoleBinding}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@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/gke_hub.list_membership_r_b_a_c_role_bindings.js + * region_tag:gkehub_v1_generated_GkeHub_ListMembershipRBACRoleBindings_async + */ listMembershipRBACRoleBindingsAsync( - request?: protos.google.cloud.gkehub.v1.IListMembershipRBACRoleBindingsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.gkehub.v1.IListMembershipRBACRoleBindingsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listMembershipRbacRoleBindings']; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = + this._defaults['listMembershipRbacRoleBindings']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listMembershipRBACRoleBindings iterate %j', request); return this.descriptors.page.listMembershipRBACRoleBindings.asyncIterate( this.innerApiCalls['listMembershipRbacRoleBindings'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } // -------------------- @@ -6659,7 +9112,7 @@ export class GkeHubClient { * @param {string} feature * @returns {string} Resource name string. */ - featurePath(project:string,location:string,feature:string) { + featurePath(project: string, location: string, feature: string) { return this.pathTemplates.featurePathTemplate.render({ project: project, location: location, @@ -6707,7 +9160,7 @@ export class GkeHubClient { * @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, @@ -6744,7 +9197,7 @@ export class GkeHubClient { * @param {string} membership * @returns {string} Resource name string. */ - membershipPath(project:string,location:string,membership:string) { + membershipPath(project: string, location: string, membership: string) { return this.pathTemplates.membershipPathTemplate.render({ project: project, location: location, @@ -6760,7 +9213,8 @@ export class GkeHubClient { * @returns {string} A string representing the project. */ matchProjectFromMembershipName(membershipName: string) { - return this.pathTemplates.membershipPathTemplate.match(membershipName).project; + return this.pathTemplates.membershipPathTemplate.match(membershipName) + .project; } /** @@ -6771,7 +9225,8 @@ export class GkeHubClient { * @returns {string} A string representing the location. */ matchLocationFromMembershipName(membershipName: string) { - return this.pathTemplates.membershipPathTemplate.match(membershipName).location; + return this.pathTemplates.membershipPathTemplate.match(membershipName) + .location; } /** @@ -6782,7 +9237,8 @@ export class GkeHubClient { * @returns {string} A string representing the membership. */ matchMembershipFromMembershipName(membershipName: string) { - return this.pathTemplates.membershipPathTemplate.match(membershipName).membership; + return this.pathTemplates.membershipPathTemplate.match(membershipName) + .membership; } /** @@ -6794,7 +9250,12 @@ export class GkeHubClient { * @param {string} membershipbinding * @returns {string} Resource name string. */ - membershipBindingPath(project:string,location:string,membership:string,membershipbinding:string) { + membershipBindingPath( + project: string, + location: string, + membership: string, + membershipbinding: string, + ) { return this.pathTemplates.membershipBindingPathTemplate.render({ project: project, location: location, @@ -6811,7 +9272,9 @@ export class GkeHubClient { * @returns {string} A string representing the project. */ matchProjectFromMembershipBindingName(membershipBindingName: string) { - return this.pathTemplates.membershipBindingPathTemplate.match(membershipBindingName).project; + return this.pathTemplates.membershipBindingPathTemplate.match( + membershipBindingName, + ).project; } /** @@ -6822,7 +9285,9 @@ export class GkeHubClient { * @returns {string} A string representing the location. */ matchLocationFromMembershipBindingName(membershipBindingName: string) { - return this.pathTemplates.membershipBindingPathTemplate.match(membershipBindingName).location; + return this.pathTemplates.membershipBindingPathTemplate.match( + membershipBindingName, + ).location; } /** @@ -6833,7 +9298,9 @@ export class GkeHubClient { * @returns {string} A string representing the membership. */ matchMembershipFromMembershipBindingName(membershipBindingName: string) { - return this.pathTemplates.membershipBindingPathTemplate.match(membershipBindingName).membership; + return this.pathTemplates.membershipBindingPathTemplate.match( + membershipBindingName, + ).membership; } /** @@ -6843,8 +9310,12 @@ export class GkeHubClient { * A fully-qualified path representing MembershipBinding resource. * @returns {string} A string representing the membershipbinding. */ - matchMembershipbindingFromMembershipBindingName(membershipBindingName: string) { - return this.pathTemplates.membershipBindingPathTemplate.match(membershipBindingName).membershipbinding; + matchMembershipbindingFromMembershipBindingName( + membershipBindingName: string, + ) { + return this.pathTemplates.membershipBindingPathTemplate.match( + membershipBindingName, + ).membershipbinding; } /** @@ -6856,7 +9327,12 @@ export class GkeHubClient { * @param {string} namespace * @returns {string} Resource name string. */ - namespacePath(project:string,location:string,scope:string,namespace:string) { + namespacePath( + project: string, + location: string, + scope: string, + namespace: string, + ) { return this.pathTemplates.namespacePathTemplate.render({ project: project, location: location, @@ -6873,7 +9349,8 @@ export class GkeHubClient { * @returns {string} A string representing the project. */ matchProjectFromNamespaceName(namespaceName: string) { - return this.pathTemplates.namespacePathTemplate.match(namespaceName).project; + return this.pathTemplates.namespacePathTemplate.match(namespaceName) + .project; } /** @@ -6884,7 +9361,8 @@ export class GkeHubClient { * @returns {string} A string representing the location. */ matchLocationFromNamespaceName(namespaceName: string) { - return this.pathTemplates.namespacePathTemplate.match(namespaceName).location; + return this.pathTemplates.namespacePathTemplate.match(namespaceName) + .location; } /** @@ -6906,7 +9384,8 @@ export class GkeHubClient { * @returns {string} A string representing the namespace. */ matchNamespaceFromNamespaceName(namespaceName: string) { - return this.pathTemplates.namespacePathTemplate.match(namespaceName).namespace; + return this.pathTemplates.namespacePathTemplate.match(namespaceName) + .namespace; } /** @@ -6917,7 +9396,11 @@ export class GkeHubClient { * @param {string} fleet * @returns {string} Resource name string. */ - organizationLocationFleetPath(organization:string,location:string,fleet:string) { + organizationLocationFleetPath( + organization: string, + location: string, + fleet: string, + ) { return this.pathTemplates.organizationLocationFleetPathTemplate.render({ organization: organization, location: location, @@ -6932,8 +9415,12 @@ export class GkeHubClient { * A fully-qualified path representing organization_location_fleet resource. * @returns {string} A string representing the organization. */ - matchOrganizationFromOrganizationLocationFleetName(organizationLocationFleetName: string) { - return this.pathTemplates.organizationLocationFleetPathTemplate.match(organizationLocationFleetName).organization; + matchOrganizationFromOrganizationLocationFleetName( + organizationLocationFleetName: string, + ) { + return this.pathTemplates.organizationLocationFleetPathTemplate.match( + organizationLocationFleetName, + ).organization; } /** @@ -6943,8 +9430,12 @@ export class GkeHubClient { * A fully-qualified path representing organization_location_fleet resource. * @returns {string} A string representing the location. */ - matchLocationFromOrganizationLocationFleetName(organizationLocationFleetName: string) { - return this.pathTemplates.organizationLocationFleetPathTemplate.match(organizationLocationFleetName).location; + matchLocationFromOrganizationLocationFleetName( + organizationLocationFleetName: string, + ) { + return this.pathTemplates.organizationLocationFleetPathTemplate.match( + organizationLocationFleetName, + ).location; } /** @@ -6954,8 +9445,12 @@ export class GkeHubClient { * A fully-qualified path representing organization_location_fleet resource. * @returns {string} A string representing the fleet. */ - matchFleetFromOrganizationLocationFleetName(organizationLocationFleetName: string) { - return this.pathTemplates.organizationLocationFleetPathTemplate.match(organizationLocationFleetName).fleet; + matchFleetFromOrganizationLocationFleetName( + organizationLocationFleetName: string, + ) { + return this.pathTemplates.organizationLocationFleetPathTemplate.match( + organizationLocationFleetName, + ).fleet; } /** @@ -6964,7 +9459,7 @@ export class GkeHubClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -6989,7 +9484,7 @@ export class GkeHubClient { * @param {string} fleet * @returns {string} Resource name string. */ - projectLocationFleetPath(project:string,location:string,fleet:string) { + projectLocationFleetPath(project: string, location: string, fleet: string) { return this.pathTemplates.projectLocationFleetPathTemplate.render({ project: project, location: location, @@ -7005,7 +9500,9 @@ export class GkeHubClient { * @returns {string} A string representing the project. */ matchProjectFromProjectLocationFleetName(projectLocationFleetName: string) { - return this.pathTemplates.projectLocationFleetPathTemplate.match(projectLocationFleetName).project; + return this.pathTemplates.projectLocationFleetPathTemplate.match( + projectLocationFleetName, + ).project; } /** @@ -7016,7 +9513,9 @@ export class GkeHubClient { * @returns {string} A string representing the location. */ matchLocationFromProjectLocationFleetName(projectLocationFleetName: string) { - return this.pathTemplates.projectLocationFleetPathTemplate.match(projectLocationFleetName).location; + return this.pathTemplates.projectLocationFleetPathTemplate.match( + projectLocationFleetName, + ).location; } /** @@ -7027,7 +9526,9 @@ export class GkeHubClient { * @returns {string} A string representing the fleet. */ matchFleetFromProjectLocationFleetName(projectLocationFleetName: string) { - return this.pathTemplates.projectLocationFleetPathTemplate.match(projectLocationFleetName).fleet; + return this.pathTemplates.projectLocationFleetPathTemplate.match( + projectLocationFleetName, + ).fleet; } /** @@ -7039,13 +9540,20 @@ export class GkeHubClient { * @param {string} rbacrolebinding * @returns {string} Resource name string. */ - projectLocationMembershipRbacrolebindingPath(project:string,location:string,membership:string,rbacrolebinding:string) { - return this.pathTemplates.projectLocationMembershipRbacrolebindingPathTemplate.render({ - project: project, - location: location, - membership: membership, - rbacrolebinding: rbacrolebinding, - }); + projectLocationMembershipRbacrolebindingPath( + project: string, + location: string, + membership: string, + rbacrolebinding: string, + ) { + return this.pathTemplates.projectLocationMembershipRbacrolebindingPathTemplate.render( + { + project: project, + location: location, + membership: membership, + rbacrolebinding: rbacrolebinding, + }, + ); } /** @@ -7055,8 +9563,12 @@ export class GkeHubClient { * A fully-qualified path representing project_location_membership_rbacrolebinding resource. * @returns {string} A string representing the project. */ - matchProjectFromProjectLocationMembershipRbacrolebindingName(projectLocationMembershipRbacrolebindingName: string) { - return this.pathTemplates.projectLocationMembershipRbacrolebindingPathTemplate.match(projectLocationMembershipRbacrolebindingName).project; + matchProjectFromProjectLocationMembershipRbacrolebindingName( + projectLocationMembershipRbacrolebindingName: string, + ) { + return this.pathTemplates.projectLocationMembershipRbacrolebindingPathTemplate.match( + projectLocationMembershipRbacrolebindingName, + ).project; } /** @@ -7066,8 +9578,12 @@ export class GkeHubClient { * A fully-qualified path representing project_location_membership_rbacrolebinding resource. * @returns {string} A string representing the location. */ - matchLocationFromProjectLocationMembershipRbacrolebindingName(projectLocationMembershipRbacrolebindingName: string) { - return this.pathTemplates.projectLocationMembershipRbacrolebindingPathTemplate.match(projectLocationMembershipRbacrolebindingName).location; + matchLocationFromProjectLocationMembershipRbacrolebindingName( + projectLocationMembershipRbacrolebindingName: string, + ) { + return this.pathTemplates.projectLocationMembershipRbacrolebindingPathTemplate.match( + projectLocationMembershipRbacrolebindingName, + ).location; } /** @@ -7077,8 +9593,12 @@ export class GkeHubClient { * A fully-qualified path representing project_location_membership_rbacrolebinding resource. * @returns {string} A string representing the membership. */ - matchMembershipFromProjectLocationMembershipRbacrolebindingName(projectLocationMembershipRbacrolebindingName: string) { - return this.pathTemplates.projectLocationMembershipRbacrolebindingPathTemplate.match(projectLocationMembershipRbacrolebindingName).membership; + matchMembershipFromProjectLocationMembershipRbacrolebindingName( + projectLocationMembershipRbacrolebindingName: string, + ) { + return this.pathTemplates.projectLocationMembershipRbacrolebindingPathTemplate.match( + projectLocationMembershipRbacrolebindingName, + ).membership; } /** @@ -7088,8 +9608,12 @@ export class GkeHubClient { * A fully-qualified path representing project_location_membership_rbacrolebinding resource. * @returns {string} A string representing the rbacrolebinding. */ - matchRbacrolebindingFromProjectLocationMembershipRbacrolebindingName(projectLocationMembershipRbacrolebindingName: string) { - return this.pathTemplates.projectLocationMembershipRbacrolebindingPathTemplate.match(projectLocationMembershipRbacrolebindingName).rbacrolebinding; + matchRbacrolebindingFromProjectLocationMembershipRbacrolebindingName( + projectLocationMembershipRbacrolebindingName: string, + ) { + return this.pathTemplates.projectLocationMembershipRbacrolebindingPathTemplate.match( + projectLocationMembershipRbacrolebindingName, + ).rbacrolebinding; } /** @@ -7101,13 +9625,20 @@ export class GkeHubClient { * @param {string} rbacrolebinding * @returns {string} Resource name string. */ - projectLocationScopeRbacrolebindingPath(project:string,location:string,scope:string,rbacrolebinding:string) { - return this.pathTemplates.projectLocationScopeRbacrolebindingPathTemplate.render({ - project: project, - location: location, - scope: scope, - rbacrolebinding: rbacrolebinding, - }); + projectLocationScopeRbacrolebindingPath( + project: string, + location: string, + scope: string, + rbacrolebinding: string, + ) { + return this.pathTemplates.projectLocationScopeRbacrolebindingPathTemplate.render( + { + project: project, + location: location, + scope: scope, + rbacrolebinding: rbacrolebinding, + }, + ); } /** @@ -7117,8 +9648,12 @@ export class GkeHubClient { * A fully-qualified path representing project_location_scope_rbacrolebinding resource. * @returns {string} A string representing the project. */ - matchProjectFromProjectLocationScopeRbacrolebindingName(projectLocationScopeRbacrolebindingName: string) { - return this.pathTemplates.projectLocationScopeRbacrolebindingPathTemplate.match(projectLocationScopeRbacrolebindingName).project; + matchProjectFromProjectLocationScopeRbacrolebindingName( + projectLocationScopeRbacrolebindingName: string, + ) { + return this.pathTemplates.projectLocationScopeRbacrolebindingPathTemplate.match( + projectLocationScopeRbacrolebindingName, + ).project; } /** @@ -7128,8 +9663,12 @@ export class GkeHubClient { * A fully-qualified path representing project_location_scope_rbacrolebinding resource. * @returns {string} A string representing the location. */ - matchLocationFromProjectLocationScopeRbacrolebindingName(projectLocationScopeRbacrolebindingName: string) { - return this.pathTemplates.projectLocationScopeRbacrolebindingPathTemplate.match(projectLocationScopeRbacrolebindingName).location; + matchLocationFromProjectLocationScopeRbacrolebindingName( + projectLocationScopeRbacrolebindingName: string, + ) { + return this.pathTemplates.projectLocationScopeRbacrolebindingPathTemplate.match( + projectLocationScopeRbacrolebindingName, + ).location; } /** @@ -7139,8 +9678,12 @@ export class GkeHubClient { * A fully-qualified path representing project_location_scope_rbacrolebinding resource. * @returns {string} A string representing the scope. */ - matchScopeFromProjectLocationScopeRbacrolebindingName(projectLocationScopeRbacrolebindingName: string) { - return this.pathTemplates.projectLocationScopeRbacrolebindingPathTemplate.match(projectLocationScopeRbacrolebindingName).scope; + matchScopeFromProjectLocationScopeRbacrolebindingName( + projectLocationScopeRbacrolebindingName: string, + ) { + return this.pathTemplates.projectLocationScopeRbacrolebindingPathTemplate.match( + projectLocationScopeRbacrolebindingName, + ).scope; } /** @@ -7150,8 +9693,12 @@ export class GkeHubClient { * A fully-qualified path representing project_location_scope_rbacrolebinding resource. * @returns {string} A string representing the rbacrolebinding. */ - matchRbacrolebindingFromProjectLocationScopeRbacrolebindingName(projectLocationScopeRbacrolebindingName: string) { - return this.pathTemplates.projectLocationScopeRbacrolebindingPathTemplate.match(projectLocationScopeRbacrolebindingName).rbacrolebinding; + matchRbacrolebindingFromProjectLocationScopeRbacrolebindingName( + projectLocationScopeRbacrolebindingName: string, + ) { + return this.pathTemplates.projectLocationScopeRbacrolebindingPathTemplate.match( + projectLocationScopeRbacrolebindingName, + ).rbacrolebinding; } /** @@ -7162,7 +9709,7 @@ export class GkeHubClient { * @param {string} scope * @returns {string} Resource name string. */ - scopePath(project:string,location:string,scope:string) { + scopePath(project: string, location: string, scope: string) { return this.pathTemplates.scopePathTemplate.render({ project: project, location: location, @@ -7211,7 +9758,7 @@ export class GkeHubClient { */ close(): Promise { if (this.gkeHubStub && !this._terminated) { - return this.gkeHubStub.then(stub => { + return this.gkeHubStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); @@ -7220,4 +9767,4 @@ export class GkeHubClient { } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-gkehub/src/v1/index.ts b/packages/google-cloud-gkehub/src/v1/index.ts index 5512785d3fb8..ea1c8a89881c 100644 --- a/packages/google-cloud-gkehub/src/v1/index.ts +++ b/packages/google-cloud-gkehub/src/v1/index.ts @@ -16,4 +16,4 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {GkeHubClient} from './gke_hub_client'; +export { GkeHubClient } from './gke_hub_client'; diff --git a/packages/google-cloud-gkehub/src/v1alpha/gke_hub_client.ts b/packages/google-cloud-gkehub/src/v1alpha/gke_hub_client.ts index 66e553005203..779eb9ece8c8 100644 --- a/packages/google-cloud-gkehub/src/v1alpha/gke_hub_client.ts +++ b/packages/google-cloud-gkehub/src/v1alpha/gke_hub_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 @@ -57,7 +66,7 @@ export class GkeHubClient { 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('gke-hub'); @@ -70,10 +79,10 @@ export class GkeHubClient { 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; - gkeHubStub?: Promise<{[name: string]: Function}>; + gkeHubStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of GkeHubClient. @@ -114,21 +123,42 @@ export class GkeHubClient { * const client = new GkeHubClient({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 GkeHubClient; - 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 = 'gkehub.' + 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; @@ -153,7 +183,7 @@ export class GkeHubClient { this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; // Set useJWTAccessWithScope on the auth object. this.auth.useJWTAccessWithScope = true; @@ -167,10 +197,7 @@ export class GkeHubClient { } // 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 { @@ -192,7 +219,7 @@ export class GkeHubClient { // Create useful helper objects for these. this.pathTemplates = { featurePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/features/{feature}' + 'projects/{project}/locations/{location}/features/{feature}', ), }; @@ -200,8 +227,11 @@ export class GkeHubClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listFeatures: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'resources') + listFeatures: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'resources', + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -210,48 +240,116 @@ export class GkeHubClient { // rather than holding a request open. const lroOptions: GrpcClientOptions = { auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1alpha/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1alpha/{name=projects/*}/locations',},{selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',get: '/v1alpha/{resource=projects/*/locations/*/memberships/*}:getIamPolicy',additional_bindings: [{get: '/v1alpha/{resource=projects/*/locations/*/features/*}:getIamPolicy',}], - },{selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',post: '/v1alpha/{resource=projects/*/locations/*/memberships/*}:setIamPolicy',body: '*',additional_bindings: [{post: '/v1alpha/{resource=projects/*/locations/*/features/*}:setIamPolicy',body: '*',}], - },{selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',post: '/v1alpha/{resource=projects/*/locations/*/memberships/*}:testIamPermissions',body: '*',additional_bindings: [{post: '/v1alpha/{resource=projects/*/locations/*/features/*}:testIamPermissions',body: '*',}], - },{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1alpha/{name=projects/*/locations/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1alpha/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1alpha/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1alpha/{name=projects/*/locations/*}/operations',}]; + lroOptions.httpRules = [ + { + selector: 'google.cloud.location.Locations.GetLocation', + get: '/v1alpha/{name=projects/*/locations/*}', + }, + { + selector: 'google.cloud.location.Locations.ListLocations', + get: '/v1alpha/{name=projects/*}/locations', + }, + { + selector: 'google.iam.v1.IAMPolicy.GetIamPolicy', + get: '/v1alpha/{resource=projects/*/locations/*/memberships/*}:getIamPolicy', + additional_bindings: [ + { + get: '/v1alpha/{resource=projects/*/locations/*/features/*}:getIamPolicy', + }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.SetIamPolicy', + post: '/v1alpha/{resource=projects/*/locations/*/memberships/*}:setIamPolicy', + body: '*', + additional_bindings: [ + { + post: '/v1alpha/{resource=projects/*/locations/*/features/*}:setIamPolicy', + body: '*', + }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.TestIamPermissions', + post: '/v1alpha/{resource=projects/*/locations/*/memberships/*}:testIamPermissions', + body: '*', + additional_bindings: [ + { + post: '/v1alpha/{resource=projects/*/locations/*/features/*}:testIamPermissions', + body: '*', + }, + ], + }, + { + selector: 'google.longrunning.Operations.CancelOperation', + post: '/v1alpha/{name=projects/*/locations/*/operations/*}:cancel', + body: '*', + }, + { + selector: 'google.longrunning.Operations.DeleteOperation', + delete: '/v1alpha/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v1alpha/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v1alpha/{name=projects/*/locations/*}/operations', + }, + ]; } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); const createFeatureResponse = protoFilesRoot.lookup( - '.google.cloud.gkehub.v1alpha.Feature') as gax.protobuf.Type; + '.google.cloud.gkehub.v1alpha.Feature', + ) as gax.protobuf.Type; const createFeatureMetadata = protoFilesRoot.lookup( - '.google.cloud.gkehub.v1alpha.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.gkehub.v1alpha.OperationMetadata', + ) as gax.protobuf.Type; const deleteFeatureResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteFeatureMetadata = protoFilesRoot.lookup( - '.google.cloud.gkehub.v1alpha.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.gkehub.v1alpha.OperationMetadata', + ) as gax.protobuf.Type; const updateFeatureResponse = protoFilesRoot.lookup( - '.google.cloud.gkehub.v1alpha.Feature') as gax.protobuf.Type; + '.google.cloud.gkehub.v1alpha.Feature', + ) as gax.protobuf.Type; const updateFeatureMetadata = protoFilesRoot.lookup( - '.google.cloud.gkehub.v1alpha.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.gkehub.v1alpha.OperationMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { createFeature: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createFeatureResponse.decode.bind(createFeatureResponse), - createFeatureMetadata.decode.bind(createFeatureMetadata)), + createFeatureMetadata.decode.bind(createFeatureMetadata), + ), deleteFeature: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteFeatureResponse.decode.bind(deleteFeatureResponse), - deleteFeatureMetadata.decode.bind(deleteFeatureMetadata)), + deleteFeatureMetadata.decode.bind(deleteFeatureMetadata), + ), updateFeature: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateFeatureResponse.decode.bind(updateFeatureResponse), - updateFeatureMetadata.decode.bind(updateFeatureMetadata)) + updateFeatureMetadata.decode.bind(updateFeatureMetadata), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.gkehub.v1alpha.GkeHub', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.gkehub.v1alpha.GkeHub', + 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 @@ -282,28 +380,39 @@ export class GkeHubClient { // Put together the "service stub" for // google.cloud.gkehub.v1alpha.GkeHub. this.gkeHubStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.gkehub.v1alpha.GkeHub') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.gkehub.v1alpha.GkeHub', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.gkehub.v1alpha.GkeHub, - 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 gkeHubStubMethods = - ['listFeatures', 'getFeature', 'createFeature', 'deleteFeature', 'updateFeature']; + const gkeHubStubMethods = [ + 'listFeatures', + 'getFeature', + 'createFeature', + 'deleteFeature', + 'updateFeature', + ]; for (const methodName of gkeHubStubMethods) { const callPromise = this.gkeHubStub.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] || @@ -313,7 +422,7 @@ export class GkeHubClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -328,8 +437,14 @@ export class GkeHubClient { * @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 'gkehub.googleapis.com'; } @@ -340,8 +455,14 @@ export class GkeHubClient { * @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 'gkehub.googleapis.com'; } @@ -372,9 +493,7 @@ export class GkeHubClient { * @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; @@ -383,8 +502,9 @@ export class GkeHubClient { * 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; @@ -395,593 +515,838 @@ export class GkeHubClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Gets details of a single Feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The Feature resource name in the format - * `projects/* /locations/* /features/*` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.gkehub.v1alpha.Feature|Feature}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/gke_hub.get_feature.js - * region_tag:gkehub_v1alpha_generated_GkeHub_GetFeature_async - */ + /** + * Gets details of a single Feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The Feature resource name in the format + * `projects/* /locations/* /features/*` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.gkehub.v1alpha.Feature|Feature}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/gke_hub.get_feature.js + * region_tag:gkehub_v1alpha_generated_GkeHub_GetFeature_async + */ getFeature( - request?: protos.google.cloud.gkehub.v1alpha.IGetFeatureRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gkehub.v1alpha.IFeature, - protos.google.cloud.gkehub.v1alpha.IGetFeatureRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkehub.v1alpha.IGetFeatureRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gkehub.v1alpha.IFeature, + protos.google.cloud.gkehub.v1alpha.IGetFeatureRequest | undefined, + {} | undefined, + ] + >; getFeature( - request: protos.google.cloud.gkehub.v1alpha.IGetFeatureRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.gkehub.v1alpha.IFeature, - protos.google.cloud.gkehub.v1alpha.IGetFeatureRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1alpha.IGetFeatureRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.gkehub.v1alpha.IFeature, + protos.google.cloud.gkehub.v1alpha.IGetFeatureRequest | null | undefined, + {} | null | undefined + >, + ): void; getFeature( - request: protos.google.cloud.gkehub.v1alpha.IGetFeatureRequest, - callback: Callback< - protos.google.cloud.gkehub.v1alpha.IFeature, - protos.google.cloud.gkehub.v1alpha.IGetFeatureRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1alpha.IGetFeatureRequest, + callback: Callback< + protos.google.cloud.gkehub.v1alpha.IFeature, + protos.google.cloud.gkehub.v1alpha.IGetFeatureRequest | null | undefined, + {} | null | undefined + >, + ): void; getFeature( - request?: protos.google.cloud.gkehub.v1alpha.IGetFeatureRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.gkehub.v1alpha.IGetFeatureRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.gkehub.v1alpha.IFeature, - protos.google.cloud.gkehub.v1alpha.IGetFeatureRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.gkehub.v1alpha.IFeature, - protos.google.cloud.gkehub.v1alpha.IGetFeatureRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.gkehub.v1alpha.IFeature, - protos.google.cloud.gkehub.v1alpha.IGetFeatureRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.gkehub.v1alpha.IGetFeatureRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.gkehub.v1alpha.IFeature, + protos.google.cloud.gkehub.v1alpha.IGetFeatureRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.gkehub.v1alpha.IFeature, + protos.google.cloud.gkehub.v1alpha.IGetFeatureRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getFeature request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.gkehub.v1alpha.IFeature, - protos.google.cloud.gkehub.v1alpha.IGetFeatureRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.gkehub.v1alpha.IFeature, + | protos.google.cloud.gkehub.v1alpha.IGetFeatureRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getFeature response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getFeature(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.gkehub.v1alpha.IFeature, - protos.google.cloud.gkehub.v1alpha.IGetFeatureRequest|undefined, - {}|undefined - ]) => { - this._log.info('getFeature response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getFeature(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.gkehub.v1alpha.IFeature, + protos.google.cloud.gkehub.v1alpha.IGetFeatureRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getFeature response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 Feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * The parent (project and location) where the Feature will be created. - * Specified in the format `projects/* /locations/*`. - * @param {string} request.featureId - * The ID of the feature to create. - * @param {google.cloud.gkehub.v1alpha.Feature} request.resource - * The Feature resource to create. - * @param {string} [request.requestId] - * Optional. A request ID to identify requests. Specify a unique request ID - * so that if you must retry your request, the server will know to ignore - * the request if it has already been completed. The server will guarantee - * that for at least 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/gke_hub.create_feature.js - * region_tag:gkehub_v1alpha_generated_GkeHub_CreateFeature_async - */ + /** + * Adds a new Feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * The parent (project and location) where the Feature will be created. + * Specified in the format `projects/* /locations/*`. + * @param {string} request.featureId + * The ID of the feature to create. + * @param {google.cloud.gkehub.v1alpha.Feature} request.resource + * The Feature resource to create. + * @param {string} [request.requestId] + * Optional. A request ID to identify requests. Specify a unique request ID + * so that if you must retry your request, the server will know to ignore + * the request if it has already been completed. The server will guarantee + * that for at least 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/gke_hub.create_feature.js + * region_tag:gkehub_v1alpha_generated_GkeHub_CreateFeature_async + */ createFeature( - request?: protos.google.cloud.gkehub.v1alpha.ICreateFeatureRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkehub.v1alpha.ICreateFeatureRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.gkehub.v1alpha.IFeature, + protos.google.cloud.gkehub.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createFeature( - request: protos.google.cloud.gkehub.v1alpha.ICreateFeatureRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1alpha.ICreateFeatureRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.gkehub.v1alpha.IFeature, + protos.google.cloud.gkehub.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createFeature( - request: protos.google.cloud.gkehub.v1alpha.ICreateFeatureRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1alpha.ICreateFeatureRequest, + callback: Callback< + LROperation< + protos.google.cloud.gkehub.v1alpha.IFeature, + protos.google.cloud.gkehub.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createFeature( - request?: protos.google.cloud.gkehub.v1alpha.ICreateFeatureRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.gkehub.v1alpha.ICreateFeatureRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.gkehub.v1alpha.IFeature, + protos.google.cloud.gkehub.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.gkehub.v1alpha.IFeature, + protos.google.cloud.gkehub.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.gkehub.v1alpha.IFeature, + protos.google.cloud.gkehub.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.gkehub.v1alpha.IFeature, + protos.google.cloud.gkehub.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createFeature response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createFeature request %j', request); - return this.innerApiCalls.createFeature(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createFeature response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createFeature(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.gkehub.v1alpha.IFeature, + protos.google.cloud.gkehub.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createFeature response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createFeature()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/gke_hub.create_feature.js - * region_tag:gkehub_v1alpha_generated_GkeHub_CreateFeature_async - */ - async checkCreateFeatureProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createFeature()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/gke_hub.create_feature.js + * region_tag:gkehub_v1alpha_generated_GkeHub_CreateFeature_async + */ + async checkCreateFeatureProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.gkehub.v1alpha.Feature, + protos.google.cloud.gkehub.v1alpha.OperationMetadata + > + > { this._log.info('createFeature long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createFeature, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createFeature, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.gkehub.v1alpha.Feature, + protos.google.cloud.gkehub.v1alpha.OperationMetadata + >; } -/** - * Removes a Feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The Feature resource name in the format - * `projects/* /locations/* /features/*`. - * @param {boolean} request.force - * If set to true, the delete will ignore any outstanding resources for - * this Feature (that is, `FeatureState.has_resources` is set to true). These - * resources will NOT be cleaned up or modified in any way. - * @param {string} [request.requestId] - * Optional. A request ID to identify requests. Specify a unique request ID - * so that if you must retry your request, the server will know to ignore - * the request if it has already been completed. The server will guarantee - * that for at least 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/gke_hub.delete_feature.js - * region_tag:gkehub_v1alpha_generated_GkeHub_DeleteFeature_async - */ + /** + * Removes a Feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The Feature resource name in the format + * `projects/* /locations/* /features/*`. + * @param {boolean} request.force + * If set to true, the delete will ignore any outstanding resources for + * this Feature (that is, `FeatureState.has_resources` is set to true). These + * resources will NOT be cleaned up or modified in any way. + * @param {string} [request.requestId] + * Optional. A request ID to identify requests. Specify a unique request ID + * so that if you must retry your request, the server will know to ignore + * the request if it has already been completed. The server will guarantee + * that for at least 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/gke_hub.delete_feature.js + * region_tag:gkehub_v1alpha_generated_GkeHub_DeleteFeature_async + */ deleteFeature( - request?: protos.google.cloud.gkehub.v1alpha.IDeleteFeatureRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkehub.v1alpha.IDeleteFeatureRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteFeature( - request: protos.google.cloud.gkehub.v1alpha.IDeleteFeatureRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1alpha.IDeleteFeatureRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteFeature( - request: protos.google.cloud.gkehub.v1alpha.IDeleteFeatureRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1alpha.IDeleteFeatureRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteFeature( - request?: protos.google.cloud.gkehub.v1alpha.IDeleteFeatureRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.gkehub.v1alpha.IDeleteFeatureRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteFeature response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteFeature request %j', request); - return this.innerApiCalls.deleteFeature(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteFeature response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteFeature(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteFeature response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteFeature()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/gke_hub.delete_feature.js - * region_tag:gkehub_v1alpha_generated_GkeHub_DeleteFeature_async - */ - async checkDeleteFeatureProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteFeature()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/gke_hub.delete_feature.js + * region_tag:gkehub_v1alpha_generated_GkeHub_DeleteFeature_async + */ + async checkDeleteFeatureProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.gkehub.v1alpha.OperationMetadata + > + > { this._log.info('deleteFeature long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteFeature, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteFeature, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.gkehub.v1alpha.OperationMetadata + >; } -/** - * Updates an existing Feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The Feature resource name in the format - * `projects/* /locations/* /features/*`. - * @param {google.protobuf.FieldMask} request.updateMask - * Mask of fields to update. - * @param {google.cloud.gkehub.v1alpha.Feature} request.resource - * Only fields specified in update_mask are updated. - * If you specify a field in the update_mask but don't specify its value here - * that field will be deleted. - * If you are updating a map field, set the value of a key to null or empty - * string to delete the key from the map. It's not possible to update a key's - * value to the empty string. - * If you specify the update_mask to be a special path "*", fully replaces all - * user-modifiable fields to match `resource`. - * @param {string} [request.requestId] - * Optional. A request ID to identify requests. Specify a unique request ID - * so that if you must retry your request, the server will know to ignore - * the request if it has already been completed. The server will guarantee - * that for at least 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/gke_hub.update_feature.js - * region_tag:gkehub_v1alpha_generated_GkeHub_UpdateFeature_async - */ + /** + * Updates an existing Feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The Feature resource name in the format + * `projects/* /locations/* /features/*`. + * @param {google.protobuf.FieldMask} request.updateMask + * Mask of fields to update. + * @param {google.cloud.gkehub.v1alpha.Feature} request.resource + * Only fields specified in update_mask are updated. + * If you specify a field in the update_mask but don't specify its value here + * that field will be deleted. + * If you are updating a map field, set the value of a key to null or empty + * string to delete the key from the map. It's not possible to update a key's + * value to the empty string. + * If you specify the update_mask to be a special path "*", fully replaces all + * user-modifiable fields to match `resource`. + * @param {string} [request.requestId] + * Optional. A request ID to identify requests. Specify a unique request ID + * so that if you must retry your request, the server will know to ignore + * the request if it has already been completed. The server will guarantee + * that for at least 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/gke_hub.update_feature.js + * region_tag:gkehub_v1alpha_generated_GkeHub_UpdateFeature_async + */ updateFeature( - request?: protos.google.cloud.gkehub.v1alpha.IUpdateFeatureRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkehub.v1alpha.IUpdateFeatureRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.gkehub.v1alpha.IFeature, + protos.google.cloud.gkehub.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateFeature( - request: protos.google.cloud.gkehub.v1alpha.IUpdateFeatureRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1alpha.IUpdateFeatureRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.gkehub.v1alpha.IFeature, + protos.google.cloud.gkehub.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateFeature( - request: protos.google.cloud.gkehub.v1alpha.IUpdateFeatureRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1alpha.IUpdateFeatureRequest, + callback: Callback< + LROperation< + protos.google.cloud.gkehub.v1alpha.IFeature, + protos.google.cloud.gkehub.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateFeature( - request?: protos.google.cloud.gkehub.v1alpha.IUpdateFeatureRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.gkehub.v1alpha.IUpdateFeatureRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.gkehub.v1alpha.IFeature, + protos.google.cloud.gkehub.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.gkehub.v1alpha.IFeature, + protos.google.cloud.gkehub.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.gkehub.v1alpha.IFeature, + protos.google.cloud.gkehub.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.gkehub.v1alpha.IFeature, + protos.google.cloud.gkehub.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateFeature response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateFeature request %j', request); - return this.innerApiCalls.updateFeature(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateFeature response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateFeature(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.gkehub.v1alpha.IFeature, + protos.google.cloud.gkehub.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateFeature response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateFeature()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/gke_hub.update_feature.js - * region_tag:gkehub_v1alpha_generated_GkeHub_UpdateFeature_async - */ - async checkUpdateFeatureProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateFeature()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/gke_hub.update_feature.js + * region_tag:gkehub_v1alpha_generated_GkeHub_UpdateFeature_async + */ + async checkUpdateFeatureProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.gkehub.v1alpha.Feature, + protos.google.cloud.gkehub.v1alpha.OperationMetadata + > + > { this._log.info('updateFeature long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.updateFeature, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateFeature, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.gkehub.v1alpha.Feature, + protos.google.cloud.gkehub.v1alpha.OperationMetadata + >; } - /** - * Lists Features in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * The parent (project and location) where the Features will be listed. - * Specified in the format `projects/* /locations/*`. - * @param {number} request.pageSize - * When requesting a 'page' of resources, `page_size` specifies number of - * resources to return. If unspecified or set to 0, all resources will - * be returned. - * @param {string} request.pageToken - * Token returned by previous call to `ListFeatures` which - * specifies the position in the list from where to continue listing the - * resources. - * @param {string} request.filter - * Lists Features that match the filter expression, following the syntax - * outlined in https://google.aip.dev/160. - * - * Examples: - * - * - Feature with the name "servicemesh" in project "foo-proj": - * - * name = "projects/foo-proj/locations/global/features/servicemesh" - * - * - Features that have a label called `foo`: - * - * labels.foo:* - * - * - Features that have a label called `foo` whose value is `bar`: - * - * labels.foo = bar - * @param {string} request.orderBy - * One or more fields to compare and use to sort the output. - * See https://google.aip.dev/132#ordering. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link protos.google.cloud.gkehub.v1alpha.Feature|Feature}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listFeaturesAsync()` - * method described below for async iteration which you can stop as 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 Features in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * The parent (project and location) where the Features will be listed. + * Specified in the format `projects/* /locations/*`. + * @param {number} request.pageSize + * When requesting a 'page' of resources, `page_size` specifies number of + * resources to return. If unspecified or set to 0, all resources will + * be returned. + * @param {string} request.pageToken + * Token returned by previous call to `ListFeatures` which + * specifies the position in the list from where to continue listing the + * resources. + * @param {string} request.filter + * Lists Features that match the filter expression, following the syntax + * outlined in https://google.aip.dev/160. + * + * Examples: + * + * - Feature with the name "servicemesh" in project "foo-proj": + * + * name = "projects/foo-proj/locations/global/features/servicemesh" + * + * - Features that have a label called `foo`: + * + * labels.foo:* + * + * - Features that have a label called `foo` whose value is `bar`: + * + * labels.foo = bar + * @param {string} request.orderBy + * One or more fields to compare and use to sort the output. + * See https://google.aip.dev/132#ordering. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.gkehub.v1alpha.Feature|Feature}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listFeaturesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listFeatures( - request?: protos.google.cloud.gkehub.v1alpha.IListFeaturesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gkehub.v1alpha.IFeature[], - protos.google.cloud.gkehub.v1alpha.IListFeaturesRequest|null, - protos.google.cloud.gkehub.v1alpha.IListFeaturesResponse - ]>; + request?: protos.google.cloud.gkehub.v1alpha.IListFeaturesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gkehub.v1alpha.IFeature[], + protos.google.cloud.gkehub.v1alpha.IListFeaturesRequest | null, + protos.google.cloud.gkehub.v1alpha.IListFeaturesResponse, + ] + >; listFeatures( - request: protos.google.cloud.gkehub.v1alpha.IListFeaturesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.gkehub.v1alpha.IListFeaturesRequest, - protos.google.cloud.gkehub.v1alpha.IListFeaturesResponse|null|undefined, - protos.google.cloud.gkehub.v1alpha.IFeature>): void; + request: protos.google.cloud.gkehub.v1alpha.IListFeaturesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.gkehub.v1alpha.IListFeaturesRequest, + | protos.google.cloud.gkehub.v1alpha.IListFeaturesResponse + | null + | undefined, + protos.google.cloud.gkehub.v1alpha.IFeature + >, + ): void; listFeatures( - request: protos.google.cloud.gkehub.v1alpha.IListFeaturesRequest, - callback: PaginationCallback< - protos.google.cloud.gkehub.v1alpha.IListFeaturesRequest, - protos.google.cloud.gkehub.v1alpha.IListFeaturesResponse|null|undefined, - protos.google.cloud.gkehub.v1alpha.IFeature>): void; + request: protos.google.cloud.gkehub.v1alpha.IListFeaturesRequest, + callback: PaginationCallback< + protos.google.cloud.gkehub.v1alpha.IListFeaturesRequest, + | protos.google.cloud.gkehub.v1alpha.IListFeaturesResponse + | null + | undefined, + protos.google.cloud.gkehub.v1alpha.IFeature + >, + ): void; listFeatures( - request?: protos.google.cloud.gkehub.v1alpha.IListFeaturesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< + request?: protos.google.cloud.gkehub.v1alpha.IListFeaturesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.gkehub.v1alpha.IListFeaturesRequest, - protos.google.cloud.gkehub.v1alpha.IListFeaturesResponse|null|undefined, - protos.google.cloud.gkehub.v1alpha.IFeature>, - callback?: PaginationCallback< - protos.google.cloud.gkehub.v1alpha.IListFeaturesRequest, - protos.google.cloud.gkehub.v1alpha.IListFeaturesResponse|null|undefined, - protos.google.cloud.gkehub.v1alpha.IFeature>): - Promise<[ - protos.google.cloud.gkehub.v1alpha.IFeature[], - protos.google.cloud.gkehub.v1alpha.IListFeaturesRequest|null, - protos.google.cloud.gkehub.v1alpha.IListFeaturesResponse - ]>|void { + | protos.google.cloud.gkehub.v1alpha.IListFeaturesResponse + | null + | undefined, + protos.google.cloud.gkehub.v1alpha.IFeature + >, + callback?: PaginationCallback< + protos.google.cloud.gkehub.v1alpha.IListFeaturesRequest, + | protos.google.cloud.gkehub.v1alpha.IListFeaturesResponse + | null + | undefined, + protos.google.cloud.gkehub.v1alpha.IFeature + >, + ): Promise< + [ + protos.google.cloud.gkehub.v1alpha.IFeature[], + protos.google.cloud.gkehub.v1alpha.IListFeaturesRequest | null, + protos.google.cloud.gkehub.v1alpha.IListFeaturesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-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.gkehub.v1alpha.IListFeaturesRequest, - protos.google.cloud.gkehub.v1alpha.IListFeaturesResponse|null|undefined, - protos.google.cloud.gkehub.v1alpha.IFeature>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.gkehub.v1alpha.IListFeaturesRequest, + | protos.google.cloud.gkehub.v1alpha.IListFeaturesResponse + | null + | undefined, + protos.google.cloud.gkehub.v1alpha.IFeature + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listFeatures values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -990,156 +1355,160 @@ export class GkeHubClient { this._log.info('listFeatures request %j', request); return this.innerApiCalls .listFeatures(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.gkehub.v1alpha.IFeature[], - protos.google.cloud.gkehub.v1alpha.IListFeaturesRequest|null, - protos.google.cloud.gkehub.v1alpha.IListFeaturesResponse - ]) => { - this._log.info('listFeatures values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.gkehub.v1alpha.IFeature[], + protos.google.cloud.gkehub.v1alpha.IListFeaturesRequest | null, + protos.google.cloud.gkehub.v1alpha.IListFeaturesResponse, + ]) => { + this._log.info('listFeatures values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listFeatures`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * The parent (project and location) where the Features will be listed. - * Specified in the format `projects/* /locations/*`. - * @param {number} request.pageSize - * When requesting a 'page' of resources, `page_size` specifies number of - * resources to return. If unspecified or set to 0, all resources will - * be returned. - * @param {string} request.pageToken - * Token returned by previous call to `ListFeatures` which - * specifies the position in the list from where to continue listing the - * resources. - * @param {string} request.filter - * Lists Features that match the filter expression, following the syntax - * outlined in https://google.aip.dev/160. - * - * Examples: - * - * - Feature with the name "servicemesh" in project "foo-proj": - * - * name = "projects/foo-proj/locations/global/features/servicemesh" - * - * - Features that have a label called `foo`: - * - * labels.foo:* - * - * - Features that have a label called `foo` whose value is `bar`: - * - * labels.foo = bar - * @param {string} request.orderBy - * One or more fields to compare and use to sort the output. - * See https://google.aip.dev/132#ordering. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.gkehub.v1alpha.Feature|Feature} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listFeaturesAsync()` - * method described below for async iteration which you can stop as 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 `listFeatures`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * The parent (project and location) where the Features will be listed. + * Specified in the format `projects/* /locations/*`. + * @param {number} request.pageSize + * When requesting a 'page' of resources, `page_size` specifies number of + * resources to return. If unspecified or set to 0, all resources will + * be returned. + * @param {string} request.pageToken + * Token returned by previous call to `ListFeatures` which + * specifies the position in the list from where to continue listing the + * resources. + * @param {string} request.filter + * Lists Features that match the filter expression, following the syntax + * outlined in https://google.aip.dev/160. + * + * Examples: + * + * - Feature with the name "servicemesh" in project "foo-proj": + * + * name = "projects/foo-proj/locations/global/features/servicemesh" + * + * - Features that have a label called `foo`: + * + * labels.foo:* + * + * - Features that have a label called `foo` whose value is `bar`: + * + * labels.foo = bar + * @param {string} request.orderBy + * One or more fields to compare and use to sort the output. + * See https://google.aip.dev/132#ordering. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.gkehub.v1alpha.Feature|Feature} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listFeaturesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listFeaturesStream( - request?: protos.google.cloud.gkehub.v1alpha.IListFeaturesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.gkehub.v1alpha.IListFeaturesRequest, + 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['listFeatures']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listFeatures stream %j', request); return this.descriptors.page.listFeatures.createStream( this.innerApiCalls.listFeatures as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listFeatures`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is 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 parent (project and location) where the Features will be listed. - * Specified in the format `projects/* /locations/*`. - * @param {number} request.pageSize - * When requesting a 'page' of resources, `page_size` specifies number of - * resources to return. If unspecified or set to 0, all resources will - * be returned. - * @param {string} request.pageToken - * Token returned by previous call to `ListFeatures` which - * specifies the position in the list from where to continue listing the - * resources. - * @param {string} request.filter - * Lists Features that match the filter expression, following the syntax - * outlined in https://google.aip.dev/160. - * - * Examples: - * - * - Feature with the name "servicemesh" in project "foo-proj": - * - * name = "projects/foo-proj/locations/global/features/servicemesh" - * - * - Features that have a label called `foo`: - * - * labels.foo:* - * - * - Features that have a label called `foo` whose value is `bar`: - * - * labels.foo = bar - * @param {string} request.orderBy - * One or more fields to compare and use to sort the output. - * See https://google.aip.dev/132#ordering. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.gkehub.v1alpha.Feature|Feature}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/gke_hub.list_features.js - * region_tag:gkehub_v1alpha_generated_GkeHub_ListFeatures_async - */ + /** + * Equivalent to `listFeatures`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is 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 parent (project and location) where the Features will be listed. + * Specified in the format `projects/* /locations/*`. + * @param {number} request.pageSize + * When requesting a 'page' of resources, `page_size` specifies number of + * resources to return. If unspecified or set to 0, all resources will + * be returned. + * @param {string} request.pageToken + * Token returned by previous call to `ListFeatures` which + * specifies the position in the list from where to continue listing the + * resources. + * @param {string} request.filter + * Lists Features that match the filter expression, following the syntax + * outlined in https://google.aip.dev/160. + * + * Examples: + * + * - Feature with the name "servicemesh" in project "foo-proj": + * + * name = "projects/foo-proj/locations/global/features/servicemesh" + * + * - Features that have a label called `foo`: + * + * labels.foo:* + * + * - Features that have a label called `foo` whose value is `bar`: + * + * labels.foo = bar + * @param {string} request.orderBy + * One or more fields to compare and use to sort the output. + * See https://google.aip.dev/132#ordering. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.gkehub.v1alpha.Feature|Feature}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/gke_hub.list_features.js + * region_tag:gkehub_v1alpha_generated_GkeHub_ListFeatures_async + */ listFeaturesAsync( - request?: protos.google.cloud.gkehub.v1alpha.IListFeaturesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.gkehub.v1alpha.IListFeaturesRequest, + 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['listFeatures']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listFeatures iterate %j', request); return this.descriptors.page.listFeatures.asyncIterate( this.innerApiCalls['listFeatures'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } // -------------------- @@ -1154,7 +1523,7 @@ export class GkeHubClient { * @param {string} feature * @returns {string} Resource name string. */ - featurePath(project:string,location:string,feature:string) { + featurePath(project: string, location: string, feature: string) { return this.pathTemplates.featurePathTemplate.render({ project: project, location: location, @@ -1203,7 +1572,7 @@ export class GkeHubClient { */ close(): Promise { if (this.gkeHubStub && !this._terminated) { - return this.gkeHubStub.then(stub => { + return this.gkeHubStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); @@ -1212,4 +1581,4 @@ export class GkeHubClient { } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-gkehub/src/v1alpha/index.ts b/packages/google-cloud-gkehub/src/v1alpha/index.ts index 5512785d3fb8..ea1c8a89881c 100644 --- a/packages/google-cloud-gkehub/src/v1alpha/index.ts +++ b/packages/google-cloud-gkehub/src/v1alpha/index.ts @@ -16,4 +16,4 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {GkeHubClient} from './gke_hub_client'; +export { GkeHubClient } from './gke_hub_client'; diff --git a/packages/google-cloud-gkehub/src/v1beta/gke_hub_client.ts b/packages/google-cloud-gkehub/src/v1beta/gke_hub_client.ts index f35c7c60b261..7b566f574643 100644 --- a/packages/google-cloud-gkehub/src/v1beta/gke_hub_client.ts +++ b/packages/google-cloud-gkehub/src/v1beta/gke_hub_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 @@ -57,7 +66,7 @@ export class GkeHubClient { 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('gke-hub'); @@ -70,10 +79,10 @@ export class GkeHubClient { 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; - gkeHubStub?: Promise<{[name: string]: Function}>; + gkeHubStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of GkeHubClient. @@ -114,21 +123,42 @@ export class GkeHubClient { * const client = new GkeHubClient({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 GkeHubClient; - 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 = 'gkehub.' + 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; @@ -153,7 +183,7 @@ export class GkeHubClient { this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; // Set useJWTAccessWithScope on the auth object. this.auth.useJWTAccessWithScope = true; @@ -167,10 +197,7 @@ export class GkeHubClient { } // 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 { @@ -192,7 +219,7 @@ export class GkeHubClient { // Create useful helper objects for these. this.pathTemplates = { featurePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/features/{feature}' + 'projects/{project}/locations/{location}/features/{feature}', ), }; @@ -200,8 +227,11 @@ export class GkeHubClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listFeatures: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'resources') + listFeatures: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'resources', + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -210,48 +240,116 @@ export class GkeHubClient { // rather than holding a request open. const lroOptions: GrpcClientOptions = { auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1beta/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1beta/{name=projects/*}/locations',},{selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',get: '/v1beta/{resource=projects/*/locations/*/memberships/*}:getIamPolicy',additional_bindings: [{get: '/v1beta/{resource=projects/*/locations/*/features/*}:getIamPolicy',}], - },{selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',post: '/v1beta/{resource=projects/*/locations/*/memberships/*}:setIamPolicy',body: '*',additional_bindings: [{post: '/v1beta/{resource=projects/*/locations/*/features/*}:setIamPolicy',body: '*',}], - },{selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',post: '/v1beta/{resource=projects/*/locations/*/memberships/*}:testIamPermissions',body: '*',additional_bindings: [{post: '/v1beta/{resource=projects/*/locations/*/features/*}:testIamPermissions',body: '*',}], - },{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1beta/{name=projects/*/locations/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1beta/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1beta/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1beta/{name=projects/*/locations/*}/operations',}]; + lroOptions.httpRules = [ + { + selector: 'google.cloud.location.Locations.GetLocation', + get: '/v1beta/{name=projects/*/locations/*}', + }, + { + selector: 'google.cloud.location.Locations.ListLocations', + get: '/v1beta/{name=projects/*}/locations', + }, + { + selector: 'google.iam.v1.IAMPolicy.GetIamPolicy', + get: '/v1beta/{resource=projects/*/locations/*/memberships/*}:getIamPolicy', + additional_bindings: [ + { + get: '/v1beta/{resource=projects/*/locations/*/features/*}:getIamPolicy', + }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.SetIamPolicy', + post: '/v1beta/{resource=projects/*/locations/*/memberships/*}:setIamPolicy', + body: '*', + additional_bindings: [ + { + post: '/v1beta/{resource=projects/*/locations/*/features/*}:setIamPolicy', + body: '*', + }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.TestIamPermissions', + post: '/v1beta/{resource=projects/*/locations/*/memberships/*}:testIamPermissions', + body: '*', + additional_bindings: [ + { + post: '/v1beta/{resource=projects/*/locations/*/features/*}:testIamPermissions', + body: '*', + }, + ], + }, + { + selector: 'google.longrunning.Operations.CancelOperation', + post: '/v1beta/{name=projects/*/locations/*/operations/*}:cancel', + body: '*', + }, + { + selector: 'google.longrunning.Operations.DeleteOperation', + delete: '/v1beta/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v1beta/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v1beta/{name=projects/*/locations/*}/operations', + }, + ]; } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); const createFeatureResponse = protoFilesRoot.lookup( - '.google.cloud.gkehub.v1beta.Feature') as gax.protobuf.Type; + '.google.cloud.gkehub.v1beta.Feature', + ) as gax.protobuf.Type; const createFeatureMetadata = protoFilesRoot.lookup( - '.google.cloud.gkehub.v1beta.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.gkehub.v1beta.OperationMetadata', + ) as gax.protobuf.Type; const deleteFeatureResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteFeatureMetadata = protoFilesRoot.lookup( - '.google.cloud.gkehub.v1beta.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.gkehub.v1beta.OperationMetadata', + ) as gax.protobuf.Type; const updateFeatureResponse = protoFilesRoot.lookup( - '.google.cloud.gkehub.v1beta.Feature') as gax.protobuf.Type; + '.google.cloud.gkehub.v1beta.Feature', + ) as gax.protobuf.Type; const updateFeatureMetadata = protoFilesRoot.lookup( - '.google.cloud.gkehub.v1beta.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.gkehub.v1beta.OperationMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { createFeature: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createFeatureResponse.decode.bind(createFeatureResponse), - createFeatureMetadata.decode.bind(createFeatureMetadata)), + createFeatureMetadata.decode.bind(createFeatureMetadata), + ), deleteFeature: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteFeatureResponse.decode.bind(deleteFeatureResponse), - deleteFeatureMetadata.decode.bind(deleteFeatureMetadata)), + deleteFeatureMetadata.decode.bind(deleteFeatureMetadata), + ), updateFeature: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateFeatureResponse.decode.bind(updateFeatureResponse), - updateFeatureMetadata.decode.bind(updateFeatureMetadata)) + updateFeatureMetadata.decode.bind(updateFeatureMetadata), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.gkehub.v1beta.GkeHub', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.gkehub.v1beta.GkeHub', + 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 @@ -282,28 +380,39 @@ export class GkeHubClient { // Put together the "service stub" for // google.cloud.gkehub.v1beta.GkeHub. this.gkeHubStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.gkehub.v1beta.GkeHub') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.gkehub.v1beta.GkeHub', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.gkehub.v1beta.GkeHub, - 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 gkeHubStubMethods = - ['listFeatures', 'getFeature', 'createFeature', 'deleteFeature', 'updateFeature']; + const gkeHubStubMethods = [ + 'listFeatures', + 'getFeature', + 'createFeature', + 'deleteFeature', + 'updateFeature', + ]; for (const methodName of gkeHubStubMethods) { const callPromise = this.gkeHubStub.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] || @@ -313,7 +422,7 @@ export class GkeHubClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -328,8 +437,14 @@ export class GkeHubClient { * @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 'gkehub.googleapis.com'; } @@ -340,8 +455,14 @@ export class GkeHubClient { * @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 'gkehub.googleapis.com'; } @@ -372,9 +493,7 @@ export class GkeHubClient { * @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; @@ -383,8 +502,9 @@ export class GkeHubClient { * 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; @@ -395,593 +515,838 @@ export class GkeHubClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Gets details of a single Feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The Feature resource name in the format - * `projects/* /locations/* /features/*` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.gkehub.v1beta.Feature|Feature}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/gke_hub.get_feature.js - * region_tag:gkehub_v1beta_generated_GkeHub_GetFeature_async - */ + /** + * Gets details of a single Feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The Feature resource name in the format + * `projects/* /locations/* /features/*` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.gkehub.v1beta.Feature|Feature}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/gke_hub.get_feature.js + * region_tag:gkehub_v1beta_generated_GkeHub_GetFeature_async + */ getFeature( - request?: protos.google.cloud.gkehub.v1beta.IGetFeatureRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gkehub.v1beta.IFeature, - protos.google.cloud.gkehub.v1beta.IGetFeatureRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkehub.v1beta.IGetFeatureRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gkehub.v1beta.IFeature, + protos.google.cloud.gkehub.v1beta.IGetFeatureRequest | undefined, + {} | undefined, + ] + >; getFeature( - request: protos.google.cloud.gkehub.v1beta.IGetFeatureRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.gkehub.v1beta.IFeature, - protos.google.cloud.gkehub.v1beta.IGetFeatureRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1beta.IGetFeatureRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.gkehub.v1beta.IFeature, + protos.google.cloud.gkehub.v1beta.IGetFeatureRequest | null | undefined, + {} | null | undefined + >, + ): void; getFeature( - request: protos.google.cloud.gkehub.v1beta.IGetFeatureRequest, - callback: Callback< - protos.google.cloud.gkehub.v1beta.IFeature, - protos.google.cloud.gkehub.v1beta.IGetFeatureRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1beta.IGetFeatureRequest, + callback: Callback< + protos.google.cloud.gkehub.v1beta.IFeature, + protos.google.cloud.gkehub.v1beta.IGetFeatureRequest | null | undefined, + {} | null | undefined + >, + ): void; getFeature( - request?: protos.google.cloud.gkehub.v1beta.IGetFeatureRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.gkehub.v1beta.IGetFeatureRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.gkehub.v1beta.IFeature, - protos.google.cloud.gkehub.v1beta.IGetFeatureRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.gkehub.v1beta.IFeature, - protos.google.cloud.gkehub.v1beta.IGetFeatureRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.gkehub.v1beta.IFeature, - protos.google.cloud.gkehub.v1beta.IGetFeatureRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.gkehub.v1beta.IGetFeatureRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.gkehub.v1beta.IFeature, + protos.google.cloud.gkehub.v1beta.IGetFeatureRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.gkehub.v1beta.IFeature, + protos.google.cloud.gkehub.v1beta.IGetFeatureRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getFeature request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.gkehub.v1beta.IFeature, - protos.google.cloud.gkehub.v1beta.IGetFeatureRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.gkehub.v1beta.IFeature, + | protos.google.cloud.gkehub.v1beta.IGetFeatureRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getFeature response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getFeature(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.gkehub.v1beta.IFeature, - protos.google.cloud.gkehub.v1beta.IGetFeatureRequest|undefined, - {}|undefined - ]) => { - this._log.info('getFeature response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getFeature(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.gkehub.v1beta.IFeature, + protos.google.cloud.gkehub.v1beta.IGetFeatureRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getFeature response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 Feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * The parent (project and location) where the Feature will be created. - * Specified in the format `projects/* /locations/*`. - * @param {string} request.featureId - * The ID of the feature to create. - * @param {google.cloud.gkehub.v1beta.Feature} request.resource - * The Feature resource to create. - * @param {string} [request.requestId] - * Optional. A request ID to identify requests. Specify a unique request ID - * so that if you must retry your request, the server will know to ignore - * the request if it has already been completed. The server will guarantee - * that for at least 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/gke_hub.create_feature.js - * region_tag:gkehub_v1beta_generated_GkeHub_CreateFeature_async - */ + /** + * Adds a new Feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * The parent (project and location) where the Feature will be created. + * Specified in the format `projects/* /locations/*`. + * @param {string} request.featureId + * The ID of the feature to create. + * @param {google.cloud.gkehub.v1beta.Feature} request.resource + * The Feature resource to create. + * @param {string} [request.requestId] + * Optional. A request ID to identify requests. Specify a unique request ID + * so that if you must retry your request, the server will know to ignore + * the request if it has already been completed. The server will guarantee + * that for at least 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/gke_hub.create_feature.js + * region_tag:gkehub_v1beta_generated_GkeHub_CreateFeature_async + */ createFeature( - request?: protos.google.cloud.gkehub.v1beta.ICreateFeatureRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkehub.v1beta.ICreateFeatureRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.gkehub.v1beta.IFeature, + protos.google.cloud.gkehub.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createFeature( - request: protos.google.cloud.gkehub.v1beta.ICreateFeatureRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1beta.ICreateFeatureRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.gkehub.v1beta.IFeature, + protos.google.cloud.gkehub.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createFeature( - request: protos.google.cloud.gkehub.v1beta.ICreateFeatureRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1beta.ICreateFeatureRequest, + callback: Callback< + LROperation< + protos.google.cloud.gkehub.v1beta.IFeature, + protos.google.cloud.gkehub.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createFeature( - request?: protos.google.cloud.gkehub.v1beta.ICreateFeatureRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.gkehub.v1beta.ICreateFeatureRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.gkehub.v1beta.IFeature, + protos.google.cloud.gkehub.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.gkehub.v1beta.IFeature, + protos.google.cloud.gkehub.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.gkehub.v1beta.IFeature, + protos.google.cloud.gkehub.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.gkehub.v1beta.IFeature, + protos.google.cloud.gkehub.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createFeature response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createFeature request %j', request); - return this.innerApiCalls.createFeature(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createFeature response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createFeature(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.gkehub.v1beta.IFeature, + protos.google.cloud.gkehub.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createFeature response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createFeature()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/gke_hub.create_feature.js - * region_tag:gkehub_v1beta_generated_GkeHub_CreateFeature_async - */ - async checkCreateFeatureProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createFeature()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/gke_hub.create_feature.js + * region_tag:gkehub_v1beta_generated_GkeHub_CreateFeature_async + */ + async checkCreateFeatureProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.gkehub.v1beta.Feature, + protos.google.cloud.gkehub.v1beta.OperationMetadata + > + > { this._log.info('createFeature long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createFeature, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createFeature, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.gkehub.v1beta.Feature, + protos.google.cloud.gkehub.v1beta.OperationMetadata + >; } -/** - * Removes a Feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The Feature resource name in the format - * `projects/* /locations/* /features/*`. - * @param {boolean} request.force - * If set to true, the delete will ignore any outstanding resources for - * this Feature (that is, `FeatureState.has_resources` is set to true). These - * resources will NOT be cleaned up or modified in any way. - * @param {string} [request.requestId] - * Optional. A request ID to identify requests. Specify a unique request ID - * so that if you must retry your request, the server will know to ignore - * the request if it has already been completed. The server will guarantee - * that for at least 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/gke_hub.delete_feature.js - * region_tag:gkehub_v1beta_generated_GkeHub_DeleteFeature_async - */ + /** + * Removes a Feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The Feature resource name in the format + * `projects/* /locations/* /features/*`. + * @param {boolean} request.force + * If set to true, the delete will ignore any outstanding resources for + * this Feature (that is, `FeatureState.has_resources` is set to true). These + * resources will NOT be cleaned up or modified in any way. + * @param {string} [request.requestId] + * Optional. A request ID to identify requests. Specify a unique request ID + * so that if you must retry your request, the server will know to ignore + * the request if it has already been completed. The server will guarantee + * that for at least 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/gke_hub.delete_feature.js + * region_tag:gkehub_v1beta_generated_GkeHub_DeleteFeature_async + */ deleteFeature( - request?: protos.google.cloud.gkehub.v1beta.IDeleteFeatureRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkehub.v1beta.IDeleteFeatureRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteFeature( - request: protos.google.cloud.gkehub.v1beta.IDeleteFeatureRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1beta.IDeleteFeatureRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteFeature( - request: protos.google.cloud.gkehub.v1beta.IDeleteFeatureRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1beta.IDeleteFeatureRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteFeature( - request?: protos.google.cloud.gkehub.v1beta.IDeleteFeatureRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.gkehub.v1beta.IDeleteFeatureRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteFeature response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteFeature request %j', request); - return this.innerApiCalls.deleteFeature(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteFeature response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteFeature(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteFeature response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteFeature()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/gke_hub.delete_feature.js - * region_tag:gkehub_v1beta_generated_GkeHub_DeleteFeature_async - */ - async checkDeleteFeatureProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteFeature()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/gke_hub.delete_feature.js + * region_tag:gkehub_v1beta_generated_GkeHub_DeleteFeature_async + */ + async checkDeleteFeatureProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.gkehub.v1beta.OperationMetadata + > + > { this._log.info('deleteFeature long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteFeature, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteFeature, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.gkehub.v1beta.OperationMetadata + >; } -/** - * Updates an existing Feature. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The Feature resource name in the format - * `projects/* /locations/* /features/*`. - * @param {google.protobuf.FieldMask} request.updateMask - * Mask of fields to update. - * @param {google.cloud.gkehub.v1beta.Feature} request.resource - * Only fields specified in update_mask are updated. - * If you specify a field in the update_mask but don't specify its value here - * that field will be deleted. - * If you are updating a map field, set the value of a key to null or empty - * string to delete the key from the map. It's not possible to update a key's - * value to the empty string. - * If you specify the update_mask to be a special path "*", fully replaces all - * user-modifiable fields to match `resource`. - * @param {string} [request.requestId] - * Optional. A request ID to identify requests. Specify a unique request ID - * so that if you must retry your request, the server will know to ignore - * the request if it has already been completed. The server will guarantee - * that for at least 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/gke_hub.update_feature.js - * region_tag:gkehub_v1beta_generated_GkeHub_UpdateFeature_async - */ + /** + * Updates an existing Feature. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The Feature resource name in the format + * `projects/* /locations/* /features/*`. + * @param {google.protobuf.FieldMask} request.updateMask + * Mask of fields to update. + * @param {google.cloud.gkehub.v1beta.Feature} request.resource + * Only fields specified in update_mask are updated. + * If you specify a field in the update_mask but don't specify its value here + * that field will be deleted. + * If you are updating a map field, set the value of a key to null or empty + * string to delete the key from the map. It's not possible to update a key's + * value to the empty string. + * If you specify the update_mask to be a special path "*", fully replaces all + * user-modifiable fields to match `resource`. + * @param {string} [request.requestId] + * Optional. A request ID to identify requests. Specify a unique request ID + * so that if you must retry your request, the server will know to ignore + * the request if it has already been completed. The server will guarantee + * that for at least 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/gke_hub.update_feature.js + * region_tag:gkehub_v1beta_generated_GkeHub_UpdateFeature_async + */ updateFeature( - request?: protos.google.cloud.gkehub.v1beta.IUpdateFeatureRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkehub.v1beta.IUpdateFeatureRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.gkehub.v1beta.IFeature, + protos.google.cloud.gkehub.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateFeature( - request: protos.google.cloud.gkehub.v1beta.IUpdateFeatureRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1beta.IUpdateFeatureRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.gkehub.v1beta.IFeature, + protos.google.cloud.gkehub.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateFeature( - request: protos.google.cloud.gkehub.v1beta.IUpdateFeatureRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1beta.IUpdateFeatureRequest, + callback: Callback< + LROperation< + protos.google.cloud.gkehub.v1beta.IFeature, + protos.google.cloud.gkehub.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateFeature( - request?: protos.google.cloud.gkehub.v1beta.IUpdateFeatureRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.gkehub.v1beta.IUpdateFeatureRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.gkehub.v1beta.IFeature, + protos.google.cloud.gkehub.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.gkehub.v1beta.IFeature, + protos.google.cloud.gkehub.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.gkehub.v1beta.IFeature, + protos.google.cloud.gkehub.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.gkehub.v1beta.IFeature, + protos.google.cloud.gkehub.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateFeature response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateFeature request %j', request); - return this.innerApiCalls.updateFeature(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateFeature response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateFeature(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.gkehub.v1beta.IFeature, + protos.google.cloud.gkehub.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateFeature response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateFeature()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/gke_hub.update_feature.js - * region_tag:gkehub_v1beta_generated_GkeHub_UpdateFeature_async - */ - async checkUpdateFeatureProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateFeature()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/gke_hub.update_feature.js + * region_tag:gkehub_v1beta_generated_GkeHub_UpdateFeature_async + */ + async checkUpdateFeatureProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.gkehub.v1beta.Feature, + protos.google.cloud.gkehub.v1beta.OperationMetadata + > + > { this._log.info('updateFeature long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.updateFeature, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateFeature, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.gkehub.v1beta.Feature, + protos.google.cloud.gkehub.v1beta.OperationMetadata + >; } - /** - * Lists Features in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * The parent (project and location) where the Features will be listed. - * Specified in the format `projects/* /locations/*`. - * @param {number} request.pageSize - * When requesting a 'page' of resources, `page_size` specifies number of - * resources to return. If unspecified or set to 0, all resources will - * be returned. - * @param {string} request.pageToken - * Token returned by previous call to `ListFeatures` which - * specifies the position in the list from where to continue listing the - * resources. - * @param {string} request.filter - * Lists Features that match the filter expression, following the syntax - * outlined in https://google.aip.dev/160. - * - * Examples: - * - * - Feature with the name "servicemesh" in project "foo-proj": - * - * name = "projects/foo-proj/locations/global/features/servicemesh" - * - * - Features that have a label called `foo`: - * - * labels.foo:* - * - * - Features that have a label called `foo` whose value is `bar`: - * - * labels.foo = bar - * @param {string} request.orderBy - * One or more fields to compare and use to sort the output. - * See https://google.aip.dev/132#ordering. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link protos.google.cloud.gkehub.v1beta.Feature|Feature}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listFeaturesAsync()` - * method described below for async iteration which you can stop as 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 Features in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * The parent (project and location) where the Features will be listed. + * Specified in the format `projects/* /locations/*`. + * @param {number} request.pageSize + * When requesting a 'page' of resources, `page_size` specifies number of + * resources to return. If unspecified or set to 0, all resources will + * be returned. + * @param {string} request.pageToken + * Token returned by previous call to `ListFeatures` which + * specifies the position in the list from where to continue listing the + * resources. + * @param {string} request.filter + * Lists Features that match the filter expression, following the syntax + * outlined in https://google.aip.dev/160. + * + * Examples: + * + * - Feature with the name "servicemesh" in project "foo-proj": + * + * name = "projects/foo-proj/locations/global/features/servicemesh" + * + * - Features that have a label called `foo`: + * + * labels.foo:* + * + * - Features that have a label called `foo` whose value is `bar`: + * + * labels.foo = bar + * @param {string} request.orderBy + * One or more fields to compare and use to sort the output. + * See https://google.aip.dev/132#ordering. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.gkehub.v1beta.Feature|Feature}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listFeaturesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listFeatures( - request?: protos.google.cloud.gkehub.v1beta.IListFeaturesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gkehub.v1beta.IFeature[], - protos.google.cloud.gkehub.v1beta.IListFeaturesRequest|null, - protos.google.cloud.gkehub.v1beta.IListFeaturesResponse - ]>; + request?: protos.google.cloud.gkehub.v1beta.IListFeaturesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gkehub.v1beta.IFeature[], + protos.google.cloud.gkehub.v1beta.IListFeaturesRequest | null, + protos.google.cloud.gkehub.v1beta.IListFeaturesResponse, + ] + >; listFeatures( - request: protos.google.cloud.gkehub.v1beta.IListFeaturesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.gkehub.v1beta.IListFeaturesRequest, - protos.google.cloud.gkehub.v1beta.IListFeaturesResponse|null|undefined, - protos.google.cloud.gkehub.v1beta.IFeature>): void; + request: protos.google.cloud.gkehub.v1beta.IListFeaturesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.gkehub.v1beta.IListFeaturesRequest, + | protos.google.cloud.gkehub.v1beta.IListFeaturesResponse + | null + | undefined, + protos.google.cloud.gkehub.v1beta.IFeature + >, + ): void; listFeatures( - request: protos.google.cloud.gkehub.v1beta.IListFeaturesRequest, - callback: PaginationCallback< - protos.google.cloud.gkehub.v1beta.IListFeaturesRequest, - protos.google.cloud.gkehub.v1beta.IListFeaturesResponse|null|undefined, - protos.google.cloud.gkehub.v1beta.IFeature>): void; + request: protos.google.cloud.gkehub.v1beta.IListFeaturesRequest, + callback: PaginationCallback< + protos.google.cloud.gkehub.v1beta.IListFeaturesRequest, + | protos.google.cloud.gkehub.v1beta.IListFeaturesResponse + | null + | undefined, + protos.google.cloud.gkehub.v1beta.IFeature + >, + ): void; listFeatures( - request?: protos.google.cloud.gkehub.v1beta.IListFeaturesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< + request?: protos.google.cloud.gkehub.v1beta.IListFeaturesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.gkehub.v1beta.IListFeaturesRequest, - protos.google.cloud.gkehub.v1beta.IListFeaturesResponse|null|undefined, - protos.google.cloud.gkehub.v1beta.IFeature>, - callback?: PaginationCallback< - protos.google.cloud.gkehub.v1beta.IListFeaturesRequest, - protos.google.cloud.gkehub.v1beta.IListFeaturesResponse|null|undefined, - protos.google.cloud.gkehub.v1beta.IFeature>): - Promise<[ - protos.google.cloud.gkehub.v1beta.IFeature[], - protos.google.cloud.gkehub.v1beta.IListFeaturesRequest|null, - protos.google.cloud.gkehub.v1beta.IListFeaturesResponse - ]>|void { + | protos.google.cloud.gkehub.v1beta.IListFeaturesResponse + | null + | undefined, + protos.google.cloud.gkehub.v1beta.IFeature + >, + callback?: PaginationCallback< + protos.google.cloud.gkehub.v1beta.IListFeaturesRequest, + | protos.google.cloud.gkehub.v1beta.IListFeaturesResponse + | null + | undefined, + protos.google.cloud.gkehub.v1beta.IFeature + >, + ): Promise< + [ + protos.google.cloud.gkehub.v1beta.IFeature[], + protos.google.cloud.gkehub.v1beta.IListFeaturesRequest | null, + protos.google.cloud.gkehub.v1beta.IListFeaturesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-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.gkehub.v1beta.IListFeaturesRequest, - protos.google.cloud.gkehub.v1beta.IListFeaturesResponse|null|undefined, - protos.google.cloud.gkehub.v1beta.IFeature>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.gkehub.v1beta.IListFeaturesRequest, + | protos.google.cloud.gkehub.v1beta.IListFeaturesResponse + | null + | undefined, + protos.google.cloud.gkehub.v1beta.IFeature + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listFeatures values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -990,156 +1355,160 @@ export class GkeHubClient { this._log.info('listFeatures request %j', request); return this.innerApiCalls .listFeatures(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.gkehub.v1beta.IFeature[], - protos.google.cloud.gkehub.v1beta.IListFeaturesRequest|null, - protos.google.cloud.gkehub.v1beta.IListFeaturesResponse - ]) => { - this._log.info('listFeatures values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.gkehub.v1beta.IFeature[], + protos.google.cloud.gkehub.v1beta.IListFeaturesRequest | null, + protos.google.cloud.gkehub.v1beta.IListFeaturesResponse, + ]) => { + this._log.info('listFeatures values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listFeatures`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * The parent (project and location) where the Features will be listed. - * Specified in the format `projects/* /locations/*`. - * @param {number} request.pageSize - * When requesting a 'page' of resources, `page_size` specifies number of - * resources to return. If unspecified or set to 0, all resources will - * be returned. - * @param {string} request.pageToken - * Token returned by previous call to `ListFeatures` which - * specifies the position in the list from where to continue listing the - * resources. - * @param {string} request.filter - * Lists Features that match the filter expression, following the syntax - * outlined in https://google.aip.dev/160. - * - * Examples: - * - * - Feature with the name "servicemesh" in project "foo-proj": - * - * name = "projects/foo-proj/locations/global/features/servicemesh" - * - * - Features that have a label called `foo`: - * - * labels.foo:* - * - * - Features that have a label called `foo` whose value is `bar`: - * - * labels.foo = bar - * @param {string} request.orderBy - * One or more fields to compare and use to sort the output. - * See https://google.aip.dev/132#ordering. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.gkehub.v1beta.Feature|Feature} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listFeaturesAsync()` - * method described below for async iteration which you can stop as 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 `listFeatures`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * The parent (project and location) where the Features will be listed. + * Specified in the format `projects/* /locations/*`. + * @param {number} request.pageSize + * When requesting a 'page' of resources, `page_size` specifies number of + * resources to return. If unspecified or set to 0, all resources will + * be returned. + * @param {string} request.pageToken + * Token returned by previous call to `ListFeatures` which + * specifies the position in the list from where to continue listing the + * resources. + * @param {string} request.filter + * Lists Features that match the filter expression, following the syntax + * outlined in https://google.aip.dev/160. + * + * Examples: + * + * - Feature with the name "servicemesh" in project "foo-proj": + * + * name = "projects/foo-proj/locations/global/features/servicemesh" + * + * - Features that have a label called `foo`: + * + * labels.foo:* + * + * - Features that have a label called `foo` whose value is `bar`: + * + * labels.foo = bar + * @param {string} request.orderBy + * One or more fields to compare and use to sort the output. + * See https://google.aip.dev/132#ordering. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.gkehub.v1beta.Feature|Feature} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listFeaturesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listFeaturesStream( - request?: protos.google.cloud.gkehub.v1beta.IListFeaturesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.gkehub.v1beta.IListFeaturesRequest, + 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['listFeatures']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listFeatures stream %j', request); return this.descriptors.page.listFeatures.createStream( this.innerApiCalls.listFeatures as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listFeatures`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is 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 parent (project and location) where the Features will be listed. - * Specified in the format `projects/* /locations/*`. - * @param {number} request.pageSize - * When requesting a 'page' of resources, `page_size` specifies number of - * resources to return. If unspecified or set to 0, all resources will - * be returned. - * @param {string} request.pageToken - * Token returned by previous call to `ListFeatures` which - * specifies the position in the list from where to continue listing the - * resources. - * @param {string} request.filter - * Lists Features that match the filter expression, following the syntax - * outlined in https://google.aip.dev/160. - * - * Examples: - * - * - Feature with the name "servicemesh" in project "foo-proj": - * - * name = "projects/foo-proj/locations/global/features/servicemesh" - * - * - Features that have a label called `foo`: - * - * labels.foo:* - * - * - Features that have a label called `foo` whose value is `bar`: - * - * labels.foo = bar - * @param {string} request.orderBy - * One or more fields to compare and use to sort the output. - * See https://google.aip.dev/132#ordering. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.gkehub.v1beta.Feature|Feature}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/gke_hub.list_features.js - * region_tag:gkehub_v1beta_generated_GkeHub_ListFeatures_async - */ + /** + * Equivalent to `listFeatures`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is 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 parent (project and location) where the Features will be listed. + * Specified in the format `projects/* /locations/*`. + * @param {number} request.pageSize + * When requesting a 'page' of resources, `page_size` specifies number of + * resources to return. If unspecified or set to 0, all resources will + * be returned. + * @param {string} request.pageToken + * Token returned by previous call to `ListFeatures` which + * specifies the position in the list from where to continue listing the + * resources. + * @param {string} request.filter + * Lists Features that match the filter expression, following the syntax + * outlined in https://google.aip.dev/160. + * + * Examples: + * + * - Feature with the name "servicemesh" in project "foo-proj": + * + * name = "projects/foo-proj/locations/global/features/servicemesh" + * + * - Features that have a label called `foo`: + * + * labels.foo:* + * + * - Features that have a label called `foo` whose value is `bar`: + * + * labels.foo = bar + * @param {string} request.orderBy + * One or more fields to compare and use to sort the output. + * See https://google.aip.dev/132#ordering. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.gkehub.v1beta.Feature|Feature}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/gke_hub.list_features.js + * region_tag:gkehub_v1beta_generated_GkeHub_ListFeatures_async + */ listFeaturesAsync( - request?: protos.google.cloud.gkehub.v1beta.IListFeaturesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.gkehub.v1beta.IListFeaturesRequest, + 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['listFeatures']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listFeatures iterate %j', request); return this.descriptors.page.listFeatures.asyncIterate( this.innerApiCalls['listFeatures'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } // -------------------- @@ -1154,7 +1523,7 @@ export class GkeHubClient { * @param {string} feature * @returns {string} Resource name string. */ - featurePath(project:string,location:string,feature:string) { + featurePath(project: string, location: string, feature: string) { return this.pathTemplates.featurePathTemplate.render({ project: project, location: location, @@ -1203,7 +1572,7 @@ export class GkeHubClient { */ close(): Promise { if (this.gkeHubStub && !this._terminated) { - return this.gkeHubStub.then(stub => { + return this.gkeHubStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); @@ -1212,4 +1581,4 @@ export class GkeHubClient { } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-gkehub/src/v1beta/index.ts b/packages/google-cloud-gkehub/src/v1beta/index.ts index 5512785d3fb8..ea1c8a89881c 100644 --- a/packages/google-cloud-gkehub/src/v1beta/index.ts +++ b/packages/google-cloud-gkehub/src/v1beta/index.ts @@ -16,4 +16,4 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {GkeHubClient} from './gke_hub_client'; +export { GkeHubClient } from './gke_hub_client'; diff --git a/packages/google-cloud-gkehub/src/v1beta1/gke_hub_membership_service_client.ts b/packages/google-cloud-gkehub/src/v1beta1/gke_hub_membership_service_client.ts index 2816ab1f3b60..114743a5fa09 100644 --- a/packages/google-cloud-gkehub/src/v1beta1/gke_hub_membership_service_client.ts +++ b/packages/google-cloud-gkehub/src/v1beta1/gke_hub_membership_service_client.ts @@ -18,11 +18,24 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, IamClient, IamProtos, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, + PaginationCallback, + GaxCall, + IamClient, + IamProtos, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import { Transform } from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); -import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; +import { loggingUtils as logging, decodeAnyProtosInArray } from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -53,7 +66,7 @@ export class GkeHubMembershipServiceClient { 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('gke-hub'); @@ -66,12 +79,12 @@ export class GkeHubMembershipServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; iamClient: IamClient; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; + pathTemplates: { [name: string]: gax.PathTemplate }; operationsClient: gax.OperationsClient; - gkeHubMembershipServiceStub?: Promise<{[name: string]: Function}>; + gkeHubMembershipServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of GkeHubMembershipServiceClient. @@ -112,21 +125,43 @@ export class GkeHubMembershipServiceClient { * const client = new GkeHubMembershipServiceClient({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 GkeHubMembershipServiceClient; - 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 GkeHubMembershipServiceClient; + 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 = 'gkehub.' + 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; @@ -151,7 +186,7 @@ export class GkeHubMembershipServiceClient { 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; @@ -164,18 +199,14 @@ export class GkeHubMembershipServiceClient { this.auth.defaultScopes = staticMembers.scopes; } this.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); - + this.locationsClient = new this._gaxModule.LocationsClient( this._gaxGrpc, - opts + opts, ); - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process === 'object' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -197,13 +228,13 @@ export class GkeHubMembershipServiceClient { // Create useful helper objects for these. this.pathTemplates = { locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' + 'projects/{project}/locations/{location}', ), membershipPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/memberships/{membership}' + 'projects/{project}/locations/{location}/memberships/{membership}', ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' + 'projects/{project}', ), }; @@ -211,8 +242,11 @@ export class GkeHubMembershipServiceClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listMemberships: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'resources') + listMemberships: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'resources', + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -221,45 +255,99 @@ export class GkeHubMembershipServiceClient { // rather than holding a request open. const lroOptions: GrpcClientOptions = { auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1beta1/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1beta1/{name=projects/*}/locations',},{selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',get: '/v1beta1/{resource=projects/*/locations/*/memberships/*}:getIamPolicy',},{selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',post: '/v1beta1/{resource=projects/*/locations/*/memberships/*}:setIamPolicy',body: '*',},{selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',post: '/v1beta1/{resource=projects/*/locations/*/memberships/*}:testIamPermissions',body: '*',},{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1beta1/{name=projects/*/locations/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1beta1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1beta1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1beta1/{name=projects/*/locations/*}/operations',}]; + lroOptions.httpRules = [ + { + selector: 'google.cloud.location.Locations.GetLocation', + get: '/v1beta1/{name=projects/*/locations/*}', + }, + { + selector: 'google.cloud.location.Locations.ListLocations', + get: '/v1beta1/{name=projects/*}/locations', + }, + { + selector: 'google.iam.v1.IAMPolicy.GetIamPolicy', + get: '/v1beta1/{resource=projects/*/locations/*/memberships/*}:getIamPolicy', + }, + { + selector: 'google.iam.v1.IAMPolicy.SetIamPolicy', + post: '/v1beta1/{resource=projects/*/locations/*/memberships/*}:setIamPolicy', + body: '*', + }, + { + selector: 'google.iam.v1.IAMPolicy.TestIamPermissions', + post: '/v1beta1/{resource=projects/*/locations/*/memberships/*}:testIamPermissions', + body: '*', + }, + { + selector: 'google.longrunning.Operations.CancelOperation', + post: '/v1beta1/{name=projects/*/locations/*/operations/*}:cancel', + body: '*', + }, + { + selector: 'google.longrunning.Operations.DeleteOperation', + delete: '/v1beta1/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v1beta1/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v1beta1/{name=projects/*/locations/*}/operations', + }, + ]; } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); const createMembershipResponse = protoFilesRoot.lookup( - '.google.cloud.gkehub.v1beta1.Membership') as gax.protobuf.Type; + '.google.cloud.gkehub.v1beta1.Membership', + ) as gax.protobuf.Type; const createMembershipMetadata = protoFilesRoot.lookup( - '.google.cloud.gkehub.v1beta1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.gkehub.v1beta1.OperationMetadata', + ) as gax.protobuf.Type; const deleteMembershipResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteMembershipMetadata = protoFilesRoot.lookup( - '.google.cloud.gkehub.v1beta1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.gkehub.v1beta1.OperationMetadata', + ) as gax.protobuf.Type; const updateMembershipResponse = protoFilesRoot.lookup( - '.google.cloud.gkehub.v1beta1.Membership') as gax.protobuf.Type; + '.google.cloud.gkehub.v1beta1.Membership', + ) as gax.protobuf.Type; const updateMembershipMetadata = protoFilesRoot.lookup( - '.google.cloud.gkehub.v1beta1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.gkehub.v1beta1.OperationMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { createMembership: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createMembershipResponse.decode.bind(createMembershipResponse), - createMembershipMetadata.decode.bind(createMembershipMetadata)), + createMembershipMetadata.decode.bind(createMembershipMetadata), + ), deleteMembership: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteMembershipResponse.decode.bind(deleteMembershipResponse), - deleteMembershipMetadata.decode.bind(deleteMembershipMetadata)), + deleteMembershipMetadata.decode.bind(deleteMembershipMetadata), + ), updateMembership: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateMembershipResponse.decode.bind(updateMembershipResponse), - updateMembershipMetadata.decode.bind(updateMembershipMetadata)) + updateMembershipMetadata.decode.bind(updateMembershipMetadata), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.gkehub.v1beta1.GkeHubMembershipService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.gkehub.v1beta1.GkeHubMembershipService', + 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 @@ -290,28 +378,43 @@ export class GkeHubMembershipServiceClient { // Put together the "service stub" for // google.cloud.gkehub.v1beta1.GkeHubMembershipService. this.gkeHubMembershipServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.gkehub.v1beta1.GkeHubMembershipService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.gkehub.v1beta1.GkeHubMembershipService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.gkehub.v1beta1.GkeHubMembershipService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.gkehub.v1beta1 + .GkeHubMembershipService, + 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 gkeHubMembershipServiceStubMethods = - ['listMemberships', 'getMembership', 'createMembership', 'deleteMembership', 'updateMembership', 'generateConnectManifest', 'validateExclusivity', 'generateExclusivityManifest']; + const gkeHubMembershipServiceStubMethods = [ + 'listMemberships', + 'getMembership', + 'createMembership', + 'deleteMembership', + 'updateMembership', + 'generateConnectManifest', + 'validateExclusivity', + 'generateExclusivityManifest', + ]; for (const methodName of gkeHubMembershipServiceStubMethods) { const callPromise = this.gkeHubMembershipServiceStub.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] || @@ -321,7 +424,7 @@ export class GkeHubMembershipServiceClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -336,8 +439,14 @@ export class GkeHubMembershipServiceClient { * @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 'gkehub.googleapis.com'; } @@ -348,8 +457,14 @@ export class GkeHubMembershipServiceClient { * @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 'gkehub.googleapis.com'; } @@ -380,9 +495,7 @@ export class GkeHubMembershipServiceClient { * @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; @@ -391,8 +504,9 @@ export class GkeHubMembershipServiceClient { * 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; @@ -403,943 +517,1341 @@ export class GkeHubMembershipServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Gets the details of a Membership. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The Membership resource name in the format - * `projects/* /locations/* /memberships/*`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.gkehub.v1beta1.Membership|Membership}. - * Please see the {@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/gke_hub_membership_service.get_membership.js - * region_tag:gkehub_v1beta1_generated_GkeHubMembershipService_GetMembership_async - */ + /** + * Gets the details of a Membership. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The Membership resource name in the format + * `projects/* /locations/* /memberships/*`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.gkehub.v1beta1.Membership|Membership}. + * Please see the {@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/gke_hub_membership_service.get_membership.js + * region_tag:gkehub_v1beta1_generated_GkeHubMembershipService_GetMembership_async + */ getMembership( - request?: protos.google.cloud.gkehub.v1beta1.IGetMembershipRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gkehub.v1beta1.IMembership, - protos.google.cloud.gkehub.v1beta1.IGetMembershipRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkehub.v1beta1.IGetMembershipRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gkehub.v1beta1.IMembership, + protos.google.cloud.gkehub.v1beta1.IGetMembershipRequest | undefined, + {} | undefined, + ] + >; getMembership( - request: protos.google.cloud.gkehub.v1beta1.IGetMembershipRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.gkehub.v1beta1.IMembership, - protos.google.cloud.gkehub.v1beta1.IGetMembershipRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1beta1.IGetMembershipRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.gkehub.v1beta1.IMembership, + | protos.google.cloud.gkehub.v1beta1.IGetMembershipRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getMembership( - request: protos.google.cloud.gkehub.v1beta1.IGetMembershipRequest, - callback: Callback< - protos.google.cloud.gkehub.v1beta1.IMembership, - protos.google.cloud.gkehub.v1beta1.IGetMembershipRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1beta1.IGetMembershipRequest, + callback: Callback< + protos.google.cloud.gkehub.v1beta1.IMembership, + | protos.google.cloud.gkehub.v1beta1.IGetMembershipRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getMembership( - request?: protos.google.cloud.gkehub.v1beta1.IGetMembershipRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.gkehub.v1beta1.IMembership, - protos.google.cloud.gkehub.v1beta1.IGetMembershipRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.gkehub.v1beta1.IGetMembershipRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.gkehub.v1beta1.IMembership, - protos.google.cloud.gkehub.v1beta1.IGetMembershipRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.gkehub.v1beta1.IMembership, - protos.google.cloud.gkehub.v1beta1.IGetMembershipRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.gkehub.v1beta1.IGetMembershipRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.gkehub.v1beta1.IMembership, + | protos.google.cloud.gkehub.v1beta1.IGetMembershipRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.gkehub.v1beta1.IMembership, + protos.google.cloud.gkehub.v1beta1.IGetMembershipRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getMembership request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.gkehub.v1beta1.IMembership, - protos.google.cloud.gkehub.v1beta1.IGetMembershipRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.gkehub.v1beta1.IMembership, + | protos.google.cloud.gkehub.v1beta1.IGetMembershipRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getMembership response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getMembership(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.gkehub.v1beta1.IMembership, - protos.google.cloud.gkehub.v1beta1.IGetMembershipRequest|undefined, - {}|undefined - ]) => { - this._log.info('getMembership response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getMembership(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.gkehub.v1beta1.IMembership, + protos.google.cloud.gkehub.v1beta1.IGetMembershipRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getMembership response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 the manifest for deployment of the GKE connect agent. - * - * **This method is used internally by Google-provided libraries.** - * Most clients should not need to call this method directly. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The Membership resource name the Agent will associate with, in - * the format `projects/* /locations/* /memberships/*`. - * @param {google.cloud.gkehub.v1beta1.ConnectAgent} [request.connectAgent] - * Optional. The connect agent to generate manifest for. - * @param {string} [request.version] - * Optional. The Connect agent version to use. Defaults to the most current - * version. - * @param {boolean} [request.isUpgrade] - * Optional. If true, generate the resources for upgrade only. Some resources - * generated only for installation (e.g. secrets) will be excluded. - * @param {string} [request.registry] - * Optional. The registry to fetch the connect agent image from. Defaults to - * gcr.io/gkeconnect. - * @param {Buffer} [request.imagePullSecretContent] - * Optional. The image pull secret content for the registry, if not public. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.gkehub.v1beta1.GenerateConnectManifestResponse|GenerateConnectManifestResponse}. - * Please see the {@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/gke_hub_membership_service.generate_connect_manifest.js - * region_tag:gkehub_v1beta1_generated_GkeHubMembershipService_GenerateConnectManifest_async - */ + /** + * Generates the manifest for deployment of the GKE connect agent. + * + * **This method is used internally by Google-provided libraries.** + * Most clients should not need to call this method directly. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The Membership resource name the Agent will associate with, in + * the format `projects/* /locations/* /memberships/*`. + * @param {google.cloud.gkehub.v1beta1.ConnectAgent} [request.connectAgent] + * Optional. The connect agent to generate manifest for. + * @param {string} [request.version] + * Optional. The Connect agent version to use. Defaults to the most current + * version. + * @param {boolean} [request.isUpgrade] + * Optional. If true, generate the resources for upgrade only. Some resources + * generated only for installation (e.g. secrets) will be excluded. + * @param {string} [request.registry] + * Optional. The registry to fetch the connect agent image from. Defaults to + * gcr.io/gkeconnect. + * @param {Buffer} [request.imagePullSecretContent] + * Optional. The image pull secret content for the registry, if not public. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.gkehub.v1beta1.GenerateConnectManifestResponse|GenerateConnectManifestResponse}. + * Please see the {@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/gke_hub_membership_service.generate_connect_manifest.js + * region_tag:gkehub_v1beta1_generated_GkeHubMembershipService_GenerateConnectManifest_async + */ generateConnectManifest( - request?: protos.google.cloud.gkehub.v1beta1.IGenerateConnectManifestRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gkehub.v1beta1.IGenerateConnectManifestResponse, - protos.google.cloud.gkehub.v1beta1.IGenerateConnectManifestRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkehub.v1beta1.IGenerateConnectManifestRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gkehub.v1beta1.IGenerateConnectManifestResponse, + ( + | protos.google.cloud.gkehub.v1beta1.IGenerateConnectManifestRequest + | undefined + ), + {} | undefined, + ] + >; generateConnectManifest( - request: protos.google.cloud.gkehub.v1beta1.IGenerateConnectManifestRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.gkehub.v1beta1.IGenerateConnectManifestResponse, - protos.google.cloud.gkehub.v1beta1.IGenerateConnectManifestRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1beta1.IGenerateConnectManifestRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.gkehub.v1beta1.IGenerateConnectManifestResponse, + | protos.google.cloud.gkehub.v1beta1.IGenerateConnectManifestRequest + | null + | undefined, + {} | null | undefined + >, + ): void; generateConnectManifest( - request: protos.google.cloud.gkehub.v1beta1.IGenerateConnectManifestRequest, - callback: Callback< - protos.google.cloud.gkehub.v1beta1.IGenerateConnectManifestResponse, - protos.google.cloud.gkehub.v1beta1.IGenerateConnectManifestRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1beta1.IGenerateConnectManifestRequest, + callback: Callback< + protos.google.cloud.gkehub.v1beta1.IGenerateConnectManifestResponse, + | protos.google.cloud.gkehub.v1beta1.IGenerateConnectManifestRequest + | null + | undefined, + {} | null | undefined + >, + ): void; generateConnectManifest( - request?: protos.google.cloud.gkehub.v1beta1.IGenerateConnectManifestRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.gkehub.v1beta1.IGenerateConnectManifestResponse, - protos.google.cloud.gkehub.v1beta1.IGenerateConnectManifestRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.gkehub.v1beta1.IGenerateConnectManifestRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.gkehub.v1beta1.IGenerateConnectManifestResponse, - protos.google.cloud.gkehub.v1beta1.IGenerateConnectManifestRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.gkehub.v1beta1.IGenerateConnectManifestResponse, - protos.google.cloud.gkehub.v1beta1.IGenerateConnectManifestRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.gkehub.v1beta1.IGenerateConnectManifestRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.gkehub.v1beta1.IGenerateConnectManifestResponse, + | protos.google.cloud.gkehub.v1beta1.IGenerateConnectManifestRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.gkehub.v1beta1.IGenerateConnectManifestResponse, + ( + | protos.google.cloud.gkehub.v1beta1.IGenerateConnectManifestRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('generateConnectManifest request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.gkehub.v1beta1.IGenerateConnectManifestResponse, - protos.google.cloud.gkehub.v1beta1.IGenerateConnectManifestRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.gkehub.v1beta1.IGenerateConnectManifestResponse, + | protos.google.cloud.gkehub.v1beta1.IGenerateConnectManifestRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('generateConnectManifest response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.generateConnectManifest(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.gkehub.v1beta1.IGenerateConnectManifestResponse, - protos.google.cloud.gkehub.v1beta1.IGenerateConnectManifestRequest|undefined, - {}|undefined - ]) => { - this._log.info('generateConnectManifest response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .generateConnectManifest(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.gkehub.v1beta1.IGenerateConnectManifestResponse, + ( + | protos.google.cloud.gkehub.v1beta1.IGenerateConnectManifestRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('generateConnectManifest response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * ValidateExclusivity validates the state of exclusivity in the cluster. - * The validation does not depend on an existing Hub membership resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent (project and location) where the Memberships will be - * created. Specified in the format `projects/* /locations/*`. - * @param {string} [request.crManifest] - * Optional. The YAML of the membership CR in the cluster. Empty if the - * membership CR does not exist. - * @param {string} request.intendedMembership - * Required. The intended membership name under the `parent`. This method only - * does validation in anticipation of a CreateMembership call with the same - * name. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.gkehub.v1beta1.ValidateExclusivityResponse|ValidateExclusivityResponse}. - * Please see the {@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/gke_hub_membership_service.validate_exclusivity.js - * region_tag:gkehub_v1beta1_generated_GkeHubMembershipService_ValidateExclusivity_async - */ + /** + * ValidateExclusivity validates the state of exclusivity in the cluster. + * The validation does not depend on an existing Hub membership resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent (project and location) where the Memberships will be + * created. Specified in the format `projects/* /locations/*`. + * @param {string} [request.crManifest] + * Optional. The YAML of the membership CR in the cluster. Empty if the + * membership CR does not exist. + * @param {string} request.intendedMembership + * Required. The intended membership name under the `parent`. This method only + * does validation in anticipation of a CreateMembership call with the same + * name. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.gkehub.v1beta1.ValidateExclusivityResponse|ValidateExclusivityResponse}. + * Please see the {@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/gke_hub_membership_service.validate_exclusivity.js + * region_tag:gkehub_v1beta1_generated_GkeHubMembershipService_ValidateExclusivity_async + */ validateExclusivity( - request?: protos.google.cloud.gkehub.v1beta1.IValidateExclusivityRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gkehub.v1beta1.IValidateExclusivityResponse, - protos.google.cloud.gkehub.v1beta1.IValidateExclusivityRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkehub.v1beta1.IValidateExclusivityRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gkehub.v1beta1.IValidateExclusivityResponse, + ( + | protos.google.cloud.gkehub.v1beta1.IValidateExclusivityRequest + | undefined + ), + {} | undefined, + ] + >; validateExclusivity( - request: protos.google.cloud.gkehub.v1beta1.IValidateExclusivityRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.gkehub.v1beta1.IValidateExclusivityResponse, - protos.google.cloud.gkehub.v1beta1.IValidateExclusivityRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1beta1.IValidateExclusivityRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.gkehub.v1beta1.IValidateExclusivityResponse, + | protos.google.cloud.gkehub.v1beta1.IValidateExclusivityRequest + | null + | undefined, + {} | null | undefined + >, + ): void; validateExclusivity( - request: protos.google.cloud.gkehub.v1beta1.IValidateExclusivityRequest, - callback: Callback< - protos.google.cloud.gkehub.v1beta1.IValidateExclusivityResponse, - protos.google.cloud.gkehub.v1beta1.IValidateExclusivityRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1beta1.IValidateExclusivityRequest, + callback: Callback< + protos.google.cloud.gkehub.v1beta1.IValidateExclusivityResponse, + | protos.google.cloud.gkehub.v1beta1.IValidateExclusivityRequest + | null + | undefined, + {} | null | undefined + >, + ): void; validateExclusivity( - request?: protos.google.cloud.gkehub.v1beta1.IValidateExclusivityRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.gkehub.v1beta1.IValidateExclusivityResponse, - protos.google.cloud.gkehub.v1beta1.IValidateExclusivityRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.gkehub.v1beta1.IValidateExclusivityRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.gkehub.v1beta1.IValidateExclusivityResponse, - protos.google.cloud.gkehub.v1beta1.IValidateExclusivityRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.gkehub.v1beta1.IValidateExclusivityResponse, - protos.google.cloud.gkehub.v1beta1.IValidateExclusivityRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.gkehub.v1beta1.IValidateExclusivityRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.gkehub.v1beta1.IValidateExclusivityResponse, + | protos.google.cloud.gkehub.v1beta1.IValidateExclusivityRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.gkehub.v1beta1.IValidateExclusivityResponse, + ( + | protos.google.cloud.gkehub.v1beta1.IValidateExclusivityRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.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('validateExclusivity request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.gkehub.v1beta1.IValidateExclusivityResponse, - protos.google.cloud.gkehub.v1beta1.IValidateExclusivityRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.gkehub.v1beta1.IValidateExclusivityResponse, + | protos.google.cloud.gkehub.v1beta1.IValidateExclusivityRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('validateExclusivity response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.validateExclusivity(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.gkehub.v1beta1.IValidateExclusivityResponse, - protos.google.cloud.gkehub.v1beta1.IValidateExclusivityRequest|undefined, - {}|undefined - ]) => { - this._log.info('validateExclusivity response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .validateExclusivity(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.gkehub.v1beta1.IValidateExclusivityResponse, + ( + | protos.google.cloud.gkehub.v1beta1.IValidateExclusivityRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('validateExclusivity response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * GenerateExclusivityManifest generates the manifests to update the - * exclusivity artifacts in the cluster if needed. - * - * Exclusivity artifacts include the Membership custom resource definition - * (CRD) and the singleton Membership custom resource (CR). Combined with - * ValidateExclusivity, exclusivity artifacts guarantee that a Kubernetes - * cluster is only registered to a single GKE Hub. - * - * The Membership CRD is versioned, and may require conversion when the GKE - * Hub API server begins serving a newer version of the CRD and - * corresponding CR. The response will be the converted CRD and CR if there - * are any differences between the versions. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The Membership resource name in the format - * `projects/* /locations/* /memberships/*`. - * @param {string} [request.crdManifest] - * Optional. The YAML manifest of the membership CRD retrieved by - * `kubectl get customresourcedefinitions membership`. - * Leave empty if the resource does not exist. - * @param {string} [request.crManifest] - * Optional. The YAML manifest of the membership CR retrieved by - * `kubectl get memberships membership`. - * Leave empty if the resource does not exist. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.gkehub.v1beta1.GenerateExclusivityManifestResponse|GenerateExclusivityManifestResponse}. - * Please see the {@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/gke_hub_membership_service.generate_exclusivity_manifest.js - * region_tag:gkehub_v1beta1_generated_GkeHubMembershipService_GenerateExclusivityManifest_async - */ + /** + * GenerateExclusivityManifest generates the manifests to update the + * exclusivity artifacts in the cluster if needed. + * + * Exclusivity artifacts include the Membership custom resource definition + * (CRD) and the singleton Membership custom resource (CR). Combined with + * ValidateExclusivity, exclusivity artifacts guarantee that a Kubernetes + * cluster is only registered to a single GKE Hub. + * + * The Membership CRD is versioned, and may require conversion when the GKE + * Hub API server begins serving a newer version of the CRD and + * corresponding CR. The response will be the converted CRD and CR if there + * are any differences between the versions. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The Membership resource name in the format + * `projects/* /locations/* /memberships/*`. + * @param {string} [request.crdManifest] + * Optional. The YAML manifest of the membership CRD retrieved by + * `kubectl get customresourcedefinitions membership`. + * Leave empty if the resource does not exist. + * @param {string} [request.crManifest] + * Optional. The YAML manifest of the membership CR retrieved by + * `kubectl get memberships membership`. + * Leave empty if the resource does not exist. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.gkehub.v1beta1.GenerateExclusivityManifestResponse|GenerateExclusivityManifestResponse}. + * Please see the {@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/gke_hub_membership_service.generate_exclusivity_manifest.js + * region_tag:gkehub_v1beta1_generated_GkeHubMembershipService_GenerateExclusivityManifest_async + */ generateExclusivityManifest( - request?: protos.google.cloud.gkehub.v1beta1.IGenerateExclusivityManifestRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gkehub.v1beta1.IGenerateExclusivityManifestResponse, - protos.google.cloud.gkehub.v1beta1.IGenerateExclusivityManifestRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkehub.v1beta1.IGenerateExclusivityManifestRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gkehub.v1beta1.IGenerateExclusivityManifestResponse, + ( + | protos.google.cloud.gkehub.v1beta1.IGenerateExclusivityManifestRequest + | undefined + ), + {} | undefined, + ] + >; generateExclusivityManifest( - request: protos.google.cloud.gkehub.v1beta1.IGenerateExclusivityManifestRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.gkehub.v1beta1.IGenerateExclusivityManifestResponse, - protos.google.cloud.gkehub.v1beta1.IGenerateExclusivityManifestRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1beta1.IGenerateExclusivityManifestRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.gkehub.v1beta1.IGenerateExclusivityManifestResponse, + | protos.google.cloud.gkehub.v1beta1.IGenerateExclusivityManifestRequest + | null + | undefined, + {} | null | undefined + >, + ): void; generateExclusivityManifest( - request: protos.google.cloud.gkehub.v1beta1.IGenerateExclusivityManifestRequest, - callback: Callback< - protos.google.cloud.gkehub.v1beta1.IGenerateExclusivityManifestResponse, - protos.google.cloud.gkehub.v1beta1.IGenerateExclusivityManifestRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1beta1.IGenerateExclusivityManifestRequest, + callback: Callback< + protos.google.cloud.gkehub.v1beta1.IGenerateExclusivityManifestResponse, + | protos.google.cloud.gkehub.v1beta1.IGenerateExclusivityManifestRequest + | null + | undefined, + {} | null | undefined + >, + ): void; generateExclusivityManifest( - request?: protos.google.cloud.gkehub.v1beta1.IGenerateExclusivityManifestRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.gkehub.v1beta1.IGenerateExclusivityManifestResponse, - protos.google.cloud.gkehub.v1beta1.IGenerateExclusivityManifestRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.gkehub.v1beta1.IGenerateExclusivityManifestRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.gkehub.v1beta1.IGenerateExclusivityManifestResponse, - protos.google.cloud.gkehub.v1beta1.IGenerateExclusivityManifestRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.gkehub.v1beta1.IGenerateExclusivityManifestResponse, - protos.google.cloud.gkehub.v1beta1.IGenerateExclusivityManifestRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.gkehub.v1beta1.IGenerateExclusivityManifestRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.gkehub.v1beta1.IGenerateExclusivityManifestResponse, + | protos.google.cloud.gkehub.v1beta1.IGenerateExclusivityManifestRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.gkehub.v1beta1.IGenerateExclusivityManifestResponse, + ( + | protos.google.cloud.gkehub.v1beta1.IGenerateExclusivityManifestRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('generateExclusivityManifest request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.gkehub.v1beta1.IGenerateExclusivityManifestResponse, - protos.google.cloud.gkehub.v1beta1.IGenerateExclusivityManifestRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.gkehub.v1beta1.IGenerateExclusivityManifestResponse, + | protos.google.cloud.gkehub.v1beta1.IGenerateExclusivityManifestRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('generateExclusivityManifest response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.generateExclusivityManifest(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.gkehub.v1beta1.IGenerateExclusivityManifestResponse, - protos.google.cloud.gkehub.v1beta1.IGenerateExclusivityManifestRequest|undefined, - {}|undefined - ]) => { - this._log.info('generateExclusivityManifest response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .generateExclusivityManifest(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.gkehub.v1beta1.IGenerateExclusivityManifestResponse, + ( + | protos.google.cloud.gkehub.v1beta1.IGenerateExclusivityManifestRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('generateExclusivityManifest response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 Membership. - * - * **This is currently only supported for GKE clusters on Google Cloud**. - * To register other clusters, follow the instructions at - * https://cloud.google.com/anthos/multicluster-management/connect/registering-a-cluster. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent (project and location) where the Memberships will be - * created. Specified in the format `projects/* /locations/*`. - * @param {string} request.membershipId - * Required. Client chosen ID for the membership. `membership_id` must be a - * valid RFC 1123 compliant DNS label: - * - * 1. At most 63 characters in length - * 2. It must consist of lower case alphanumeric characters or `-` - * 3. It must start and end with an alphanumeric character - * - * Which can be expressed as the regex: `[a-z0-9]([-a-z0-9]*[a-z0-9])?`, - * with a maximum length of 63 characters. - * @param {google.cloud.gkehub.v1beta1.Membership} request.resource - * Required. The membership to create. - * @param {string} [request.requestId] - * Optional. A request ID to identify requests. Specify a unique request ID - * so that if you must retry your request, the server will know to ignore - * the request if it has already been completed. The server will guarantee - * that for at least 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/gke_hub_membership_service.create_membership.js - * region_tag:gkehub_v1beta1_generated_GkeHubMembershipService_CreateMembership_async - */ + /** + * Creates a new Membership. + * + * **This is currently only supported for GKE clusters on Google Cloud**. + * To register other clusters, follow the instructions at + * https://cloud.google.com/anthos/multicluster-management/connect/registering-a-cluster. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent (project and location) where the Memberships will be + * created. Specified in the format `projects/* /locations/*`. + * @param {string} request.membershipId + * Required. Client chosen ID for the membership. `membership_id` must be a + * valid RFC 1123 compliant DNS label: + * + * 1. At most 63 characters in length + * 2. It must consist of lower case alphanumeric characters or `-` + * 3. It must start and end with an alphanumeric character + * + * Which can be expressed as the regex: `[a-z0-9]([-a-z0-9]*[a-z0-9])?`, + * with a maximum length of 63 characters. + * @param {google.cloud.gkehub.v1beta1.Membership} request.resource + * Required. The membership to create. + * @param {string} [request.requestId] + * Optional. A request ID to identify requests. Specify a unique request ID + * so that if you must retry your request, the server will know to ignore + * the request if it has already been completed. The server will guarantee + * that for at least 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/gke_hub_membership_service.create_membership.js + * region_tag:gkehub_v1beta1_generated_GkeHubMembershipService_CreateMembership_async + */ createMembership( - request?: protos.google.cloud.gkehub.v1beta1.ICreateMembershipRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkehub.v1beta1.ICreateMembershipRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.gkehub.v1beta1.IMembership, + protos.google.cloud.gkehub.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createMembership( - request: protos.google.cloud.gkehub.v1beta1.ICreateMembershipRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1beta1.ICreateMembershipRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.gkehub.v1beta1.IMembership, + protos.google.cloud.gkehub.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createMembership( - request: protos.google.cloud.gkehub.v1beta1.ICreateMembershipRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1beta1.ICreateMembershipRequest, + callback: Callback< + LROperation< + protos.google.cloud.gkehub.v1beta1.IMembership, + protos.google.cloud.gkehub.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createMembership( - request?: protos.google.cloud.gkehub.v1beta1.ICreateMembershipRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.gkehub.v1beta1.ICreateMembershipRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.gkehub.v1beta1.IMembership, + protos.google.cloud.gkehub.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.gkehub.v1beta1.IMembership, + protos.google.cloud.gkehub.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.gkehub.v1beta1.IMembership, + protos.google.cloud.gkehub.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.gkehub.v1beta1.IMembership, + protos.google.cloud.gkehub.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createMembership response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createMembership request %j', request); - return this.innerApiCalls.createMembership(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createMembership response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createMembership(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.gkehub.v1beta1.IMembership, + protos.google.cloud.gkehub.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createMembership response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createMembership()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/gke_hub_membership_service.create_membership.js - * region_tag:gkehub_v1beta1_generated_GkeHubMembershipService_CreateMembership_async - */ - async checkCreateMembershipProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createMembership()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/gke_hub_membership_service.create_membership.js + * region_tag:gkehub_v1beta1_generated_GkeHubMembershipService_CreateMembership_async + */ + async checkCreateMembershipProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.gkehub.v1beta1.Membership, + protos.google.cloud.gkehub.v1beta1.OperationMetadata + > + > { this._log.info('createMembership long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createMembership, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createMembership, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.gkehub.v1beta1.Membership, + protos.google.cloud.gkehub.v1beta1.OperationMetadata + >; } -/** - * Removes a Membership. - * - * **This is currently only supported for GKE clusters on Google Cloud**. - * To unregister other clusters, follow the instructions at - * https://cloud.google.com/anthos/multicluster-management/connect/unregistering-a-cluster. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The Membership resource name in the format - * `projects/* /locations/* /memberships/*`. - * @param {string} [request.requestId] - * Optional. A request ID to identify requests. Specify a unique request ID - * so that if you must retry your request, the server will know to ignore - * the request if it has already been completed. The server will guarantee - * that for at least 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @param {boolean} [request.force] - * Optional. If set to true, any subresource from this Membership will also be - * deleted. Otherwise, the request will only work if the Membership has no - * subresource. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/gke_hub_membership_service.delete_membership.js - * region_tag:gkehub_v1beta1_generated_GkeHubMembershipService_DeleteMembership_async - */ + /** + * Removes a Membership. + * + * **This is currently only supported for GKE clusters on Google Cloud**. + * To unregister other clusters, follow the instructions at + * https://cloud.google.com/anthos/multicluster-management/connect/unregistering-a-cluster. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The Membership resource name in the format + * `projects/* /locations/* /memberships/*`. + * @param {string} [request.requestId] + * Optional. A request ID to identify requests. Specify a unique request ID + * so that if you must retry your request, the server will know to ignore + * the request if it has already been completed. The server will guarantee + * that for at least 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @param {boolean} [request.force] + * Optional. If set to true, any subresource from this Membership will also be + * deleted. Otherwise, the request will only work if the Membership has no + * subresource. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/gke_hub_membership_service.delete_membership.js + * region_tag:gkehub_v1beta1_generated_GkeHubMembershipService_DeleteMembership_async + */ deleteMembership( - request?: protos.google.cloud.gkehub.v1beta1.IDeleteMembershipRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkehub.v1beta1.IDeleteMembershipRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteMembership( - request: protos.google.cloud.gkehub.v1beta1.IDeleteMembershipRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1beta1.IDeleteMembershipRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteMembership( - request: protos.google.cloud.gkehub.v1beta1.IDeleteMembershipRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1beta1.IDeleteMembershipRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteMembership( - request?: protos.google.cloud.gkehub.v1beta1.IDeleteMembershipRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.gkehub.v1beta1.IDeleteMembershipRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteMembership response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteMembership request %j', request); - return this.innerApiCalls.deleteMembership(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteMembership response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteMembership(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteMembership response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteMembership()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/gke_hub_membership_service.delete_membership.js - * region_tag:gkehub_v1beta1_generated_GkeHubMembershipService_DeleteMembership_async - */ - async checkDeleteMembershipProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteMembership()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/gke_hub_membership_service.delete_membership.js + * region_tag:gkehub_v1beta1_generated_GkeHubMembershipService_DeleteMembership_async + */ + async checkDeleteMembershipProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.gkehub.v1beta1.OperationMetadata + > + > { this._log.info('deleteMembership long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteMembership, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteMembership, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.gkehub.v1beta1.OperationMetadata + >; } -/** - * Updates an existing Membership. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The membership resource name in the format: - * `projects/[project_id]/locations/global/memberships/[membership_id]` - * @param {google.protobuf.FieldMask} request.updateMask - * Required. Mask of fields to update. At least one field path must be - * specified in this mask. - * @param {google.cloud.gkehub.v1beta1.Membership} request.resource - * Required. Only fields specified in update_mask are updated. - * If you specify a field in the update_mask but don't specify its value here - * that field will be deleted. - * If you are updating a map field, set the value of a key to null or empty - * string to delete the key from the map. It's not possible to update a key's - * value to the empty string. - * If you specify the update_mask to be a special path "*", fully replaces all - * user-modifiable fields to match `resource`. - * @param {string} [request.requestId] - * Optional. A request ID to identify requests. Specify a unique request ID - * so that if you must retry your request, the server will know to ignore - * the request if it has already been completed. The server will guarantee - * that for at least 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/gke_hub_membership_service.update_membership.js - * region_tag:gkehub_v1beta1_generated_GkeHubMembershipService_UpdateMembership_async - */ + /** + * Updates an existing Membership. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The membership resource name in the format: + * `projects/[project_id]/locations/global/memberships/[membership_id]` + * @param {google.protobuf.FieldMask} request.updateMask + * Required. Mask of fields to update. At least one field path must be + * specified in this mask. + * @param {google.cloud.gkehub.v1beta1.Membership} request.resource + * Required. Only fields specified in update_mask are updated. + * If you specify a field in the update_mask but don't specify its value here + * that field will be deleted. + * If you are updating a map field, set the value of a key to null or empty + * string to delete the key from the map. It's not possible to update a key's + * value to the empty string. + * If you specify the update_mask to be a special path "*", fully replaces all + * user-modifiable fields to match `resource`. + * @param {string} [request.requestId] + * Optional. A request ID to identify requests. Specify a unique request ID + * so that if you must retry your request, the server will know to ignore + * the request if it has already been completed. The server will guarantee + * that for at least 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/gke_hub_membership_service.update_membership.js + * region_tag:gkehub_v1beta1_generated_GkeHubMembershipService_UpdateMembership_async + */ updateMembership( - request?: protos.google.cloud.gkehub.v1beta1.IUpdateMembershipRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkehub.v1beta1.IUpdateMembershipRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.gkehub.v1beta1.IMembership, + protos.google.cloud.gkehub.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateMembership( - request: protos.google.cloud.gkehub.v1beta1.IUpdateMembershipRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1beta1.IUpdateMembershipRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.gkehub.v1beta1.IMembership, + protos.google.cloud.gkehub.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateMembership( - request: protos.google.cloud.gkehub.v1beta1.IUpdateMembershipRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkehub.v1beta1.IUpdateMembershipRequest, + callback: Callback< + LROperation< + protos.google.cloud.gkehub.v1beta1.IMembership, + protos.google.cloud.gkehub.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateMembership( - request?: protos.google.cloud.gkehub.v1beta1.IUpdateMembershipRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.gkehub.v1beta1.IUpdateMembershipRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.gkehub.v1beta1.IMembership, + protos.google.cloud.gkehub.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.gkehub.v1beta1.IMembership, + protos.google.cloud.gkehub.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.gkehub.v1beta1.IMembership, + protos.google.cloud.gkehub.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.gkehub.v1beta1.IMembership, + protos.google.cloud.gkehub.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateMembership response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateMembership request %j', request); - return this.innerApiCalls.updateMembership(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateMembership response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateMembership(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.gkehub.v1beta1.IMembership, + protos.google.cloud.gkehub.v1beta1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateMembership response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateMembership()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta1/gke_hub_membership_service.update_membership.js - * region_tag:gkehub_v1beta1_generated_GkeHubMembershipService_UpdateMembership_async - */ - async checkUpdateMembershipProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateMembership()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta1/gke_hub_membership_service.update_membership.js + * region_tag:gkehub_v1beta1_generated_GkeHubMembershipService_UpdateMembership_async + */ + async checkUpdateMembershipProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.gkehub.v1beta1.Membership, + protos.google.cloud.gkehub.v1beta1.OperationMetadata + > + > { this._log.info('updateMembership long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.updateMembership, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateMembership, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.gkehub.v1beta1.Membership, + protos.google.cloud.gkehub.v1beta1.OperationMetadata + >; } - /** - * Lists Memberships in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent (project and location) where the Memberships will be - * listed. Specified in the format `projects/* /locations/*`. - * `projects/* /locations/-` list memberships in all the regions. - * @param {number} [request.pageSize] - * Optional. When requesting a 'page' of resources, `page_size` specifies - * number of resources to return. If unspecified or set to 0, all resources - * will be returned. - * @param {string} [request.pageToken] - * Optional. Token returned by previous call to `ListMemberships` which - * specifies the position in the list from where to continue listing the - * resources. - * @param {string} [request.filter] - * Optional. Lists Memberships that match the filter expression, following the - * syntax outlined in https://google.aip.dev/160. - * - * Examples: - * - * - Name is `bar` in project `foo-proj` and location `global`: - * - * name = "projects/foo-proj/locations/global/membership/bar" - * - * - Memberships that have a label called `foo`: - * - * labels.foo:* - * - * - Memberships that have a label called `foo` whose value is `bar`: - * - * labels.foo = bar - * - * - Memberships in the CREATING state: - * - * state = CREATING - * @param {string} [request.orderBy] - * Optional. One or more fields to compare and use to sort the output. - * See https://google.aip.dev/132#ordering. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link protos.google.cloud.gkehub.v1beta1.Membership|Membership}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listMembershipsAsync()` - * method described below for async iteration which you can stop as 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 Memberships in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent (project and location) where the Memberships will be + * listed. Specified in the format `projects/* /locations/*`. + * `projects/* /locations/-` list memberships in all the regions. + * @param {number} [request.pageSize] + * Optional. When requesting a 'page' of resources, `page_size` specifies + * number of resources to return. If unspecified or set to 0, all resources + * will be returned. + * @param {string} [request.pageToken] + * Optional. Token returned by previous call to `ListMemberships` which + * specifies the position in the list from where to continue listing the + * resources. + * @param {string} [request.filter] + * Optional. Lists Memberships that match the filter expression, following the + * syntax outlined in https://google.aip.dev/160. + * + * Examples: + * + * - Name is `bar` in project `foo-proj` and location `global`: + * + * name = "projects/foo-proj/locations/global/membership/bar" + * + * - Memberships that have a label called `foo`: + * + * labels.foo:* + * + * - Memberships that have a label called `foo` whose value is `bar`: + * + * labels.foo = bar + * + * - Memberships in the CREATING state: + * + * state = CREATING + * @param {string} [request.orderBy] + * Optional. One or more fields to compare and use to sort the output. + * See https://google.aip.dev/132#ordering. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.gkehub.v1beta1.Membership|Membership}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listMembershipsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listMemberships( - request?: protos.google.cloud.gkehub.v1beta1.IListMembershipsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gkehub.v1beta1.IMembership[], - protos.google.cloud.gkehub.v1beta1.IListMembershipsRequest|null, - protos.google.cloud.gkehub.v1beta1.IListMembershipsResponse - ]>; + request?: protos.google.cloud.gkehub.v1beta1.IListMembershipsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gkehub.v1beta1.IMembership[], + protos.google.cloud.gkehub.v1beta1.IListMembershipsRequest | null, + protos.google.cloud.gkehub.v1beta1.IListMembershipsResponse, + ] + >; listMemberships( - request: protos.google.cloud.gkehub.v1beta1.IListMembershipsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.gkehub.v1beta1.IListMembershipsRequest, - protos.google.cloud.gkehub.v1beta1.IListMembershipsResponse|null|undefined, - protos.google.cloud.gkehub.v1beta1.IMembership>): void; + request: protos.google.cloud.gkehub.v1beta1.IListMembershipsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.gkehub.v1beta1.IListMembershipsRequest, + | protos.google.cloud.gkehub.v1beta1.IListMembershipsResponse + | null + | undefined, + protos.google.cloud.gkehub.v1beta1.IMembership + >, + ): void; listMemberships( - request: protos.google.cloud.gkehub.v1beta1.IListMembershipsRequest, - callback: PaginationCallback< - protos.google.cloud.gkehub.v1beta1.IListMembershipsRequest, - protos.google.cloud.gkehub.v1beta1.IListMembershipsResponse|null|undefined, - protos.google.cloud.gkehub.v1beta1.IMembership>): void; + request: protos.google.cloud.gkehub.v1beta1.IListMembershipsRequest, + callback: PaginationCallback< + protos.google.cloud.gkehub.v1beta1.IListMembershipsRequest, + | protos.google.cloud.gkehub.v1beta1.IListMembershipsResponse + | null + | undefined, + protos.google.cloud.gkehub.v1beta1.IMembership + >, + ): void; listMemberships( - request?: protos.google.cloud.gkehub.v1beta1.IListMembershipsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.gkehub.v1beta1.IListMembershipsRequest, - protos.google.cloud.gkehub.v1beta1.IListMembershipsResponse|null|undefined, - protos.google.cloud.gkehub.v1beta1.IMembership>, - callback?: PaginationCallback< + request?: protos.google.cloud.gkehub.v1beta1.IListMembershipsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.gkehub.v1beta1.IListMembershipsRequest, - protos.google.cloud.gkehub.v1beta1.IListMembershipsResponse|null|undefined, - protos.google.cloud.gkehub.v1beta1.IMembership>): - Promise<[ - protos.google.cloud.gkehub.v1beta1.IMembership[], - protos.google.cloud.gkehub.v1beta1.IListMembershipsRequest|null, - protos.google.cloud.gkehub.v1beta1.IListMembershipsResponse - ]>|void { + | protos.google.cloud.gkehub.v1beta1.IListMembershipsResponse + | null + | undefined, + protos.google.cloud.gkehub.v1beta1.IMembership + >, + callback?: PaginationCallback< + protos.google.cloud.gkehub.v1beta1.IListMembershipsRequest, + | protos.google.cloud.gkehub.v1beta1.IListMembershipsResponse + | null + | undefined, + protos.google.cloud.gkehub.v1beta1.IMembership + >, + ): Promise< + [ + protos.google.cloud.gkehub.v1beta1.IMembership[], + protos.google.cloud.gkehub.v1beta1.IListMembershipsRequest | null, + protos.google.cloud.gkehub.v1beta1.IListMembershipsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-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.gkehub.v1beta1.IListMembershipsRequest, - protos.google.cloud.gkehub.v1beta1.IListMembershipsResponse|null|undefined, - protos.google.cloud.gkehub.v1beta1.IMembership>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.gkehub.v1beta1.IListMembershipsRequest, + | protos.google.cloud.gkehub.v1beta1.IListMembershipsResponse + | null + | undefined, + protos.google.cloud.gkehub.v1beta1.IMembership + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listMemberships values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1348,193 +1860,197 @@ export class GkeHubMembershipServiceClient { this._log.info('listMemberships request %j', request); return this.innerApiCalls .listMemberships(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.gkehub.v1beta1.IMembership[], - protos.google.cloud.gkehub.v1beta1.IListMembershipsRequest|null, - protos.google.cloud.gkehub.v1beta1.IListMembershipsResponse - ]) => { - this._log.info('listMemberships values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.gkehub.v1beta1.IMembership[], + protos.google.cloud.gkehub.v1beta1.IListMembershipsRequest | null, + protos.google.cloud.gkehub.v1beta1.IListMembershipsResponse, + ]) => { + this._log.info('listMemberships values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listMemberships`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent (project and location) where the Memberships will be - * listed. Specified in the format `projects/* /locations/*`. - * `projects/* /locations/-` list memberships in all the regions. - * @param {number} [request.pageSize] - * Optional. When requesting a 'page' of resources, `page_size` specifies - * number of resources to return. If unspecified or set to 0, all resources - * will be returned. - * @param {string} [request.pageToken] - * Optional. Token returned by previous call to `ListMemberships` which - * specifies the position in the list from where to continue listing the - * resources. - * @param {string} [request.filter] - * Optional. Lists Memberships that match the filter expression, following the - * syntax outlined in https://google.aip.dev/160. - * - * Examples: - * - * - Name is `bar` in project `foo-proj` and location `global`: - * - * name = "projects/foo-proj/locations/global/membership/bar" - * - * - Memberships that have a label called `foo`: - * - * labels.foo:* - * - * - Memberships that have a label called `foo` whose value is `bar`: - * - * labels.foo = bar - * - * - Memberships in the CREATING state: - * - * state = CREATING - * @param {string} [request.orderBy] - * Optional. One or more fields to compare and use to sort the output. - * See https://google.aip.dev/132#ordering. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.gkehub.v1beta1.Membership|Membership} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listMembershipsAsync()` - * method described below for async iteration which you can stop as 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 `listMemberships`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent (project and location) where the Memberships will be + * listed. Specified in the format `projects/* /locations/*`. + * `projects/* /locations/-` list memberships in all the regions. + * @param {number} [request.pageSize] + * Optional. When requesting a 'page' of resources, `page_size` specifies + * number of resources to return. If unspecified or set to 0, all resources + * will be returned. + * @param {string} [request.pageToken] + * Optional. Token returned by previous call to `ListMemberships` which + * specifies the position in the list from where to continue listing the + * resources. + * @param {string} [request.filter] + * Optional. Lists Memberships that match the filter expression, following the + * syntax outlined in https://google.aip.dev/160. + * + * Examples: + * + * - Name is `bar` in project `foo-proj` and location `global`: + * + * name = "projects/foo-proj/locations/global/membership/bar" + * + * - Memberships that have a label called `foo`: + * + * labels.foo:* + * + * - Memberships that have a label called `foo` whose value is `bar`: + * + * labels.foo = bar + * + * - Memberships in the CREATING state: + * + * state = CREATING + * @param {string} [request.orderBy] + * Optional. One or more fields to compare and use to sort the output. + * See https://google.aip.dev/132#ordering. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.gkehub.v1beta1.Membership|Membership} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listMembershipsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listMembershipsStream( - request?: protos.google.cloud.gkehub.v1beta1.IListMembershipsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.gkehub.v1beta1.IListMembershipsRequest, + 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['listMemberships']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listMemberships stream %j', request); return this.descriptors.page.listMemberships.createStream( this.innerApiCalls.listMemberships as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listMemberships`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used 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 (project and location) where the Memberships will be - * listed. Specified in the format `projects/* /locations/*`. - * `projects/* /locations/-` list memberships in all the regions. - * @param {number} [request.pageSize] - * Optional. When requesting a 'page' of resources, `page_size` specifies - * number of resources to return. If unspecified or set to 0, all resources - * will be returned. - * @param {string} [request.pageToken] - * Optional. Token returned by previous call to `ListMemberships` which - * specifies the position in the list from where to continue listing the - * resources. - * @param {string} [request.filter] - * Optional. Lists Memberships that match the filter expression, following the - * syntax outlined in https://google.aip.dev/160. - * - * Examples: - * - * - Name is `bar` in project `foo-proj` and location `global`: - * - * name = "projects/foo-proj/locations/global/membership/bar" - * - * - Memberships that have a label called `foo`: - * - * labels.foo:* - * - * - Memberships that have a label called `foo` whose value is `bar`: - * - * labels.foo = bar - * - * - Memberships in the CREATING state: - * - * state = CREATING - * @param {string} [request.orderBy] - * Optional. One or more fields to compare and use to sort the output. - * See https://google.aip.dev/132#ordering. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.gkehub.v1beta1.Membership|Membership}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@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/gke_hub_membership_service.list_memberships.js - * region_tag:gkehub_v1beta1_generated_GkeHubMembershipService_ListMemberships_async - */ + /** + * Equivalent to `listMemberships`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used 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 (project and location) where the Memberships will be + * listed. Specified in the format `projects/* /locations/*`. + * `projects/* /locations/-` list memberships in all the regions. + * @param {number} [request.pageSize] + * Optional. When requesting a 'page' of resources, `page_size` specifies + * number of resources to return. If unspecified or set to 0, all resources + * will be returned. + * @param {string} [request.pageToken] + * Optional. Token returned by previous call to `ListMemberships` which + * specifies the position in the list from where to continue listing the + * resources. + * @param {string} [request.filter] + * Optional. Lists Memberships that match the filter expression, following the + * syntax outlined in https://google.aip.dev/160. + * + * Examples: + * + * - Name is `bar` in project `foo-proj` and location `global`: + * + * name = "projects/foo-proj/locations/global/membership/bar" + * + * - Memberships that have a label called `foo`: + * + * labels.foo:* + * + * - Memberships that have a label called `foo` whose value is `bar`: + * + * labels.foo = bar + * + * - Memberships in the CREATING state: + * + * state = CREATING + * @param {string} [request.orderBy] + * Optional. One or more fields to compare and use to sort the output. + * See https://google.aip.dev/132#ordering. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.gkehub.v1beta1.Membership|Membership}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@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/gke_hub_membership_service.list_memberships.js + * region_tag:gkehub_v1beta1_generated_GkeHubMembershipService_ListMemberships_async + */ listMembershipsAsync( - request?: protos.google.cloud.gkehub.v1beta1.IListMembershipsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.gkehub.v1beta1.IListMembershipsRequest, + 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['listMemberships']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listMemberships iterate %j', request); return this.descriptors.page.listMemberships.asyncIterate( this.innerApiCalls['listMemberships'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** - * Gets the access control policy for a resource. Returns an empty policy - * if the resource exists and does not have a policy set. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {Object} [request.options] - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. This field is only used by Cloud IAM. - * - * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Gets the access control policy for a resource. Returns an empty policy + * if the resource exists and does not have a policy set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {Object} [request.options] + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. This field is only used by Cloud IAM. + * + * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ getIamPolicy( request: IamProtos.google.iam.v1.GetIamPolicyRequest, options?: @@ -1548,40 +2064,40 @@ export class GkeHubMembershipServiceClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.getIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ setIamPolicy( request: IamProtos.google.iam.v1.SetIamPolicyRequest, options?: @@ -1595,41 +2111,41 @@ export class GkeHubMembershipServiceClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.setIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + */ testIamPermissions( request: IamProtos.google.iam.v1.TestIamPermissionsRequest, options?: @@ -1643,12 +2159,12 @@ export class GkeHubMembershipServiceClient { IamProtos.google.iam.v1.TestIamPermissionsResponse, IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { + >, + ): Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { return this.iamClient.testIamPermissions(request, options, callback); } -/** + /** * Gets information about a location. * * @param {Object} request @@ -1683,12 +2199,11 @@ export class GkeHubMembershipServiceClient { | 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. @@ -1721,12 +2236,12 @@ export class GkeHubMembershipServiceClient { */ 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. @@ -1769,22 +2284,22 @@ export class GkeHubMembershipServiceClient { 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); } /** @@ -1819,15 +2334,15 @@ export class GkeHubMembershipServiceClient { */ 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); } /** @@ -1861,7 +2376,7 @@ export class GkeHubMembershipServiceClient { * await client.cancelOperation({name: ''}); * ``` */ - cancelOperation( + cancelOperation( request: protos.google.longrunning.CancelOperationRequest, optionsOrCallback?: | gax.CallOptions @@ -1874,25 +2389,24 @@ export class GkeHubMembershipServiceClient { 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 @@ -1931,22 +2445,22 @@ export class GkeHubMembershipServiceClient { 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); } @@ -1961,7 +2475,7 @@ export class GkeHubMembershipServiceClient { * @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, @@ -1998,7 +2512,7 @@ export class GkeHubMembershipServiceClient { * @param {string} membership * @returns {string} Resource name string. */ - membershipPath(project:string,location:string,membership:string) { + membershipPath(project: string, location: string, membership: string) { return this.pathTemplates.membershipPathTemplate.render({ project: project, location: location, @@ -2014,7 +2528,8 @@ export class GkeHubMembershipServiceClient { * @returns {string} A string representing the project. */ matchProjectFromMembershipName(membershipName: string) { - return this.pathTemplates.membershipPathTemplate.match(membershipName).project; + return this.pathTemplates.membershipPathTemplate.match(membershipName) + .project; } /** @@ -2025,7 +2540,8 @@ export class GkeHubMembershipServiceClient { * @returns {string} A string representing the location. */ matchLocationFromMembershipName(membershipName: string) { - return this.pathTemplates.membershipPathTemplate.match(membershipName).location; + return this.pathTemplates.membershipPathTemplate.match(membershipName) + .location; } /** @@ -2036,7 +2552,8 @@ export class GkeHubMembershipServiceClient { * @returns {string} A string representing the membership. */ matchMembershipFromMembershipName(membershipName: string) { - return this.pathTemplates.membershipPathTemplate.match(membershipName).membership; + return this.pathTemplates.membershipPathTemplate.match(membershipName) + .membership; } /** @@ -2045,7 +2562,7 @@ export class GkeHubMembershipServiceClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -2070,15 +2587,19 @@ export class GkeHubMembershipServiceClient { */ close(): Promise { if (this.gkeHubMembershipServiceStub && !this._terminated) { - return this.gkeHubMembershipServiceStub.then(stub => { + return this.gkeHubMembershipServiceStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); - this.iamClient.close().catch(err => {throw err}); - this.locationsClient.close().catch(err => {throw err}); + this.iamClient.close().catch((err) => { + throw err; + }); + this.locationsClient.close().catch((err) => { + throw err; + }); void this.operationsClient.close(); }); } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-gkehub/src/v1beta1/index.ts b/packages/google-cloud-gkehub/src/v1beta1/index.ts index f1a64b946231..06f22f05e373 100644 --- a/packages/google-cloud-gkehub/src/v1beta1/index.ts +++ b/packages/google-cloud-gkehub/src/v1beta1/index.ts @@ -16,4 +16,4 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {GkeHubMembershipServiceClient} from './gke_hub_membership_service_client'; +export { GkeHubMembershipServiceClient } from './gke_hub_membership_service_client'; diff --git a/packages/google-cloud-gkehub/system-test/fixtures/sample/src/index.ts b/packages/google-cloud-gkehub/system-test/fixtures/sample/src/index.ts index 295751a96944..e7544191a49c 100644 --- a/packages/google-cloud-gkehub/system-test/fixtures/sample/src/index.ts +++ b/packages/google-cloud-gkehub/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 {GkeHubClient} from '@google-cloud/gke-hub'; +import { GkeHubClient } from '@google-cloud/gke-hub'; // check that the client class type name can be used function doStuffWithGkeHubClient(client: GkeHubClient) { diff --git a/packages/google-cloud-gkehub/system-test/install.ts b/packages/google-cloud-gkehub/system-test/install.ts index f66069aa3940..ccf167042d2e 100644 --- a/packages/google-cloud-gkehub/system-test/install.ts +++ b/packages/google-cloud-gkehub/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-gkehub/test/gapic_gke_hub_membership_service_v1beta1.ts b/packages/google-cloud-gkehub/test/gapic_gke_hub_membership_service_v1beta1.ts index 51bb49957d4f..c506e2fe61ae 100644 --- a/packages/google-cloud-gkehub/test/gapic_gke_hub_membership_service_v1beta1.ts +++ b/packages/google-cloud-gkehub/test/gapic_gke_hub_membership_service_v1beta1.ts @@ -19,2212 +19,3026 @@ 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 gkehubmembershipserviceModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf, LROperation, operationsProtos, IamProtos, LocationProtos} from 'google-gax'; +import { + protobuf, + LROperation, + operationsProtos, + IamProtos, + LocationProtos, +} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); +const root = protobuf.Root.fromJSON( + require('../protos/protos.json'), +).resolveAll(); // eslint-disable-next-line @typescript-eslint/no-unused-vars function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; } function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, { defaults: true }); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject, + ) as T; } function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); } -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error, +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); } -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +function stubLongRunningCall( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().rejects(callError) + : sinon.stub().resolves([mockOperation]); } -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +function stubLongRunningCallWithCallback( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().callsArgWith(2, callError) + : sinon.stub().callsArgWith(2, null, mockOperation); } -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error, +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); } - return sinon.stub().returns(mockStream); + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); } -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error, +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({ done: true, value: undefined }); + } + return Promise.resolve({ done: false, value: responses![counter++] }); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); } describe('v1beta1.GkeHubMembershipServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'gkehub.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient(); - 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 = gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient.servicePath; - assert.strictEqual(servicePath, 'gkehub.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'gkehub.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'gkehub.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'gkehub.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 gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'gkehub.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 gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'gkehub.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 gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); - - it('has port', () => { - const port = gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.gkeHubMembershipServiceStub, undefined); - await client.initialize(); - assert(client.gkeHubMembershipServiceStub); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'gkehub.googleapis.com'); + }); - it('has close method for the initialized client', done => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.gkeHubMembershipServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has universeDomain', () => { + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('has close method for the non-initialized client', done => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.gkeHubMembershipServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient + .servicePath; + assert.strictEqual(servicePath, 'gkehub.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient + .apiEndpoint; + assert.strictEqual(apiEndpoint, 'gkehub.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { universeDomain: 'example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'gkehub.example.com'); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { universe_domain: 'example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'gkehub.example.com'); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'gkehub.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 gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { universeDomain: 'configured.example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'gkehub.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 gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { universe_domain: 'example.com', universeDomain: 'example.net' }, + ); + }); }); - describe('getMembership', () => { - it('invokes getMembership without error', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta1.GetMembershipRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta1.GetMembershipRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta1.Membership() - ); - client.innerApiCalls.getMembership = stubSimpleCall(expectedResponse); - const [response] = await client.getMembership(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getMembership as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getMembership as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has port', () => { + const port = + gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient + .port; + assert(port); + assert(typeof port === 'number'); + }); - it('invokes getMembership without error using callback', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta1.GetMembershipRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta1.GetMembershipRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta1.Membership() - ); - client.innerApiCalls.getMembership = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getMembership( - request, - (err?: Error|null, result?: protos.google.cloud.gkehub.v1beta1.IMembership|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getMembership as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getMembership 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 gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient(); + assert(client); + }); - it('invokes getMembership with error', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta1.GetMembershipRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta1.GetMembershipRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getMembership = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getMembership(request), expectedError); - const actualRequest = (client.innerApiCalls.getMembership as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getMembership 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 gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + fallback: true, + }, + ); + assert(client); + }); - it('invokes getMembership with closed client', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta1.GetMembershipRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta1.GetMembershipRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getMembership(request), expectedError); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + assert.strictEqual(client.gkeHubMembershipServiceStub, undefined); + await client.initialize(); + assert(client.gkeHubMembershipServiceStub); }); - describe('generateConnectManifest', () => { - it('invokes generateConnectManifest without error', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta1.GenerateConnectManifestRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta1.GenerateConnectManifestRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta1.GenerateConnectManifestResponse() - ); - client.innerApiCalls.generateConnectManifest = stubSimpleCall(expectedResponse); - const [response] = await client.generateConnectManifest(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.generateConnectManifest as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.generateConnectManifest 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 gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + client.initialize().catch((err) => { + throw err; + }); + assert(client.gkeHubMembershipServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes generateConnectManifest without error using callback', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta1.GenerateConnectManifestRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta1.GenerateConnectManifestRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta1.GenerateConnectManifestResponse() - ); - client.innerApiCalls.generateConnectManifest = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.generateConnectManifest( - request, - (err?: Error|null, result?: protos.google.cloud.gkehub.v1beta1.IGenerateConnectManifestResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.generateConnectManifest as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.generateConnectManifest 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 gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + assert.strictEqual(client.gkeHubMembershipServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes generateConnectManifest with error', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta1.GenerateConnectManifestRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta1.GenerateConnectManifestRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.generateConnectManifest = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.generateConnectManifest(request), expectedError); - const actualRequest = (client.innerApiCalls.generateConnectManifest as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.generateConnectManifest 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 gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + 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 generateConnectManifest with closed client', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta1.GenerateConnectManifestRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta1.GenerateConnectManifestRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.generateConnectManifest(request), expectedError); - }); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + 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('getMembership', () => { + it('invokes getMembership without error', async () => { + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta1.GetMembershipRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta1.GetMembershipRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta1.Membership(), + ); + client.innerApiCalls.getMembership = stubSimpleCall(expectedResponse); + const [response] = await client.getMembership(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getMembership as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMembership as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('validateExclusivity', () => { - it('invokes validateExclusivity without error', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta1.ValidateExclusivityRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta1.ValidateExclusivityRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta1.ValidateExclusivityResponse() - ); - client.innerApiCalls.validateExclusivity = stubSimpleCall(expectedResponse); - const [response] = await client.validateExclusivity(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.validateExclusivity as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.validateExclusivity as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getMembership without error using callback', async () => { + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta1.GetMembershipRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta1.GetMembershipRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta1.Membership(), + ); + client.innerApiCalls.getMembership = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getMembership( + request, + ( + err?: Error | null, + result?: protos.google.cloud.gkehub.v1beta1.IMembership | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getMembership as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMembership as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes validateExclusivity without error using callback', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta1.ValidateExclusivityRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta1.ValidateExclusivityRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta1.ValidateExclusivityResponse() - ); - client.innerApiCalls.validateExclusivity = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.validateExclusivity( - request, - (err?: Error|null, result?: protos.google.cloud.gkehub.v1beta1.IValidateExclusivityResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.validateExclusivity as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.validateExclusivity as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getMembership with error', async () => { + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta1.GetMembershipRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta1.GetMembershipRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getMembership = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getMembership(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getMembership as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMembership as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes validateExclusivity with error', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta1.ValidateExclusivityRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta1.ValidateExclusivityRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.validateExclusivity = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.validateExclusivity(request), expectedError); - const actualRequest = (client.innerApiCalls.validateExclusivity as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.validateExclusivity as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getMembership with closed client', async () => { + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta1.GetMembershipRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta1.GetMembershipRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getMembership(request), expectedError); + }); + }); + + describe('generateConnectManifest', () => { + it('invokes generateConnectManifest without error', async () => { + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta1.GenerateConnectManifestRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta1.GenerateConnectManifestRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta1.GenerateConnectManifestResponse(), + ); + client.innerApiCalls.generateConnectManifest = + stubSimpleCall(expectedResponse); + const [response] = await client.generateConnectManifest(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.generateConnectManifest as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.generateConnectManifest as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes validateExclusivity with closed client', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta1.ValidateExclusivityRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta1.ValidateExclusivityRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.validateExclusivity(request), expectedError); - }); + it('invokes generateConnectManifest without error using callback', async () => { + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta1.GenerateConnectManifestRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta1.GenerateConnectManifestRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta1.GenerateConnectManifestResponse(), + ); + client.innerApiCalls.generateConnectManifest = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.generateConnectManifest( + request, + ( + err?: Error | null, + result?: protos.google.cloud.gkehub.v1beta1.IGenerateConnectManifestResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.generateConnectManifest as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.generateConnectManifest as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('generateExclusivityManifest', () => { - it('invokes generateExclusivityManifest without error', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta1.GenerateExclusivityManifestRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta1.GenerateExclusivityManifestRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta1.GenerateExclusivityManifestResponse() - ); - client.innerApiCalls.generateExclusivityManifest = stubSimpleCall(expectedResponse); - const [response] = await client.generateExclusivityManifest(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.generateExclusivityManifest as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.generateExclusivityManifest as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes generateConnectManifest with error', async () => { + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta1.GenerateConnectManifestRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta1.GenerateConnectManifestRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.generateConnectManifest = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.generateConnectManifest(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.generateConnectManifest as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.generateConnectManifest as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes generateExclusivityManifest without error using callback', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta1.GenerateExclusivityManifestRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta1.GenerateExclusivityManifestRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta1.GenerateExclusivityManifestResponse() - ); - client.innerApiCalls.generateExclusivityManifest = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.generateExclusivityManifest( - request, - (err?: Error|null, result?: protos.google.cloud.gkehub.v1beta1.IGenerateExclusivityManifestResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.generateExclusivityManifest as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.generateExclusivityManifest as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes generateConnectManifest with closed client', async () => { + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta1.GenerateConnectManifestRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta1.GenerateConnectManifestRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.generateConnectManifest(request), + expectedError, + ); + }); + }); + + describe('validateExclusivity', () => { + it('invokes validateExclusivity without error', async () => { + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta1.ValidateExclusivityRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta1.ValidateExclusivityRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta1.ValidateExclusivityResponse(), + ); + client.innerApiCalls.validateExclusivity = + stubSimpleCall(expectedResponse); + const [response] = await client.validateExclusivity(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.validateExclusivity as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.validateExclusivity as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes generateExclusivityManifest with error', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta1.GenerateExclusivityManifestRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta1.GenerateExclusivityManifestRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.generateExclusivityManifest = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.generateExclusivityManifest(request), expectedError); - const actualRequest = (client.innerApiCalls.generateExclusivityManifest as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.generateExclusivityManifest as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes validateExclusivity without error using callback', async () => { + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta1.ValidateExclusivityRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta1.ValidateExclusivityRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta1.ValidateExclusivityResponse(), + ); + client.innerApiCalls.validateExclusivity = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.validateExclusivity( + request, + ( + err?: Error | null, + result?: protos.google.cloud.gkehub.v1beta1.IValidateExclusivityResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.validateExclusivity as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.validateExclusivity as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes generateExclusivityManifest with closed client', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta1.GenerateExclusivityManifestRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta1.GenerateExclusivityManifestRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.generateExclusivityManifest(request), expectedError); - }); + it('invokes validateExclusivity with error', async () => { + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta1.ValidateExclusivityRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta1.ValidateExclusivityRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.validateExclusivity = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.validateExclusivity(request), expectedError); + const actualRequest = ( + client.innerApiCalls.validateExclusivity as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.validateExclusivity as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createMembership', () => { - it('invokes createMembership without error', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta1.CreateMembershipRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta1.CreateMembershipRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createMembership = stubLongRunningCall(expectedResponse); - const [operation] = await client.createMembership(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createMembership as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createMembership as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes validateExclusivity with closed client', async () => { + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta1.ValidateExclusivityRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta1.ValidateExclusivityRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.validateExclusivity(request), expectedError); + }); + }); + + describe('generateExclusivityManifest', () => { + it('invokes generateExclusivityManifest without error', async () => { + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta1.GenerateExclusivityManifestRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta1.GenerateExclusivityManifestRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta1.GenerateExclusivityManifestResponse(), + ); + client.innerApiCalls.generateExclusivityManifest = + stubSimpleCall(expectedResponse); + const [response] = await client.generateExclusivityManifest(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.generateExclusivityManifest as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.generateExclusivityManifest as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createMembership without error using callback', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta1.CreateMembershipRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta1.CreateMembershipRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createMembership = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createMembership( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createMembership as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createMembership as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes generateExclusivityManifest without error using callback', async () => { + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta1.GenerateExclusivityManifestRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta1.GenerateExclusivityManifestRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta1.GenerateExclusivityManifestResponse(), + ); + client.innerApiCalls.generateExclusivityManifest = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.generateExclusivityManifest( + request, + ( + err?: Error | null, + result?: protos.google.cloud.gkehub.v1beta1.IGenerateExclusivityManifestResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.generateExclusivityManifest as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.generateExclusivityManifest as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createMembership with call error', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta1.CreateMembershipRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta1.CreateMembershipRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createMembership = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createMembership(request), expectedError); - const actualRequest = (client.innerApiCalls.createMembership as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createMembership as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes generateExclusivityManifest with error', async () => { + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta1.GenerateExclusivityManifestRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta1.GenerateExclusivityManifestRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.generateExclusivityManifest = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.generateExclusivityManifest(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.generateExclusivityManifest as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.generateExclusivityManifest as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createMembership with LRO error', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta1.CreateMembershipRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta1.CreateMembershipRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createMembership = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createMembership(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createMembership as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createMembership as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes generateExclusivityManifest with closed client', async () => { + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta1.GenerateExclusivityManifestRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta1.GenerateExclusivityManifestRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.generateExclusivityManifest(request), + expectedError, + ); + }); + }); + + describe('createMembership', () => { + it('invokes createMembership without error', async () => { + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta1.CreateMembershipRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta1.CreateMembershipRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createMembership = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createMembership(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createMembership as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMembership as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateMembershipProgress without error', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateMembershipProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createMembership without error using callback', async () => { + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta1.CreateMembershipRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta1.CreateMembershipRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createMembership = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createMembership( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.gkehub.v1beta1.IMembership, + protos.google.cloud.gkehub.v1beta1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.gkehub.v1beta1.IMembership, + protos.google.cloud.gkehub.v1beta1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createMembership as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMembership as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateMembershipProgress with error', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateMembershipProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes createMembership with call error', async () => { + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta1.CreateMembershipRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta1.CreateMembershipRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createMembership = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createMembership(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createMembership as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMembership as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteMembership', () => { - it('invokes deleteMembership without error', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta1.DeleteMembershipRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta1.DeleteMembershipRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteMembership = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteMembership(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteMembership as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteMembership as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createMembership with LRO error', async () => { + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta1.CreateMembershipRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta1.CreateMembershipRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createMembership = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createMembership(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createMembership as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMembership as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteMembership without error using callback', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta1.DeleteMembershipRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta1.DeleteMembershipRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteMembership = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteMembership( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteMembership as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteMembership as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateMembershipProgress without error', async () => { + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateMembershipProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes deleteMembership with call error', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta1.DeleteMembershipRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta1.DeleteMembershipRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteMembership = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteMembership(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteMembership as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteMembership as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateMembershipProgress with error', async () => { + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateMembershipProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteMembership', () => { + it('invokes deleteMembership without error', async () => { + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta1.DeleteMembershipRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta1.DeleteMembershipRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteMembership = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteMembership(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteMembership as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteMembership as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteMembership with LRO error', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta1.DeleteMembershipRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta1.DeleteMembershipRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteMembership = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteMembership(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteMembership as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteMembership as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteMembership without error using callback', async () => { + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta1.DeleteMembershipRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta1.DeleteMembershipRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteMembership = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteMembership( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1beta1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1beta1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteMembership as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteMembership as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteMembershipProgress without error', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteMembershipProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes deleteMembership with call error', async () => { + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta1.DeleteMembershipRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta1.DeleteMembershipRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteMembership = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteMembership(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteMembership as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteMembership as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteMembershipProgress with error', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteMembershipProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes deleteMembership with LRO error', async () => { + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta1.DeleteMembershipRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta1.DeleteMembershipRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteMembership = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteMembership(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteMembership as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteMembership as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateMembership', () => { - it('invokes updateMembership without error', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta1.UpdateMembershipRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta1.UpdateMembershipRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateMembership = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateMembership(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateMembership as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateMembership as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteMembershipProgress without error', async () => { + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteMembershipProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes updateMembership without error using callback', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta1.UpdateMembershipRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta1.UpdateMembershipRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateMembership = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateMembership( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateMembership as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateMembership as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteMembershipProgress with error', async () => { + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteMembershipProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateMembership', () => { + it('invokes updateMembership without error', async () => { + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta1.UpdateMembershipRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta1.UpdateMembershipRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateMembership = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateMembership(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateMembership as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateMembership as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateMembership with call error', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta1.UpdateMembershipRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta1.UpdateMembershipRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateMembership = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateMembership(request), expectedError); - const actualRequest = (client.innerApiCalls.updateMembership as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateMembership as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateMembership without error using callback', async () => { + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta1.UpdateMembershipRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta1.UpdateMembershipRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateMembership = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateMembership( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.gkehub.v1beta1.IMembership, + protos.google.cloud.gkehub.v1beta1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.gkehub.v1beta1.IMembership, + protos.google.cloud.gkehub.v1beta1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateMembership as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateMembership as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateMembership with LRO error', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta1.UpdateMembershipRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta1.UpdateMembershipRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateMembership = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateMembership(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateMembership as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateMembership as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateMembership with call error', async () => { + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta1.UpdateMembershipRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta1.UpdateMembershipRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateMembership = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateMembership(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateMembership as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateMembership as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateMembershipProgress without error', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateMembershipProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes updateMembership with LRO error', async () => { + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta1.UpdateMembershipRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta1.UpdateMembershipRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateMembership = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateMembership(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateMembership as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateMembership as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateMembershipProgress with error', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateMembershipProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkUpdateMembershipProgress without error', async () => { + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdateMembershipProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('listMemberships', () => { - it('invokes listMemberships without error', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta1.ListMembershipsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta1.ListMembershipsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkehub.v1beta1.Membership()), - generateSampleMessage(new protos.google.cloud.gkehub.v1beta1.Membership()), - generateSampleMessage(new protos.google.cloud.gkehub.v1beta1.Membership()), - ]; - client.innerApiCalls.listMemberships = stubSimpleCall(expectedResponse); - const [response] = await client.listMemberships(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listMemberships as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listMemberships as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateMembershipProgress with error', async () => { + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateMembershipProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listMemberships', () => { + it('invokes listMemberships without error', async () => { + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta1.ListMembershipsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta1.ListMembershipsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.gkehub.v1beta1.Membership(), + ), + generateSampleMessage( + new protos.google.cloud.gkehub.v1beta1.Membership(), + ), + generateSampleMessage( + new protos.google.cloud.gkehub.v1beta1.Membership(), + ), + ]; + client.innerApiCalls.listMemberships = stubSimpleCall(expectedResponse); + const [response] = await client.listMemberships(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listMemberships as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMemberships as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listMemberships without error using callback', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta1.ListMembershipsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta1.ListMembershipsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkehub.v1beta1.Membership()), - generateSampleMessage(new protos.google.cloud.gkehub.v1beta1.Membership()), - generateSampleMessage(new protos.google.cloud.gkehub.v1beta1.Membership()), - ]; - client.innerApiCalls.listMemberships = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listMemberships( - request, - (err?: Error|null, result?: protos.google.cloud.gkehub.v1beta1.IMembership[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listMemberships as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listMemberships as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listMemberships without error using callback', async () => { + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta1.ListMembershipsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta1.ListMembershipsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.gkehub.v1beta1.Membership(), + ), + generateSampleMessage( + new protos.google.cloud.gkehub.v1beta1.Membership(), + ), + generateSampleMessage( + new protos.google.cloud.gkehub.v1beta1.Membership(), + ), + ]; + client.innerApiCalls.listMemberships = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listMemberships( + request, + ( + err?: Error | null, + result?: protos.google.cloud.gkehub.v1beta1.IMembership[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listMemberships as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMemberships as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listMemberships with error', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta1.ListMembershipsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta1.ListMembershipsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listMemberships = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listMemberships(request), expectedError); - const actualRequest = (client.innerApiCalls.listMemberships as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listMemberships as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listMemberships with error', async () => { + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta1.ListMembershipsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta1.ListMembershipsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listMemberships = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listMemberships(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listMemberships as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMemberships as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listMembershipsStream without error', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta1.ListMembershipsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta1.ListMembershipsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkehub.v1beta1.Membership()), - generateSampleMessage(new protos.google.cloud.gkehub.v1beta1.Membership()), - generateSampleMessage(new protos.google.cloud.gkehub.v1beta1.Membership()), - ]; - client.descriptors.page.listMemberships.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listMembershipsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.gkehub.v1beta1.Membership[] = []; - stream.on('data', (response: protos.google.cloud.gkehub.v1beta1.Membership) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listMemberships.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listMemberships, request)); - assert( - (client.descriptors.page.listMemberships.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listMembershipsStream without error', async () => { + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta1.ListMembershipsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta1.ListMembershipsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.gkehub.v1beta1.Membership(), + ), + generateSampleMessage( + new protos.google.cloud.gkehub.v1beta1.Membership(), + ), + generateSampleMessage( + new protos.google.cloud.gkehub.v1beta1.Membership(), + ), + ]; + client.descriptors.page.listMemberships.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listMembershipsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.gkehub.v1beta1.Membership[] = []; + stream.on( + 'data', + (response: protos.google.cloud.gkehub.v1beta1.Membership) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listMemberships.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listMemberships, request), + ); + assert( + (client.descriptors.page.listMemberships.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listMembershipsStream with error', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta1.ListMembershipsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta1.ListMembershipsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listMemberships.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listMembershipsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.gkehub.v1beta1.Membership[] = []; - stream.on('data', (response: protos.google.cloud.gkehub.v1beta1.Membership) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listMemberships.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listMemberships, request)); - assert( - (client.descriptors.page.listMemberships.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listMembershipsStream with error', async () => { + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta1.ListMembershipsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta1.ListMembershipsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listMemberships.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listMembershipsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.gkehub.v1beta1.Membership[] = []; + stream.on( + 'data', + (response: protos.google.cloud.gkehub.v1beta1.Membership) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listMemberships.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listMemberships, request), + ); + assert( + (client.descriptors.page.listMemberships.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listMemberships without error', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta1.ListMembershipsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta1.ListMembershipsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkehub.v1beta1.Membership()), - generateSampleMessage(new protos.google.cloud.gkehub.v1beta1.Membership()), - generateSampleMessage(new protos.google.cloud.gkehub.v1beta1.Membership()), - ]; - client.descriptors.page.listMemberships.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.gkehub.v1beta1.IMembership[] = []; - const iterable = client.listMembershipsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listMemberships.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listMemberships.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listMemberships without error', async () => { + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta1.ListMembershipsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta1.ListMembershipsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.gkehub.v1beta1.Membership(), + ), + generateSampleMessage( + new protos.google.cloud.gkehub.v1beta1.Membership(), + ), + generateSampleMessage( + new protos.google.cloud.gkehub.v1beta1.Membership(), + ), + ]; + client.descriptors.page.listMemberships.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.gkehub.v1beta1.IMembership[] = []; + const iterable = client.listMembershipsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listMemberships.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listMemberships.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listMemberships with error', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta1.ListMembershipsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta1.ListMembershipsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listMemberships.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listMembershipsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.gkehub.v1beta1.IMembership[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listMemberships.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listMemberships.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listMemberships with error', async () => { + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta1.ListMembershipsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta1.ListMembershipsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listMemberships.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listMembershipsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.gkehub.v1beta1.IMembership[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listMemberships.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listMemberships.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); }); - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.getIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getIamPolicy without error using callback', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes getIamPolicy with error', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.getIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.setIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes setIamPolicy without error using callback', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes setIamPolicy with error', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getIamPolicy without error using callback', async () => { + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .getIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.getIamPolicy as SinonStub).getCall(0)); }); - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); - const response = await client.testIamPermissions(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes testIamPermissions without error using callback', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.TestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0)); - }); - it('invokes testIamPermissions with error', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request, expectedOptions), expectedError); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getIamPolicy with error', async () => { + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.getIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - 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 gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - 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 gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.setIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - 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 gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes setIamPolicy without error using callback', async () => { + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .setIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.setIamPolicy as SinonStub).getCall(0)); }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - 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 gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - 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 gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('invokes setIamPolicy with error', async () => { + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.setIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - 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 gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - 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 gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + }); + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); + const response = await client.testIamPermissions( + request, + expectedOptions, + ); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - 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 gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - 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 gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('invokes testIamPermissions without error using callback', async () => { + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .testIamPermissions( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.TestIamPermissionsResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.testIamPermissions as SinonStub).getCall(0)); }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.IOperation[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes testIamPermissions with error', async () => { + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.testIamPermissions = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.testIamPermissions(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + 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 gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.IOperation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + 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 gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + 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 gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + 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 gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + 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 gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + 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 gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + 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 gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + 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 gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + 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 gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + 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 gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + 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 gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + 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 gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + 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 gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + 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 gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + 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('location', async () => { + const fakePath = '/rendered/path/location'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + 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('Path templates', () => { - - describe('location', async () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - 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('membership', async () => { - const fakePath = "/rendered/path/membership"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - membership: "membershipValue", - }; - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.membershipPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.membershipPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('membershipPath', () => { - const result = client.membershipPath("projectValue", "locationValue", "membershipValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.membershipPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromMembershipName', () => { - const result = client.matchProjectFromMembershipName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.membershipPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromMembershipName', () => { - const result = client.matchLocationFromMembershipName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.membershipPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchMembershipFromMembershipName', () => { - const result = client.matchMembershipFromMembershipName(fakePath); - assert.strictEqual(result, "membershipValue"); - assert((client.pathTemplates.membershipPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('membership', async () => { + const fakePath = '/rendered/path/membership'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + membership: 'membershipValue', + }; + const client = + new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.membershipPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.membershipPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('membershipPath', () => { + const result = client.membershipPath( + 'projectValue', + 'locationValue', + 'membershipValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.membershipPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromMembershipName', () => { + const result = client.matchProjectFromMembershipName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.membershipPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromMembershipName', () => { + const result = client.matchLocationFromMembershipName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.membershipPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchMembershipFromMembershipName', () => { + const result = client.matchMembershipFromMembershipName(fakePath); + assert.strictEqual(result, 'membershipValue'); + assert( + (client.pathTemplates.membershipPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('project', async () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient({ - 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 gkehubmembershipserviceModule.v1beta1.GkeHubMembershipServiceClient( + { + 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-gkehub/test/gapic_gke_hub_v1.ts b/packages/google-cloud-gkehub/test/gapic_gke_hub_v1.ts index 43c4c4631795..2d94b4acf54f 100644 --- a/packages/google-cloud-gkehub/test/gapic_gke_hub_v1.ts +++ b/packages/google-cloud-gkehub/test/gapic_gke_hub_v1.ts @@ -19,8026 +19,10315 @@ 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 gkehubModule 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('v1.GkeHubClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new gkehubModule.v1.GkeHubClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'gkehub.googleapis.com'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new gkehubModule.v1.GkeHubClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'gkehub.googleapis.com'); + }); - it('has universeDomain', () => { - const client = new gkehubModule.v1.GkeHubClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); + it('has universeDomain', () => { + const client = new gkehubModule.v1.GkeHubClient(); + 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 = gkehubModule.v1.GkeHubClient.servicePath; - assert.strictEqual(servicePath, 'gkehub.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = gkehubModule.v1.GkeHubClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'gkehub.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new gkehubModule.v1.GkeHubClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'gkehub.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 = gkehubModule.v1.GkeHubClient.servicePath; + assert.strictEqual(servicePath, 'gkehub.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = gkehubModule.v1.GkeHubClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'gkehub.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new gkehubModule.v1.GkeHubClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'gkehub.example.com'); + }); - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new gkehubModule.v1.GkeHubClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'gkehub.example.com'); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new gkehubModule.v1.GkeHubClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'gkehub.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 gkehubModule.v1.GkeHubClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'gkehub.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 gkehubModule.v1.GkeHubClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'gkehub.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 gkehubModule.v1.GkeHubClient({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 gkehubModule.v1.GkeHubClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'gkehub.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 gkehubModule.v1.GkeHubClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'gkehub.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 gkehubModule.v1.GkeHubClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('has port', () => { - const port = gkehubModule.v1.GkeHubClient.port; - assert(port); - assert(typeof port === 'number'); - }); + it('has port', () => { + const port = gkehubModule.v1.GkeHubClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('should create a client with no option', () => { - const client = new gkehubModule.v1.GkeHubClient(); - assert(client); - }); + it('should create a client with no option', () => { + const client = new gkehubModule.v1.GkeHubClient(); + assert(client); + }); - it('should create a client with gRPC fallback', () => { - const client = new gkehubModule.v1.GkeHubClient({ - fallback: true, - }); - assert(client); - }); + it('should create a client with gRPC fallback', () => { + const client = new gkehubModule.v1.GkeHubClient({ + fallback: true, + }); + assert(client); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.gkeHubStub, undefined); - await client.initialize(); - assert(client.gkeHubStub); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.gkeHubStub, undefined); + await client.initialize(); + assert(client.gkeHubStub); + }); - it('has close method for the initialized client', done => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.gkeHubStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('has close method for the initialized client', (done) => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.gkeHubStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has close method for the non-initialized client', done => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.gkeHubStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('has close method for the non-initialized client', (done) => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.gkeHubStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new gkehubModule.v1.GkeHubClient({ - 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 gkehubModule.v1.GkeHubClient({ + 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 gkehubModule.v1.GkeHubClient({ - 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 gkehubModule.v1.GkeHubClient({ + 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('getMembership', () => { + it('invokes getMembership without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.GetMembershipRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.GetMembershipRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.gkehub.v1.Membership(), + ); + client.innerApiCalls.getMembership = stubSimpleCall(expectedResponse); + const [response] = await client.getMembership(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getMembership as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMembership as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getMembership', () => { - it('invokes getMembership without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.GetMembershipRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.GetMembershipRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.gkehub.v1.Membership() - ); - client.innerApiCalls.getMembership = stubSimpleCall(expectedResponse); - const [response] = await client.getMembership(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getMembership as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getMembership as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getMembership without error using callback', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.GetMembershipRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.GetMembershipRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.gkehub.v1.Membership(), + ); + client.innerApiCalls.getMembership = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getMembership( + request, + ( + err?: Error | null, + result?: protos.google.cloud.gkehub.v1.IMembership | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getMembership as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMembership as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getMembership without error using callback', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.GetMembershipRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.GetMembershipRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.gkehub.v1.Membership() - ); - client.innerApiCalls.getMembership = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getMembership( - request, - (err?: Error|null, result?: protos.google.cloud.gkehub.v1.IMembership|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getMembership as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getMembership as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getMembership with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.GetMembershipRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.GetMembershipRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getMembership = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getMembership(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getMembership as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMembership as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getMembership with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.GetMembershipRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.GetMembershipRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getMembership = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getMembership(request), expectedError); - const actualRequest = (client.innerApiCalls.getMembership as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getMembership as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getMembership with closed client', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.GetMembershipRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.GetMembershipRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getMembership(request), expectedError); + }); + }); + + describe('getFeature', () => { + it('invokes getFeature without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.GetFeatureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.GetFeatureRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.gkehub.v1.Feature(), + ); + client.innerApiCalls.getFeature = stubSimpleCall(expectedResponse); + const [response] = await client.getFeature(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getMembership with closed client', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.GetMembershipRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.GetMembershipRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getMembership(request), expectedError); - }); + it('invokes getFeature without error using callback', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.GetFeatureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.GetFeatureRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.gkehub.v1.Feature(), + ); + client.innerApiCalls.getFeature = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getFeature( + request, + ( + err?: Error | null, + result?: protos.google.cloud.gkehub.v1.IFeature | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getFeature', () => { - it('invokes getFeature without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.GetFeatureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.GetFeatureRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.gkehub.v1.Feature() - ); - client.innerApiCalls.getFeature = stubSimpleCall(expectedResponse); - const [response] = await client.getFeature(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getFeature as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getFeature as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getFeature with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.GetFeatureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.GetFeatureRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getFeature = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getFeature(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getFeature without error using callback', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.GetFeatureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.GetFeatureRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.gkehub.v1.Feature() - ); - client.innerApiCalls.getFeature = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getFeature( - request, - (err?: Error|null, result?: protos.google.cloud.gkehub.v1.IFeature|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getFeature as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getFeature as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getFeature with closed client', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.GetFeatureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.GetFeatureRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getFeature(request), expectedError); + }); + }); + + describe('generateConnectManifest', () => { + it('invokes generateConnectManifest without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.GenerateConnectManifestRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.GenerateConnectManifestRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.gkehub.v1.GenerateConnectManifestResponse(), + ); + client.innerApiCalls.generateConnectManifest = + stubSimpleCall(expectedResponse); + const [response] = await client.generateConnectManifest(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.generateConnectManifest as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.generateConnectManifest as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getFeature with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.GetFeatureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.GetFeatureRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getFeature = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getFeature(request), expectedError); - const actualRequest = (client.innerApiCalls.getFeature as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getFeature as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes generateConnectManifest without error using callback', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.GenerateConnectManifestRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.GenerateConnectManifestRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.gkehub.v1.GenerateConnectManifestResponse(), + ); + client.innerApiCalls.generateConnectManifest = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.generateConnectManifest( + request, + ( + err?: Error | null, + result?: protos.google.cloud.gkehub.v1.IGenerateConnectManifestResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.generateConnectManifest as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.generateConnectManifest as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getFeature with closed client', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.GetFeatureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.GetFeatureRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getFeature(request), expectedError); - }); + it('invokes generateConnectManifest with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.GenerateConnectManifestRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.GenerateConnectManifestRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.generateConnectManifest = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.generateConnectManifest(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.generateConnectManifest as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.generateConnectManifest as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('generateConnectManifest', () => { - it('invokes generateConnectManifest without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.GenerateConnectManifestRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.GenerateConnectManifestRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.gkehub.v1.GenerateConnectManifestResponse() - ); - client.innerApiCalls.generateConnectManifest = stubSimpleCall(expectedResponse); - const [response] = await client.generateConnectManifest(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.generateConnectManifest as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.generateConnectManifest as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes generateConnectManifest with closed client', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.GenerateConnectManifestRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.GenerateConnectManifestRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.generateConnectManifest(request), + expectedError, + ); + }); + }); + + describe('getFleet', () => { + it('invokes getFleet without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.GetFleetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.GetFleetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.gkehub.v1.Fleet(), + ); + client.innerApiCalls.getFleet = stubSimpleCall(expectedResponse); + const [response] = await client.getFleet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getFleet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getFleet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes generateConnectManifest without error using callback', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.GenerateConnectManifestRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.GenerateConnectManifestRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.gkehub.v1.GenerateConnectManifestResponse() - ); - client.innerApiCalls.generateConnectManifest = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.generateConnectManifest( - request, - (err?: Error|null, result?: protos.google.cloud.gkehub.v1.IGenerateConnectManifestResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.generateConnectManifest as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.generateConnectManifest as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getFleet without error using callback', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.GetFleetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.GetFleetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.gkehub.v1.Fleet(), + ); + client.innerApiCalls.getFleet = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getFleet( + request, + ( + err?: Error | null, + result?: protos.google.cloud.gkehub.v1.IFleet | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getFleet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getFleet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes generateConnectManifest with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.GenerateConnectManifestRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.GenerateConnectManifestRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.generateConnectManifest = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.generateConnectManifest(request), expectedError); - const actualRequest = (client.innerApiCalls.generateConnectManifest as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.generateConnectManifest as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getFleet with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.GetFleetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.GetFleetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getFleet = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getFleet(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getFleet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getFleet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes generateConnectManifest with closed client', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.GenerateConnectManifestRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.GenerateConnectManifestRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.generateConnectManifest(request), expectedError); - }); + it('invokes getFleet with closed client', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.GetFleetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.GetFleetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getFleet(request), expectedError); + }); + }); + + describe('getScopeNamespace', () => { + it('invokes getScopeNamespace without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.GetScopeNamespaceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.GetScopeNamespaceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.gkehub.v1.Namespace(), + ); + client.innerApiCalls.getScopeNamespace = stubSimpleCall(expectedResponse); + const [response] = await client.getScopeNamespace(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getScopeNamespace as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getScopeNamespace as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getFleet', () => { - it('invokes getFleet without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.GetFleetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.GetFleetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.gkehub.v1.Fleet() - ); - client.innerApiCalls.getFleet = stubSimpleCall(expectedResponse); - const [response] = await client.getFleet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getFleet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getFleet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getScopeNamespace without error using callback', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.GetScopeNamespaceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.GetScopeNamespaceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.gkehub.v1.Namespace(), + ); + client.innerApiCalls.getScopeNamespace = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getScopeNamespace( + request, + ( + err?: Error | null, + result?: protos.google.cloud.gkehub.v1.INamespace | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getScopeNamespace as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getScopeNamespace as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getFleet without error using callback', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.GetFleetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.GetFleetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.gkehub.v1.Fleet() - ); - client.innerApiCalls.getFleet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getFleet( - request, - (err?: Error|null, result?: protos.google.cloud.gkehub.v1.IFleet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getFleet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getFleet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getScopeNamespace with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.GetScopeNamespaceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.GetScopeNamespaceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getScopeNamespace = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getScopeNamespace(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getScopeNamespace as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getScopeNamespace as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getFleet with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.GetFleetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.GetFleetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getFleet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getFleet(request), expectedError); - const actualRequest = (client.innerApiCalls.getFleet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getFleet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getScopeNamespace with closed client', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.GetScopeNamespaceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.GetScopeNamespaceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getScopeNamespace(request), expectedError); + }); + }); + + describe('getScopeRBACRoleBinding', () => { + it('invokes getScopeRBACRoleBinding without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.GetScopeRBACRoleBindingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.GetScopeRBACRoleBindingRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.gkehub.v1.RBACRoleBinding(), + ); + client.innerApiCalls.getScopeRbacRoleBinding = + stubSimpleCall(expectedResponse); + const [response] = await client.getScopeRBACRoleBinding(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getScopeRbacRoleBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getScopeRbacRoleBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getFleet with closed client', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.GetFleetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.GetFleetRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getFleet(request), expectedError); - }); + it('invokes getScopeRBACRoleBinding without error using callback', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.GetScopeRBACRoleBindingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.GetScopeRBACRoleBindingRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.gkehub.v1.RBACRoleBinding(), + ); + client.innerApiCalls.getScopeRbacRoleBinding = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getScopeRBACRoleBinding( + request, + ( + err?: Error | null, + result?: protos.google.cloud.gkehub.v1.IRBACRoleBinding | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getScopeRbacRoleBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getScopeRbacRoleBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getScopeNamespace', () => { - it('invokes getScopeNamespace without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.GetScopeNamespaceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.GetScopeNamespaceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.gkehub.v1.Namespace() - ); - client.innerApiCalls.getScopeNamespace = stubSimpleCall(expectedResponse); - const [response] = await client.getScopeNamespace(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getScopeNamespace as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getScopeNamespace as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getScopeRBACRoleBinding with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.GetScopeRBACRoleBindingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.GetScopeRBACRoleBindingRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getScopeRbacRoleBinding = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getScopeRBACRoleBinding(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.getScopeRbacRoleBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getScopeRbacRoleBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getScopeNamespace without error using callback', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.GetScopeNamespaceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.GetScopeNamespaceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.gkehub.v1.Namespace() - ); - client.innerApiCalls.getScopeNamespace = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getScopeNamespace( - request, - (err?: Error|null, result?: protos.google.cloud.gkehub.v1.INamespace|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getScopeNamespace as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getScopeNamespace as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getScopeRBACRoleBinding with closed client', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.GetScopeRBACRoleBindingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.GetScopeRBACRoleBindingRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.getScopeRBACRoleBinding(request), + expectedError, + ); + }); + }); + + describe('getScope', () => { + it('invokes getScope without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.GetScopeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.GetScopeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.gkehub.v1.Scope(), + ); + client.innerApiCalls.getScope = stubSimpleCall(expectedResponse); + const [response] = await client.getScope(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getScope as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getScope as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getScopeNamespace with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.GetScopeNamespaceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.GetScopeNamespaceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getScopeNamespace = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getScopeNamespace(request), expectedError); - const actualRequest = (client.innerApiCalls.getScopeNamespace as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getScopeNamespace as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getScope without error using callback', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.GetScopeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.GetScopeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.gkehub.v1.Scope(), + ); + client.innerApiCalls.getScope = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getScope( + request, + ( + err?: Error | null, + result?: protos.google.cloud.gkehub.v1.IScope | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getScope as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getScope as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getScopeNamespace with closed client', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.GetScopeNamespaceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.GetScopeNamespaceRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getScopeNamespace(request), expectedError); - }); + it('invokes getScope with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.GetScopeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.GetScopeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getScope = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getScope(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getScope as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getScope as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getScopeRBACRoleBinding', () => { - it('invokes getScopeRBACRoleBinding without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.GetScopeRBACRoleBindingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.GetScopeRBACRoleBindingRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.gkehub.v1.RBACRoleBinding() - ); - client.innerApiCalls.getScopeRbacRoleBinding = stubSimpleCall(expectedResponse); - const [response] = await client.getScopeRBACRoleBinding(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getScopeRbacRoleBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getScopeRbacRoleBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getScope with closed client', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.GetScopeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.GetScopeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getScope(request), expectedError); + }); + }); + + describe('getMembershipBinding', () => { + it('invokes getMembershipBinding without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.GetMembershipBindingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.GetMembershipBindingRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.gkehub.v1.MembershipBinding(), + ); + client.innerApiCalls.getMembershipBinding = + stubSimpleCall(expectedResponse); + const [response] = await client.getMembershipBinding(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getMembershipBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMembershipBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getScopeRBACRoleBinding without error using callback', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.GetScopeRBACRoleBindingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.GetScopeRBACRoleBindingRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.gkehub.v1.RBACRoleBinding() - ); - client.innerApiCalls.getScopeRbacRoleBinding = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getScopeRBACRoleBinding( - request, - (err?: Error|null, result?: protos.google.cloud.gkehub.v1.IRBACRoleBinding|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getScopeRbacRoleBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getScopeRbacRoleBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getMembershipBinding without error using callback', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.GetMembershipBindingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.GetMembershipBindingRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.gkehub.v1.MembershipBinding(), + ); + client.innerApiCalls.getMembershipBinding = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getMembershipBinding( + request, + ( + err?: Error | null, + result?: protos.google.cloud.gkehub.v1.IMembershipBinding | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getMembershipBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMembershipBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getScopeRBACRoleBinding with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.GetScopeRBACRoleBindingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.GetScopeRBACRoleBindingRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getScopeRbacRoleBinding = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getScopeRBACRoleBinding(request), expectedError); - const actualRequest = (client.innerApiCalls.getScopeRbacRoleBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getScopeRbacRoleBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getMembershipBinding with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.GetMembershipBindingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.GetMembershipBindingRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getMembershipBinding = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getMembershipBinding(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getMembershipBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMembershipBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getScopeRBACRoleBinding with closed client', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.GetScopeRBACRoleBindingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.GetScopeRBACRoleBindingRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getScopeRBACRoleBinding(request), expectedError); - }); + it('invokes getMembershipBinding with closed client', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.GetMembershipBindingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.GetMembershipBindingRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getMembershipBinding(request), expectedError); + }); + }); + + describe('getMembershipRBACRoleBinding', () => { + it('invokes getMembershipRBACRoleBinding without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.GetMembershipRBACRoleBindingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.GetMembershipRBACRoleBindingRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.gkehub.v1.RBACRoleBinding(), + ); + client.innerApiCalls.getMembershipRbacRoleBinding = + stubSimpleCall(expectedResponse); + const [response] = await client.getMembershipRBACRoleBinding(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getMembershipRbacRoleBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMembershipRbacRoleBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getScope', () => { - it('invokes getScope without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.GetScopeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.GetScopeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.gkehub.v1.Scope() - ); - client.innerApiCalls.getScope = stubSimpleCall(expectedResponse); - const [response] = await client.getScope(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getScope as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getScope as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getMembershipRBACRoleBinding without error using callback', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.GetMembershipRBACRoleBindingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.GetMembershipRBACRoleBindingRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.gkehub.v1.RBACRoleBinding(), + ); + client.innerApiCalls.getMembershipRbacRoleBinding = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getMembershipRBACRoleBinding( + request, + ( + err?: Error | null, + result?: protos.google.cloud.gkehub.v1.IRBACRoleBinding | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getMembershipRbacRoleBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMembershipRbacRoleBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getScope without error using callback', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.GetScopeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.GetScopeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.gkehub.v1.Scope() - ); - client.innerApiCalls.getScope = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getScope( - request, - (err?: Error|null, result?: protos.google.cloud.gkehub.v1.IScope|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getScope as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getScope as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getMembershipRBACRoleBinding with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.GetMembershipRBACRoleBindingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.GetMembershipRBACRoleBindingRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getMembershipRbacRoleBinding = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getMembershipRBACRoleBinding(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.getMembershipRbacRoleBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMembershipRbacRoleBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getScope with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.GetScopeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.GetScopeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getScope = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getScope(request), expectedError); - const actualRequest = (client.innerApiCalls.getScope as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getScope as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getMembershipRBACRoleBinding with closed client', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.GetMembershipRBACRoleBindingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.GetMembershipRBACRoleBindingRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.getMembershipRBACRoleBinding(request), + expectedError, + ); + }); + }); + + describe('generateMembershipRBACRoleBindingYAML', () => { + it('invokes generateMembershipRBACRoleBindingYAML without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.GenerateMembershipRBACRoleBindingYAMLRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.GenerateMembershipRBACRoleBindingYAMLRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.gkehub.v1.GenerateMembershipRBACRoleBindingYAMLResponse(), + ); + client.innerApiCalls.generateMembershipRbacRoleBindingYamL = + stubSimpleCall(expectedResponse); + const [response] = + await client.generateMembershipRBACRoleBindingYAML(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.generateMembershipRbacRoleBindingYamL as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.generateMembershipRbacRoleBindingYamL as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getScope with closed client', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.GetScopeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.GetScopeRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getScope(request), expectedError); - }); + it('invokes generateMembershipRBACRoleBindingYAML without error using callback', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.GenerateMembershipRBACRoleBindingYAMLRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.GenerateMembershipRBACRoleBindingYAMLRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.gkehub.v1.GenerateMembershipRBACRoleBindingYAMLResponse(), + ); + client.innerApiCalls.generateMembershipRbacRoleBindingYamL = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.generateMembershipRBACRoleBindingYAML( + request, + ( + err?: Error | null, + result?: protos.google.cloud.gkehub.v1.IGenerateMembershipRBACRoleBindingYAMLResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.generateMembershipRbacRoleBindingYamL as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.generateMembershipRbacRoleBindingYamL as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getMembershipBinding', () => { - it('invokes getMembershipBinding without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.GetMembershipBindingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.GetMembershipBindingRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.gkehub.v1.MembershipBinding() - ); - client.innerApiCalls.getMembershipBinding = stubSimpleCall(expectedResponse); - const [response] = await client.getMembershipBinding(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getMembershipBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getMembershipBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes generateMembershipRBACRoleBindingYAML with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.GenerateMembershipRBACRoleBindingYAMLRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.GenerateMembershipRBACRoleBindingYAMLRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.generateMembershipRbacRoleBindingYamL = + stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.generateMembershipRBACRoleBindingYAML(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.generateMembershipRbacRoleBindingYamL as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.generateMembershipRbacRoleBindingYamL as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getMembershipBinding without error using callback', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.GetMembershipBindingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.GetMembershipBindingRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.gkehub.v1.MembershipBinding() - ); - client.innerApiCalls.getMembershipBinding = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getMembershipBinding( - request, - (err?: Error|null, result?: protos.google.cloud.gkehub.v1.IMembershipBinding|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getMembershipBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getMembershipBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes generateMembershipRBACRoleBindingYAML with closed client', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.GenerateMembershipRBACRoleBindingYAMLRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.GenerateMembershipRBACRoleBindingYAMLRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.generateMembershipRBACRoleBindingYAML(request), + expectedError, + ); + }); + }); + + describe('createMembership', () => { + it('invokes createMembership without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.CreateMembershipRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.CreateMembershipRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createMembership = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createMembership(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createMembership as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMembership as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getMembershipBinding with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.GetMembershipBindingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.GetMembershipBindingRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getMembershipBinding = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getMembershipBinding(request), expectedError); - const actualRequest = (client.innerApiCalls.getMembershipBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getMembershipBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createMembership without error using callback', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.CreateMembershipRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.CreateMembershipRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createMembership = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createMembership( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.gkehub.v1.IMembership, + protos.google.cloud.gkehub.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.gkehub.v1.IMembership, + protos.google.cloud.gkehub.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createMembership as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMembership as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getMembershipBinding with closed client', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.GetMembershipBindingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.GetMembershipBindingRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getMembershipBinding(request), expectedError); - }); + it('invokes createMembership with call error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.CreateMembershipRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.CreateMembershipRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createMembership = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createMembership(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createMembership as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMembership as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getMembershipRBACRoleBinding', () => { - it('invokes getMembershipRBACRoleBinding without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.GetMembershipRBACRoleBindingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.GetMembershipRBACRoleBindingRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.gkehub.v1.RBACRoleBinding() - ); - client.innerApiCalls.getMembershipRbacRoleBinding = stubSimpleCall(expectedResponse); - const [response] = await client.getMembershipRBACRoleBinding(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getMembershipRbacRoleBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getMembershipRbacRoleBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createMembership with LRO error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.CreateMembershipRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.CreateMembershipRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createMembership = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createMembership(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createMembership as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMembership as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getMembershipRBACRoleBinding without error using callback', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.GetMembershipRBACRoleBindingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.GetMembershipRBACRoleBindingRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.gkehub.v1.RBACRoleBinding() - ); - client.innerApiCalls.getMembershipRbacRoleBinding = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getMembershipRBACRoleBinding( - request, - (err?: Error|null, result?: protos.google.cloud.gkehub.v1.IRBACRoleBinding|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getMembershipRbacRoleBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getMembershipRbacRoleBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateMembershipProgress without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateMembershipProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes getMembershipRBACRoleBinding with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.GetMembershipRBACRoleBindingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.GetMembershipRBACRoleBindingRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getMembershipRbacRoleBinding = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getMembershipRBACRoleBinding(request), expectedError); - const actualRequest = (client.innerApiCalls.getMembershipRbacRoleBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getMembershipRbacRoleBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateMembershipProgress with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateMembershipProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createFeature', () => { + it('invokes createFeature without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.CreateFeatureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.CreateFeatureRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createFeature = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createFeature(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getMembershipRBACRoleBinding with closed client', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.GetMembershipRBACRoleBindingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.GetMembershipRBACRoleBindingRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getMembershipRBACRoleBinding(request), expectedError); - }); + it('invokes createFeature without error using callback', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.CreateFeatureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.CreateFeatureRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createFeature = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createFeature( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.gkehub.v1.IFeature, + protos.google.cloud.gkehub.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.gkehub.v1.IFeature, + protos.google.cloud.gkehub.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('generateMembershipRBACRoleBindingYAML', () => { - it('invokes generateMembershipRBACRoleBindingYAML without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.GenerateMembershipRBACRoleBindingYAMLRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.GenerateMembershipRBACRoleBindingYAMLRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.gkehub.v1.GenerateMembershipRBACRoleBindingYAMLResponse() - ); - client.innerApiCalls.generateMembershipRbacRoleBindingYamL = stubSimpleCall(expectedResponse); - const [response] = await client.generateMembershipRBACRoleBindingYAML(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.generateMembershipRbacRoleBindingYamL as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.generateMembershipRbacRoleBindingYamL as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createFeature with call error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.CreateFeatureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.CreateFeatureRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createFeature = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createFeature(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes generateMembershipRBACRoleBindingYAML without error using callback', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.GenerateMembershipRBACRoleBindingYAMLRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.GenerateMembershipRBACRoleBindingYAMLRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.gkehub.v1.GenerateMembershipRBACRoleBindingYAMLResponse() - ); - client.innerApiCalls.generateMembershipRbacRoleBindingYamL = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.generateMembershipRBACRoleBindingYAML( - request, - (err?: Error|null, result?: protos.google.cloud.gkehub.v1.IGenerateMembershipRBACRoleBindingYAMLResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.generateMembershipRbacRoleBindingYamL as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.generateMembershipRbacRoleBindingYamL as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createFeature with LRO error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.CreateFeatureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.CreateFeatureRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createFeature = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createFeature(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes generateMembershipRBACRoleBindingYAML with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.GenerateMembershipRBACRoleBindingYAMLRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.GenerateMembershipRBACRoleBindingYAMLRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.generateMembershipRbacRoleBindingYamL = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.generateMembershipRBACRoleBindingYAML(request), expectedError); - const actualRequest = (client.innerApiCalls.generateMembershipRbacRoleBindingYamL as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.generateMembershipRbacRoleBindingYamL as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateFeatureProgress without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateFeatureProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes generateMembershipRBACRoleBindingYAML with closed client', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.GenerateMembershipRBACRoleBindingYAMLRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.GenerateMembershipRBACRoleBindingYAMLRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.generateMembershipRBACRoleBindingYAML(request), expectedError); - }); + it('invokes checkCreateFeatureProgress with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateFeatureProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteMembership', () => { + it('invokes deleteMembership without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.DeleteMembershipRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.DeleteMembershipRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteMembership = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteMembership(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteMembership as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteMembership as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createMembership', () => { - it('invokes createMembership without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.CreateMembershipRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.CreateMembershipRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createMembership = stubLongRunningCall(expectedResponse); - const [operation] = await client.createMembership(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createMembership as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createMembership as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteMembership without error using callback', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.DeleteMembershipRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.DeleteMembershipRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteMembership = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteMembership( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteMembership as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteMembership as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createMembership without error using callback', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.CreateMembershipRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.CreateMembershipRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createMembership = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createMembership( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createMembership as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createMembership as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteMembership with call error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.DeleteMembershipRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.DeleteMembershipRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteMembership = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteMembership(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteMembership as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteMembership as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createMembership with call error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.CreateMembershipRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.CreateMembershipRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createMembership = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createMembership(request), expectedError); - const actualRequest = (client.innerApiCalls.createMembership as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createMembership as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteMembership with LRO error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.DeleteMembershipRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.DeleteMembershipRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteMembership = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteMembership(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteMembership as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteMembership as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createMembership with LRO error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.CreateMembershipRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.CreateMembershipRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createMembership = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createMembership(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createMembership as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createMembership as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteMembershipProgress without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteMembershipProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkCreateMembershipProgress without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateMembershipProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkDeleteMembershipProgress with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteMembershipProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteFeature', () => { + it('invokes deleteFeature without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.DeleteFeatureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.DeleteFeatureRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteFeature = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteFeature(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateMembershipProgress with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateMembershipProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes deleteFeature without error using callback', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.DeleteFeatureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.DeleteFeatureRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteFeature = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteFeature( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createFeature', () => { - it('invokes createFeature without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.CreateFeatureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.CreateFeatureRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createFeature = stubLongRunningCall(expectedResponse); - const [operation] = await client.createFeature(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createFeature as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createFeature as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteFeature with call error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.DeleteFeatureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.DeleteFeatureRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteFeature = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteFeature(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createFeature without error using callback', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.CreateFeatureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.CreateFeatureRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createFeature = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createFeature( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createFeature as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createFeature as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteFeature with LRO error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.DeleteFeatureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.DeleteFeatureRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteFeature = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteFeature(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createFeature with call error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.CreateFeatureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.CreateFeatureRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createFeature = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createFeature(request), expectedError); - const actualRequest = (client.innerApiCalls.createFeature as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createFeature as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteFeatureProgress without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteFeatureProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes createFeature with LRO error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.CreateFeatureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.CreateFeatureRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createFeature = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createFeature(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createFeature as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createFeature as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteFeatureProgress with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteFeatureProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateMembership', () => { + it('invokes updateMembership without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.UpdateMembershipRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.UpdateMembershipRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateMembership = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateMembership(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateMembership as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateMembership as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateFeatureProgress without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateFeatureProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes updateMembership without error using callback', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.UpdateMembershipRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.UpdateMembershipRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateMembership = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateMembership( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.gkehub.v1.IMembership, + protos.google.cloud.gkehub.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.gkehub.v1.IMembership, + protos.google.cloud.gkehub.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateMembership as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateMembership as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateFeatureProgress with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateFeatureProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes updateMembership with call error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.UpdateMembershipRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.UpdateMembershipRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateMembership = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateMembership(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateMembership as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateMembership as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteMembership', () => { - it('invokes deleteMembership without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.DeleteMembershipRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.DeleteMembershipRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteMembership = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteMembership(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteMembership as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteMembership as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateMembership with LRO error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.UpdateMembershipRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.UpdateMembershipRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateMembership = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateMembership(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateMembership as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateMembership as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteMembership without error using callback', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.DeleteMembershipRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.DeleteMembershipRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteMembership = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteMembership( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteMembership as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteMembership as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateMembershipProgress without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdateMembershipProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes deleteMembership with call error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.DeleteMembershipRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.DeleteMembershipRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteMembership = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteMembership(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteMembership as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteMembership as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateMembershipProgress with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateMembershipProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateFeature', () => { + it('invokes updateFeature without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.UpdateFeatureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.UpdateFeatureRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateFeature = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateFeature(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteMembership with LRO error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.DeleteMembershipRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.DeleteMembershipRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteMembership = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteMembership(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteMembership as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteMembership as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateFeature without error using callback', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.UpdateFeatureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.UpdateFeatureRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateFeature = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateFeature( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.gkehub.v1.IFeature, + protos.google.cloud.gkehub.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.gkehub.v1.IFeature, + protos.google.cloud.gkehub.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteMembershipProgress without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteMembershipProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes updateFeature with call error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.UpdateFeatureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.UpdateFeatureRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateFeature = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateFeature(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteMembershipProgress with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteMembershipProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes updateFeature with LRO error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.UpdateFeatureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.UpdateFeatureRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateFeature = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateFeature(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteFeature', () => { - it('invokes deleteFeature without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.DeleteFeatureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.DeleteFeatureRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteFeature = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteFeature(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteFeature as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteFeature as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateFeatureProgress without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdateFeatureProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes deleteFeature without error using callback', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.DeleteFeatureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.DeleteFeatureRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteFeature = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteFeature( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteFeature as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteFeature as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateFeatureProgress with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateFeatureProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createFleet', () => { + it('invokes createFleet without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.CreateFleetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.CreateFleetRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createFleet = stubLongRunningCall(expectedResponse); + const [operation] = await client.createFleet(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createFleet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createFleet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteFeature with call error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.DeleteFeatureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.DeleteFeatureRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteFeature = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteFeature(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteFeature as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteFeature as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createFleet without error using callback', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.CreateFleetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.CreateFleetRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createFleet = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createFleet( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.gkehub.v1.IFleet, + protos.google.cloud.gkehub.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.gkehub.v1.IFleet, + protos.google.cloud.gkehub.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createFleet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createFleet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteFeature with LRO error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.DeleteFeatureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.DeleteFeatureRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteFeature = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteFeature(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteFeature as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteFeature as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createFleet with call error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.CreateFleetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.CreateFleetRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createFleet = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createFleet(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createFleet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createFleet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteFeatureProgress without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteFeatureProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createFleet with LRO error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.CreateFleetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.CreateFleetRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createFleet = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createFleet(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createFleet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createFleet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteFeatureProgress with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteFeatureProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkCreateFleetProgress without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateFleetProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('updateMembership', () => { - it('invokes updateMembership without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.UpdateMembershipRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.UpdateMembershipRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateMembership = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateMembership(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateMembership as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateMembership as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateFleetProgress with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkCreateFleetProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateFleet', () => { + it('invokes updateFleet without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.UpdateFleetRequest(), + ); + request.fleet ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.UpdateFleetRequest', + ['fleet', 'name'], + ); + request.fleet.name = defaultValue1; + const expectedHeaderRequestParams = `fleet.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateFleet = stubLongRunningCall(expectedResponse); + const [operation] = await client.updateFleet(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateFleet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateFleet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateMembership without error using callback', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.UpdateMembershipRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.UpdateMembershipRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateMembership = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateMembership( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateMembership as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateMembership as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateFleet without error using callback', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.UpdateFleetRequest(), + ); + request.fleet ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.UpdateFleetRequest', + ['fleet', 'name'], + ); + request.fleet.name = defaultValue1; + const expectedHeaderRequestParams = `fleet.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateFleet = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateFleet( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.gkehub.v1.IFleet, + protos.google.cloud.gkehub.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.gkehub.v1.IFleet, + protos.google.cloud.gkehub.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateFleet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateFleet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateMembership with call error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.UpdateMembershipRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.UpdateMembershipRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateMembership = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateMembership(request), expectedError); - const actualRequest = (client.innerApiCalls.updateMembership as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateMembership as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateFleet with call error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.UpdateFleetRequest(), + ); + request.fleet ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.UpdateFleetRequest', + ['fleet', 'name'], + ); + request.fleet.name = defaultValue1; + const expectedHeaderRequestParams = `fleet.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateFleet = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateFleet(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateFleet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateFleet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateMembership with LRO error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.UpdateMembershipRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.UpdateMembershipRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateMembership = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateMembership(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateMembership as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateMembership as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateFleet with LRO error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.UpdateFleetRequest(), + ); + request.fleet ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.UpdateFleetRequest', + ['fleet', 'name'], + ); + request.fleet.name = defaultValue1; + const expectedHeaderRequestParams = `fleet.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateFleet = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateFleet(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateFleet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateFleet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateMembershipProgress without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateMembershipProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkUpdateFleetProgress without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdateFleetProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkUpdateMembershipProgress with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateMembershipProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkUpdateFleetProgress with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkUpdateFleetProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteFleet', () => { + it('invokes deleteFleet without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.DeleteFleetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.DeleteFleetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteFleet = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteFleet(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteFleet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteFleet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateFeature', () => { - it('invokes updateFeature without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.UpdateFeatureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.UpdateFeatureRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateFeature = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateFeature(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateFeature as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateFeature as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteFleet without error using callback', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.DeleteFleetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.DeleteFleetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteFleet = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteFleet( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteFleet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteFleet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateFeature without error using callback', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.UpdateFeatureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.UpdateFeatureRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateFeature = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateFeature( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateFeature as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateFeature as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteFleet with call error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.DeleteFleetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.DeleteFleetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteFleet = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteFleet(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteFleet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteFleet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateFeature with call error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.UpdateFeatureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.UpdateFeatureRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateFeature = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateFeature(request), expectedError); - const actualRequest = (client.innerApiCalls.updateFeature as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateFeature as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteFleet with LRO error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.DeleteFleetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.DeleteFleetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteFleet = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteFleet(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteFleet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteFleet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateFeature with LRO error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.UpdateFeatureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.UpdateFeatureRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateFeature = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateFeature(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateFeature as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateFeature as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteFleetProgress without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteFleetProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkUpdateFeatureProgress without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateFeatureProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkDeleteFleetProgress with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkDeleteFleetProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createScopeNamespace', () => { + it('invokes createScopeNamespace without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.CreateScopeNamespaceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.CreateScopeNamespaceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createScopeNamespace = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createScopeNamespace(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createScopeNamespace as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createScopeNamespace as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateFeatureProgress with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateFeatureProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes createScopeNamespace without error using callback', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.CreateScopeNamespaceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.CreateScopeNamespaceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createScopeNamespace = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createScopeNamespace( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.gkehub.v1.INamespace, + protos.google.cloud.gkehub.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.gkehub.v1.INamespace, + protos.google.cloud.gkehub.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createScopeNamespace as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createScopeNamespace as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createFleet', () => { - it('invokes createFleet without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.CreateFleetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.CreateFleetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createFleet = stubLongRunningCall(expectedResponse); - const [operation] = await client.createFleet(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createFleet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createFleet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createScopeNamespace with call error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.CreateScopeNamespaceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.CreateScopeNamespaceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createScopeNamespace = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createScopeNamespace(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createScopeNamespace as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createScopeNamespace as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createFleet without error using callback', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.CreateFleetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.CreateFleetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createFleet = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createFleet( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createFleet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createFleet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createScopeNamespace with LRO error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.CreateScopeNamespaceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.CreateScopeNamespaceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createScopeNamespace = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createScopeNamespace(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createScopeNamespace as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createScopeNamespace as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createFleet with call error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.CreateFleetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.CreateFleetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createFleet = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createFleet(request), expectedError); - const actualRequest = (client.innerApiCalls.createFleet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createFleet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateScopeNamespaceProgress without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateScopeNamespaceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes createFleet with LRO error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.CreateFleetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.CreateFleetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createFleet = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createFleet(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createFleet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createFleet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateScopeNamespaceProgress with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateScopeNamespaceProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateScopeNamespace', () => { + it('invokes updateScopeNamespace without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.UpdateScopeNamespaceRequest(), + ); + request.scopeNamespace ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.UpdateScopeNamespaceRequest', + ['scopeNamespace', 'name'], + ); + request.scopeNamespace.name = defaultValue1; + const expectedHeaderRequestParams = `scope_namespace.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateScopeNamespace = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateScopeNamespace(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateScopeNamespace as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateScopeNamespace as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateFleetProgress without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateFleetProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes updateScopeNamespace without error using callback', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.UpdateScopeNamespaceRequest(), + ); + request.scopeNamespace ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.UpdateScopeNamespaceRequest', + ['scopeNamespace', 'name'], + ); + request.scopeNamespace.name = defaultValue1; + const expectedHeaderRequestParams = `scope_namespace.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateScopeNamespace = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateScopeNamespace( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.gkehub.v1.INamespace, + protos.google.cloud.gkehub.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.gkehub.v1.INamespace, + protos.google.cloud.gkehub.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateScopeNamespace as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateScopeNamespace as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateFleetProgress with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateFleetProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes updateScopeNamespace with call error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.UpdateScopeNamespaceRequest(), + ); + request.scopeNamespace ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.UpdateScopeNamespaceRequest', + ['scopeNamespace', 'name'], + ); + request.scopeNamespace.name = defaultValue1; + const expectedHeaderRequestParams = `scope_namespace.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateScopeNamespace = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateScopeNamespace(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateScopeNamespace as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateScopeNamespace as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateFleet', () => { - it('invokes updateFleet without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.UpdateFleetRequest() - ); - request.fleet ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.UpdateFleetRequest', ['fleet', 'name']); - request.fleet.name = defaultValue1; - const expectedHeaderRequestParams = `fleet.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateFleet = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateFleet(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateFleet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateFleet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateScopeNamespace with LRO error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.UpdateScopeNamespaceRequest(), + ); + request.scopeNamespace ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.UpdateScopeNamespaceRequest', + ['scopeNamespace', 'name'], + ); + request.scopeNamespace.name = defaultValue1; + const expectedHeaderRequestParams = `scope_namespace.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateScopeNamespace = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateScopeNamespace(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateScopeNamespace as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateScopeNamespace as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateFleet without error using callback', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.UpdateFleetRequest() - ); - request.fleet ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.UpdateFleetRequest', ['fleet', 'name']); - request.fleet.name = defaultValue1; - const expectedHeaderRequestParams = `fleet.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateFleet = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateFleet( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateFleet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateFleet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateScopeNamespaceProgress without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdateScopeNamespaceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes updateFleet with call error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.UpdateFleetRequest() - ); - request.fleet ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.UpdateFleetRequest', ['fleet', 'name']); - request.fleet.name = defaultValue1; - const expectedHeaderRequestParams = `fleet.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateFleet = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateFleet(request), expectedError); - const actualRequest = (client.innerApiCalls.updateFleet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateFleet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateScopeNamespaceProgress with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateScopeNamespaceProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteScopeNamespace', () => { + it('invokes deleteScopeNamespace without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.DeleteScopeNamespaceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.DeleteScopeNamespaceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteScopeNamespace = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteScopeNamespace(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteScopeNamespace as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteScopeNamespace as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateFleet with LRO error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.UpdateFleetRequest() - ); - request.fleet ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.UpdateFleetRequest', ['fleet', 'name']); - request.fleet.name = defaultValue1; - const expectedHeaderRequestParams = `fleet.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateFleet = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateFleet(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateFleet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateFleet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteScopeNamespace without error using callback', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.DeleteScopeNamespaceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.DeleteScopeNamespaceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteScopeNamespace = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteScopeNamespace( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteScopeNamespace as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteScopeNamespace as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateFleetProgress without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateFleetProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes deleteScopeNamespace with call error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.DeleteScopeNamespaceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.DeleteScopeNamespaceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteScopeNamespace = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteScopeNamespace(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteScopeNamespace as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteScopeNamespace as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateFleetProgress with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateFleetProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes deleteScopeNamespace with LRO error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.DeleteScopeNamespaceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.DeleteScopeNamespaceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteScopeNamespace = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteScopeNamespace(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteScopeNamespace as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteScopeNamespace as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteFleet', () => { - it('invokes deleteFleet without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.DeleteFleetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.DeleteFleetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteFleet = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteFleet(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteFleet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteFleet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteScopeNamespaceProgress without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteScopeNamespaceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes deleteFleet without error using callback', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.DeleteFleetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.DeleteFleetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteFleet = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteFleet( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteFleet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteFleet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteScopeNamespaceProgress with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteScopeNamespaceProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createScopeRBACRoleBinding', () => { + it('invokes createScopeRBACRoleBinding without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.CreateScopeRBACRoleBindingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.CreateScopeRBACRoleBindingRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createScopeRbacRoleBinding = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createScopeRBACRoleBinding(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createScopeRbacRoleBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createScopeRbacRoleBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteFleet with call error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.DeleteFleetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.DeleteFleetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteFleet = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteFleet(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteFleet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteFleet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createScopeRBACRoleBinding without error using callback', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.CreateScopeRBACRoleBindingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.CreateScopeRBACRoleBindingRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createScopeRbacRoleBinding = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createScopeRBACRoleBinding( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.gkehub.v1.IRBACRoleBinding, + protos.google.cloud.gkehub.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.gkehub.v1.IRBACRoleBinding, + protos.google.cloud.gkehub.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createScopeRbacRoleBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createScopeRbacRoleBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteFleet with LRO error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.DeleteFleetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.DeleteFleetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteFleet = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteFleet(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteFleet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteFleet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createScopeRBACRoleBinding with call error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.CreateScopeRBACRoleBindingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.CreateScopeRBACRoleBindingRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createScopeRbacRoleBinding = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.createScopeRBACRoleBinding(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.createScopeRbacRoleBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createScopeRbacRoleBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteFleetProgress without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteFleetProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createScopeRBACRoleBinding with LRO error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.CreateScopeRBACRoleBindingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.CreateScopeRBACRoleBindingRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createScopeRbacRoleBinding = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createScopeRBACRoleBinding(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createScopeRbacRoleBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createScopeRbacRoleBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteFleetProgress with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteFleetProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkCreateScopeRBACRoleBindingProgress without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = + await client.checkCreateScopeRBACRoleBindingProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('createScopeNamespace', () => { - it('invokes createScopeNamespace without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.CreateScopeNamespaceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.CreateScopeNamespaceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createScopeNamespace = stubLongRunningCall(expectedResponse); - const [operation] = await client.createScopeNamespace(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createScopeNamespace as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createScopeNamespace as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateScopeRBACRoleBindingProgress with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateScopeRBACRoleBindingProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateScopeRBACRoleBinding', () => { + it('invokes updateScopeRBACRoleBinding without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.UpdateScopeRBACRoleBindingRequest(), + ); + request.rbacrolebinding ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.UpdateScopeRBACRoleBindingRequest', + ['rbacrolebinding', 'name'], + ); + request.rbacrolebinding.name = defaultValue1; + const expectedHeaderRequestParams = `rbacrolebinding.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateScopeRbacRoleBinding = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateScopeRBACRoleBinding(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateScopeRbacRoleBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateScopeRbacRoleBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createScopeNamespace without error using callback', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.CreateScopeNamespaceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.CreateScopeNamespaceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createScopeNamespace = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createScopeNamespace( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createScopeNamespace as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createScopeNamespace as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateScopeRBACRoleBinding without error using callback', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.UpdateScopeRBACRoleBindingRequest(), + ); + request.rbacrolebinding ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.UpdateScopeRBACRoleBindingRequest', + ['rbacrolebinding', 'name'], + ); + request.rbacrolebinding.name = defaultValue1; + const expectedHeaderRequestParams = `rbacrolebinding.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateScopeRbacRoleBinding = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateScopeRBACRoleBinding( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.gkehub.v1.IRBACRoleBinding, + protos.google.cloud.gkehub.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.gkehub.v1.IRBACRoleBinding, + protos.google.cloud.gkehub.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateScopeRbacRoleBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateScopeRbacRoleBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createScopeNamespace with call error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.CreateScopeNamespaceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.CreateScopeNamespaceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createScopeNamespace = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createScopeNamespace(request), expectedError); - const actualRequest = (client.innerApiCalls.createScopeNamespace as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createScopeNamespace as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateScopeRBACRoleBinding with call error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.UpdateScopeRBACRoleBindingRequest(), + ); + request.rbacrolebinding ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.UpdateScopeRBACRoleBindingRequest', + ['rbacrolebinding', 'name'], + ); + request.rbacrolebinding.name = defaultValue1; + const expectedHeaderRequestParams = `rbacrolebinding.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateScopeRbacRoleBinding = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.updateScopeRBACRoleBinding(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.updateScopeRbacRoleBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateScopeRbacRoleBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createScopeNamespace with LRO error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.CreateScopeNamespaceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.CreateScopeNamespaceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createScopeNamespace = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createScopeNamespace(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createScopeNamespace as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createScopeNamespace as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateScopeNamespaceProgress without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateScopeNamespaceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateScopeNamespaceProgress with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateScopeNamespaceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes updateScopeRBACRoleBinding with LRO error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.UpdateScopeRBACRoleBindingRequest(), + ); + request.rbacrolebinding ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.UpdateScopeRBACRoleBindingRequest', + ['rbacrolebinding', 'name'], + ); + request.rbacrolebinding.name = defaultValue1; + const expectedHeaderRequestParams = `rbacrolebinding.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateScopeRbacRoleBinding = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateScopeRBACRoleBinding(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateScopeRbacRoleBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateScopeRbacRoleBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateScopeNamespace', () => { - it('invokes updateScopeNamespace without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.UpdateScopeNamespaceRequest() - ); - request.scopeNamespace ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.UpdateScopeNamespaceRequest', ['scopeNamespace', 'name']); - request.scopeNamespace.name = defaultValue1; - const expectedHeaderRequestParams = `scope_namespace.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateScopeNamespace = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateScopeNamespace(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateScopeNamespace as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateScopeNamespace as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateScopeNamespace without error using callback', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.UpdateScopeNamespaceRequest() - ); - request.scopeNamespace ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.UpdateScopeNamespaceRequest', ['scopeNamespace', 'name']); - request.scopeNamespace.name = defaultValue1; - const expectedHeaderRequestParams = `scope_namespace.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateScopeNamespace = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateScopeNamespace( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateScopeNamespace as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateScopeNamespace as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateScopeNamespace with call error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.UpdateScopeNamespaceRequest() - ); - request.scopeNamespace ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.UpdateScopeNamespaceRequest', ['scopeNamespace', 'name']); - request.scopeNamespace.name = defaultValue1; - const expectedHeaderRequestParams = `scope_namespace.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateScopeNamespace = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateScopeNamespace(request), expectedError); - const actualRequest = (client.innerApiCalls.updateScopeNamespace as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateScopeNamespace as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateScopeNamespace with LRO error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.UpdateScopeNamespaceRequest() - ); - request.scopeNamespace ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.UpdateScopeNamespaceRequest', ['scopeNamespace', 'name']); - request.scopeNamespace.name = defaultValue1; - const expectedHeaderRequestParams = `scope_namespace.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateScopeNamespace = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateScopeNamespace(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateScopeNamespace as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateScopeNamespace as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpdateScopeNamespaceProgress without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateScopeNamespaceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateScopeNamespaceProgress with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateScopeNamespaceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkUpdateScopeRBACRoleBindingProgress without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = + await client.checkUpdateScopeRBACRoleBindingProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('deleteScopeNamespace', () => { - it('invokes deleteScopeNamespace without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.DeleteScopeNamespaceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.DeleteScopeNamespaceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteScopeNamespace = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteScopeNamespace(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteScopeNamespace as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteScopeNamespace as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteScopeNamespace without error using callback', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.DeleteScopeNamespaceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.DeleteScopeNamespaceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteScopeNamespace = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteScopeNamespace( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteScopeNamespace as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteScopeNamespace as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteScopeNamespace with call error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.DeleteScopeNamespaceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.DeleteScopeNamespaceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteScopeNamespace = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteScopeNamespace(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteScopeNamespace as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteScopeNamespace as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteScopeNamespace with LRO error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.DeleteScopeNamespaceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.DeleteScopeNamespaceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteScopeNamespace = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteScopeNamespace(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteScopeNamespace as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteScopeNamespace as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteScopeNamespaceProgress without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteScopeNamespaceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteScopeNamespaceProgress with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteScopeNamespaceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkUpdateScopeRBACRoleBindingProgress with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateScopeRBACRoleBindingProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - - describe('createScopeRBACRoleBinding', () => { - it('invokes createScopeRBACRoleBinding without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.CreateScopeRBACRoleBindingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.CreateScopeRBACRoleBindingRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createScopeRbacRoleBinding = stubLongRunningCall(expectedResponse); - const [operation] = await client.createScopeRBACRoleBinding(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createScopeRbacRoleBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createScopeRbacRoleBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createScopeRBACRoleBinding without error using callback', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.CreateScopeRBACRoleBindingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.CreateScopeRBACRoleBindingRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createScopeRbacRoleBinding = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createScopeRBACRoleBinding( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createScopeRbacRoleBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createScopeRbacRoleBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createScopeRBACRoleBinding with call error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.CreateScopeRBACRoleBindingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.CreateScopeRBACRoleBindingRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createScopeRbacRoleBinding = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createScopeRBACRoleBinding(request), expectedError); - const actualRequest = (client.innerApiCalls.createScopeRbacRoleBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createScopeRbacRoleBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createScopeRBACRoleBinding with LRO error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.CreateScopeRBACRoleBindingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.CreateScopeRBACRoleBindingRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createScopeRbacRoleBinding = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createScopeRBACRoleBinding(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createScopeRbacRoleBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createScopeRbacRoleBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateScopeRBACRoleBindingProgress without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateScopeRBACRoleBindingProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateScopeRBACRoleBindingProgress with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateScopeRBACRoleBindingProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + }); + + describe('deleteScopeRBACRoleBinding', () => { + it('invokes deleteScopeRBACRoleBinding without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.DeleteScopeRBACRoleBindingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.DeleteScopeRBACRoleBindingRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteScopeRbacRoleBinding = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteScopeRBACRoleBinding(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteScopeRbacRoleBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteScopeRbacRoleBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateScopeRBACRoleBinding', () => { - it('invokes updateScopeRBACRoleBinding without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.UpdateScopeRBACRoleBindingRequest() - ); - request.rbacrolebinding ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.UpdateScopeRBACRoleBindingRequest', ['rbacrolebinding', 'name']); - request.rbacrolebinding.name = defaultValue1; - const expectedHeaderRequestParams = `rbacrolebinding.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateScopeRbacRoleBinding = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateScopeRBACRoleBinding(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateScopeRbacRoleBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateScopeRbacRoleBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateScopeRBACRoleBinding without error using callback', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.UpdateScopeRBACRoleBindingRequest() - ); - request.rbacrolebinding ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.UpdateScopeRBACRoleBindingRequest', ['rbacrolebinding', 'name']); - request.rbacrolebinding.name = defaultValue1; - const expectedHeaderRequestParams = `rbacrolebinding.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateScopeRbacRoleBinding = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateScopeRBACRoleBinding( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateScopeRbacRoleBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateScopeRbacRoleBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateScopeRBACRoleBinding with call error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.UpdateScopeRBACRoleBindingRequest() - ); - request.rbacrolebinding ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.UpdateScopeRBACRoleBindingRequest', ['rbacrolebinding', 'name']); - request.rbacrolebinding.name = defaultValue1; - const expectedHeaderRequestParams = `rbacrolebinding.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateScopeRbacRoleBinding = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateScopeRBACRoleBinding(request), expectedError); - const actualRequest = (client.innerApiCalls.updateScopeRbacRoleBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateScopeRbacRoleBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateScopeRBACRoleBinding with LRO error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.UpdateScopeRBACRoleBindingRequest() - ); - request.rbacrolebinding ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.UpdateScopeRBACRoleBindingRequest', ['rbacrolebinding', 'name']); - request.rbacrolebinding.name = defaultValue1; - const expectedHeaderRequestParams = `rbacrolebinding.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateScopeRbacRoleBinding = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateScopeRBACRoleBinding(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateScopeRbacRoleBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateScopeRbacRoleBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpdateScopeRBACRoleBindingProgress without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateScopeRBACRoleBindingProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateScopeRBACRoleBindingProgress with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateScopeRBACRoleBindingProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes deleteScopeRBACRoleBinding without error using callback', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.DeleteScopeRBACRoleBindingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.DeleteScopeRBACRoleBindingRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteScopeRbacRoleBinding = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteScopeRBACRoleBinding( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteScopeRbacRoleBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteScopeRbacRoleBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteScopeRBACRoleBinding', () => { - it('invokes deleteScopeRBACRoleBinding without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.DeleteScopeRBACRoleBindingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.DeleteScopeRBACRoleBindingRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteScopeRbacRoleBinding = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteScopeRBACRoleBinding(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteScopeRbacRoleBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteScopeRbacRoleBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteScopeRBACRoleBinding without error using callback', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.DeleteScopeRBACRoleBindingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.DeleteScopeRBACRoleBindingRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteScopeRbacRoleBinding = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteScopeRBACRoleBinding( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteScopeRbacRoleBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteScopeRbacRoleBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteScopeRBACRoleBinding with call error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.DeleteScopeRBACRoleBindingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.DeleteScopeRBACRoleBindingRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteScopeRbacRoleBinding = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteScopeRBACRoleBinding(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteScopeRbacRoleBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteScopeRbacRoleBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteScopeRBACRoleBinding with LRO error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.DeleteScopeRBACRoleBindingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.DeleteScopeRBACRoleBindingRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteScopeRbacRoleBinding = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteScopeRBACRoleBinding(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteScopeRbacRoleBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteScopeRbacRoleBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteScopeRBACRoleBindingProgress without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteScopeRBACRoleBindingProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteScopeRBACRoleBindingProgress with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteScopeRBACRoleBindingProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes deleteScopeRBACRoleBinding with call error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.DeleteScopeRBACRoleBindingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.DeleteScopeRBACRoleBindingRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteScopeRbacRoleBinding = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.deleteScopeRBACRoleBinding(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.deleteScopeRbacRoleBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteScopeRbacRoleBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createScope', () => { - it('invokes createScope without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.CreateScopeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.CreateScopeRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createScope = stubLongRunningCall(expectedResponse); - const [operation] = await client.createScope(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createScope as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createScope as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createScope without error using callback', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.CreateScopeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.CreateScopeRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createScope = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createScope( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createScope as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createScope as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createScope with call error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.CreateScopeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.CreateScopeRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createScope = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createScope(request), expectedError); - const actualRequest = (client.innerApiCalls.createScope as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createScope as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createScope with LRO error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.CreateScopeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.CreateScopeRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createScope = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createScope(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createScope as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createScope as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateScopeProgress without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateScopeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateScopeProgress with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateScopeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes deleteScopeRBACRoleBinding with LRO error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.DeleteScopeRBACRoleBindingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.DeleteScopeRBACRoleBindingRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteScopeRbacRoleBinding = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteScopeRBACRoleBinding(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteScopeRbacRoleBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteScopeRbacRoleBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateScope', () => { - it('invokes updateScope without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.UpdateScopeRequest() - ); - request.scope ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.UpdateScopeRequest', ['scope', 'name']); - request.scope.name = defaultValue1; - const expectedHeaderRequestParams = `scope.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateScope = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateScope(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateScope as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateScope as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteScopeRBACRoleBindingProgress without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = + await client.checkDeleteScopeRBACRoleBindingProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes updateScope without error using callback', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.UpdateScopeRequest() - ); - request.scope ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.UpdateScopeRequest', ['scope', 'name']); - request.scope.name = defaultValue1; - const expectedHeaderRequestParams = `scope.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateScope = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateScope( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateScope as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateScope as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteScopeRBACRoleBindingProgress with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteScopeRBACRoleBindingProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createScope', () => { + it('invokes createScope without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.CreateScopeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.CreateScopeRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createScope = stubLongRunningCall(expectedResponse); + const [operation] = await client.createScope(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createScope as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createScope as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateScope with call error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.UpdateScopeRequest() - ); - request.scope ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.UpdateScopeRequest', ['scope', 'name']); - request.scope.name = defaultValue1; - const expectedHeaderRequestParams = `scope.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateScope = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateScope(request), expectedError); - const actualRequest = (client.innerApiCalls.updateScope as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateScope as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createScope without error using callback', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.CreateScopeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.CreateScopeRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createScope = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createScope( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.gkehub.v1.IScope, + protos.google.cloud.gkehub.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.gkehub.v1.IScope, + protos.google.cloud.gkehub.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createScope as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createScope as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateScope with LRO error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.UpdateScopeRequest() - ); - request.scope ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.UpdateScopeRequest', ['scope', 'name']); - request.scope.name = defaultValue1; - const expectedHeaderRequestParams = `scope.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateScope = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateScope(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateScope as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateScope as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createScope with call error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.CreateScopeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.CreateScopeRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createScope = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createScope(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createScope as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createScope as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateScopeProgress without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateScopeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createScope with LRO error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.CreateScopeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.CreateScopeRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createScope = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createScope(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createScope as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createScope as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateScopeProgress with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateScopeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkCreateScopeProgress without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateScopeProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('deleteScope', () => { - it('invokes deleteScope without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.DeleteScopeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.DeleteScopeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteScope = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteScope(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteScope as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteScope as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateScopeProgress with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkCreateScopeProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateScope', () => { + it('invokes updateScope without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.UpdateScopeRequest(), + ); + request.scope ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.UpdateScopeRequest', + ['scope', 'name'], + ); + request.scope.name = defaultValue1; + const expectedHeaderRequestParams = `scope.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateScope = stubLongRunningCall(expectedResponse); + const [operation] = await client.updateScope(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateScope as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateScope as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteScope without error using callback', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.DeleteScopeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.DeleteScopeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteScope = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteScope( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteScope as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteScope as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateScope without error using callback', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.UpdateScopeRequest(), + ); + request.scope ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.UpdateScopeRequest', + ['scope', 'name'], + ); + request.scope.name = defaultValue1; + const expectedHeaderRequestParams = `scope.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateScope = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateScope( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.gkehub.v1.IScope, + protos.google.cloud.gkehub.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.gkehub.v1.IScope, + protos.google.cloud.gkehub.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateScope as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateScope as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteScope with call error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.DeleteScopeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.DeleteScopeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteScope = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteScope(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteScope as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteScope as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateScope with call error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.UpdateScopeRequest(), + ); + request.scope ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.UpdateScopeRequest', + ['scope', 'name'], + ); + request.scope.name = defaultValue1; + const expectedHeaderRequestParams = `scope.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateScope = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateScope(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateScope as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateScope as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteScope with LRO error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.DeleteScopeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.DeleteScopeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteScope = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteScope(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteScope as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteScope as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateScope with LRO error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.UpdateScopeRequest(), + ); + request.scope ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.UpdateScopeRequest', + ['scope', 'name'], + ); + request.scope.name = defaultValue1; + const expectedHeaderRequestParams = `scope.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateScope = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateScope(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateScope as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateScope as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteScopeProgress without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteScopeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkUpdateScopeProgress without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdateScopeProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkDeleteScopeProgress with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteScopeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkUpdateScopeProgress with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkUpdateScopeProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteScope', () => { + it('invokes deleteScope without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.DeleteScopeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.DeleteScopeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteScope = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteScope(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteScope as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteScope as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createMembershipBinding', () => { - it('invokes createMembershipBinding without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.CreateMembershipBindingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.CreateMembershipBindingRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createMembershipBinding = stubLongRunningCall(expectedResponse); - const [operation] = await client.createMembershipBinding(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createMembershipBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createMembershipBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteScope without error using callback', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.DeleteScopeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.DeleteScopeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteScope = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteScope( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteScope as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteScope as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createMembershipBinding without error using callback', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.CreateMembershipBindingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.CreateMembershipBindingRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createMembershipBinding = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createMembershipBinding( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createMembershipBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createMembershipBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteScope with call error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.DeleteScopeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.DeleteScopeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteScope = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteScope(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteScope as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteScope as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createMembershipBinding with call error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.CreateMembershipBindingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.CreateMembershipBindingRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createMembershipBinding = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createMembershipBinding(request), expectedError); - const actualRequest = (client.innerApiCalls.createMembershipBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createMembershipBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteScope with LRO error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.DeleteScopeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.DeleteScopeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteScope = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteScope(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteScope as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteScope as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createMembershipBinding with LRO error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.CreateMembershipBindingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.CreateMembershipBindingRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createMembershipBinding = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createMembershipBinding(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createMembershipBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createMembershipBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteScopeProgress without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteScopeProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkCreateMembershipBindingProgress without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateMembershipBindingProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkDeleteScopeProgress with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkDeleteScopeProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createMembershipBinding', () => { + it('invokes createMembershipBinding without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.CreateMembershipBindingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.CreateMembershipBindingRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createMembershipBinding = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createMembershipBinding(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createMembershipBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMembershipBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateMembershipBindingProgress with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateMembershipBindingProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes createMembershipBinding without error using callback', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.CreateMembershipBindingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.CreateMembershipBindingRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createMembershipBinding = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createMembershipBinding( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.gkehub.v1.IMembershipBinding, + protos.google.cloud.gkehub.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.gkehub.v1.IMembershipBinding, + protos.google.cloud.gkehub.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createMembershipBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMembershipBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateMembershipBinding', () => { - it('invokes updateMembershipBinding without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.UpdateMembershipBindingRequest() - ); - request.membershipBinding ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.UpdateMembershipBindingRequest', ['membershipBinding', 'name']); - request.membershipBinding.name = defaultValue1; - const expectedHeaderRequestParams = `membership_binding.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateMembershipBinding = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateMembershipBinding(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateMembershipBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateMembershipBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createMembershipBinding with call error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.CreateMembershipBindingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.CreateMembershipBindingRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createMembershipBinding = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.createMembershipBinding(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.createMembershipBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMembershipBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateMembershipBinding without error using callback', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.UpdateMembershipBindingRequest() - ); - request.membershipBinding ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.UpdateMembershipBindingRequest', ['membershipBinding', 'name']); - request.membershipBinding.name = defaultValue1; - const expectedHeaderRequestParams = `membership_binding.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateMembershipBinding = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateMembershipBinding( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateMembershipBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateMembershipBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createMembershipBinding with LRO error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.CreateMembershipBindingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.CreateMembershipBindingRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createMembershipBinding = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createMembershipBinding(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createMembershipBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMembershipBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateMembershipBinding with call error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.UpdateMembershipBindingRequest() - ); - request.membershipBinding ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.UpdateMembershipBindingRequest', ['membershipBinding', 'name']); - request.membershipBinding.name = defaultValue1; - const expectedHeaderRequestParams = `membership_binding.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateMembershipBinding = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateMembershipBinding(request), expectedError); - const actualRequest = (client.innerApiCalls.updateMembershipBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateMembershipBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateMembershipBindingProgress without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = + await client.checkCreateMembershipBindingProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes updateMembershipBinding with LRO error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.UpdateMembershipBindingRequest() - ); - request.membershipBinding ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.UpdateMembershipBindingRequest', ['membershipBinding', 'name']); - request.membershipBinding.name = defaultValue1; - const expectedHeaderRequestParams = `membership_binding.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateMembershipBinding = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateMembershipBinding(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateMembershipBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateMembershipBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateMembershipBindingProgress with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateMembershipBindingProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateMembershipBinding', () => { + it('invokes updateMembershipBinding without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.UpdateMembershipBindingRequest(), + ); + request.membershipBinding ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.UpdateMembershipBindingRequest', + ['membershipBinding', 'name'], + ); + request.membershipBinding.name = defaultValue1; + const expectedHeaderRequestParams = `membership_binding.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateMembershipBinding = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateMembershipBinding(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateMembershipBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateMembershipBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateMembershipBindingProgress without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateMembershipBindingProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes updateMembershipBinding without error using callback', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.UpdateMembershipBindingRequest(), + ); + request.membershipBinding ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.UpdateMembershipBindingRequest', + ['membershipBinding', 'name'], + ); + request.membershipBinding.name = defaultValue1; + const expectedHeaderRequestParams = `membership_binding.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateMembershipBinding = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateMembershipBinding( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.gkehub.v1.IMembershipBinding, + protos.google.cloud.gkehub.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.gkehub.v1.IMembershipBinding, + protos.google.cloud.gkehub.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateMembershipBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateMembershipBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateMembershipBindingProgress with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateMembershipBindingProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes updateMembershipBinding with call error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.UpdateMembershipBindingRequest(), + ); + request.membershipBinding ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.UpdateMembershipBindingRequest', + ['membershipBinding', 'name'], + ); + request.membershipBinding.name = defaultValue1; + const expectedHeaderRequestParams = `membership_binding.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateMembershipBinding = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.updateMembershipBinding(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.updateMembershipBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateMembershipBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteMembershipBinding', () => { - it('invokes deleteMembershipBinding without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.DeleteMembershipBindingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.DeleteMembershipBindingRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteMembershipBinding = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteMembershipBinding(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteMembershipBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteMembershipBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateMembershipBinding with LRO error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.UpdateMembershipBindingRequest(), + ); + request.membershipBinding ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.UpdateMembershipBindingRequest', + ['membershipBinding', 'name'], + ); + request.membershipBinding.name = defaultValue1; + const expectedHeaderRequestParams = `membership_binding.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateMembershipBinding = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateMembershipBinding(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateMembershipBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateMembershipBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteMembershipBinding without error using callback', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.DeleteMembershipBindingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.DeleteMembershipBindingRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteMembershipBinding = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteMembershipBinding( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteMembershipBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteMembershipBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateMembershipBindingProgress without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = + await client.checkUpdateMembershipBindingProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes deleteMembershipBinding with call error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.DeleteMembershipBindingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.DeleteMembershipBindingRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteMembershipBinding = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteMembershipBinding(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteMembershipBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteMembershipBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateMembershipBindingProgress with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateMembershipBindingProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteMembershipBinding', () => { + it('invokes deleteMembershipBinding without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.DeleteMembershipBindingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.DeleteMembershipBindingRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteMembershipBinding = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteMembershipBinding(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteMembershipBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteMembershipBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteMembershipBinding with LRO error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.DeleteMembershipBindingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.DeleteMembershipBindingRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteMembershipBinding = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteMembershipBinding(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteMembershipBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteMembershipBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteMembershipBinding without error using callback', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.DeleteMembershipBindingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.DeleteMembershipBindingRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteMembershipBinding = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteMembershipBinding( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteMembershipBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteMembershipBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteMembershipBindingProgress without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteMembershipBindingProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes deleteMembershipBinding with call error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.DeleteMembershipBindingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.DeleteMembershipBindingRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteMembershipBinding = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.deleteMembershipBinding(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.deleteMembershipBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteMembershipBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteMembershipBindingProgress with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteMembershipBindingProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes deleteMembershipBinding with LRO error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.DeleteMembershipBindingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.DeleteMembershipBindingRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteMembershipBinding = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteMembershipBinding(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteMembershipBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteMembershipBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createMembershipRBACRoleBinding', () => { - it('invokes createMembershipRBACRoleBinding without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.CreateMembershipRBACRoleBindingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.CreateMembershipRBACRoleBindingRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createMembershipRbacRoleBinding = stubLongRunningCall(expectedResponse); - const [operation] = await client.createMembershipRBACRoleBinding(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createMembershipRbacRoleBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createMembershipRbacRoleBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteMembershipBindingProgress without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = + await client.checkDeleteMembershipBindingProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes createMembershipRBACRoleBinding without error using callback', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.CreateMembershipRBACRoleBindingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.CreateMembershipRBACRoleBindingRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createMembershipRbacRoleBinding = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createMembershipRBACRoleBinding( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createMembershipRbacRoleBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createMembershipRbacRoleBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteMembershipBindingProgress with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteMembershipBindingProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createMembershipRBACRoleBinding', () => { + it('invokes createMembershipRBACRoleBinding without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.CreateMembershipRBACRoleBindingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.CreateMembershipRBACRoleBindingRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createMembershipRbacRoleBinding = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createMembershipRBACRoleBinding(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createMembershipRbacRoleBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMembershipRbacRoleBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createMembershipRBACRoleBinding with call error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.CreateMembershipRBACRoleBindingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.CreateMembershipRBACRoleBindingRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createMembershipRbacRoleBinding = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createMembershipRBACRoleBinding(request), expectedError); - const actualRequest = (client.innerApiCalls.createMembershipRbacRoleBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createMembershipRbacRoleBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createMembershipRBACRoleBinding without error using callback', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.CreateMembershipRBACRoleBindingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.CreateMembershipRBACRoleBindingRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createMembershipRbacRoleBinding = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createMembershipRBACRoleBinding( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.gkehub.v1.IRBACRoleBinding, + protos.google.cloud.gkehub.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.gkehub.v1.IRBACRoleBinding, + protos.google.cloud.gkehub.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createMembershipRbacRoleBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMembershipRbacRoleBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createMembershipRBACRoleBinding with LRO error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.CreateMembershipRBACRoleBindingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.CreateMembershipRBACRoleBindingRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createMembershipRbacRoleBinding = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createMembershipRBACRoleBinding(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createMembershipRbacRoleBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createMembershipRbacRoleBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createMembershipRBACRoleBinding with call error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.CreateMembershipRBACRoleBindingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.CreateMembershipRBACRoleBindingRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createMembershipRbacRoleBinding = + stubLongRunningCall(undefined, expectedError); + await assert.rejects( + client.createMembershipRBACRoleBinding(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.createMembershipRbacRoleBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMembershipRbacRoleBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateMembershipRBACRoleBindingProgress without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateMembershipRBACRoleBindingProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createMembershipRBACRoleBinding with LRO error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.CreateMembershipRBACRoleBindingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.CreateMembershipRBACRoleBindingRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createMembershipRbacRoleBinding = + stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.createMembershipRBACRoleBinding(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createMembershipRbacRoleBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMembershipRbacRoleBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateMembershipRBACRoleBindingProgress with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateMembershipRBACRoleBindingProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkCreateMembershipRBACRoleBindingProgress without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = + await client.checkCreateMembershipRBACRoleBindingProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('updateMembershipRBACRoleBinding', () => { - it('invokes updateMembershipRBACRoleBinding without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.UpdateMembershipRBACRoleBindingRequest() - ); - request.rbacrolebinding ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.UpdateMembershipRBACRoleBindingRequest', ['rbacrolebinding', 'name']); - request.rbacrolebinding.name = defaultValue1; - const expectedHeaderRequestParams = `rbacrolebinding.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateMembershipRbacRoleBinding = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateMembershipRBACRoleBinding(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateMembershipRbacRoleBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateMembershipRbacRoleBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateMembershipRBACRoleBindingProgress with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateMembershipRBACRoleBindingProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateMembershipRBACRoleBinding', () => { + it('invokes updateMembershipRBACRoleBinding without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.UpdateMembershipRBACRoleBindingRequest(), + ); + request.rbacrolebinding ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.UpdateMembershipRBACRoleBindingRequest', + ['rbacrolebinding', 'name'], + ); + request.rbacrolebinding.name = defaultValue1; + const expectedHeaderRequestParams = `rbacrolebinding.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateMembershipRbacRoleBinding = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateMembershipRBACRoleBinding(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateMembershipRbacRoleBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateMembershipRbacRoleBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateMembershipRBACRoleBinding without error using callback', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.UpdateMembershipRBACRoleBindingRequest() - ); - request.rbacrolebinding ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.UpdateMembershipRBACRoleBindingRequest', ['rbacrolebinding', 'name']); - request.rbacrolebinding.name = defaultValue1; - const expectedHeaderRequestParams = `rbacrolebinding.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateMembershipRbacRoleBinding = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateMembershipRBACRoleBinding( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateMembershipRbacRoleBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateMembershipRbacRoleBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateMembershipRBACRoleBinding without error using callback', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.UpdateMembershipRBACRoleBindingRequest(), + ); + request.rbacrolebinding ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.UpdateMembershipRBACRoleBindingRequest', + ['rbacrolebinding', 'name'], + ); + request.rbacrolebinding.name = defaultValue1; + const expectedHeaderRequestParams = `rbacrolebinding.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateMembershipRbacRoleBinding = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateMembershipRBACRoleBinding( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.gkehub.v1.IRBACRoleBinding, + protos.google.cloud.gkehub.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.gkehub.v1.IRBACRoleBinding, + protos.google.cloud.gkehub.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateMembershipRbacRoleBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateMembershipRbacRoleBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateMembershipRBACRoleBinding with call error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.UpdateMembershipRBACRoleBindingRequest() - ); - request.rbacrolebinding ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.UpdateMembershipRBACRoleBindingRequest', ['rbacrolebinding', 'name']); - request.rbacrolebinding.name = defaultValue1; - const expectedHeaderRequestParams = `rbacrolebinding.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateMembershipRbacRoleBinding = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateMembershipRBACRoleBinding(request), expectedError); - const actualRequest = (client.innerApiCalls.updateMembershipRbacRoleBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateMembershipRbacRoleBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateMembershipRBACRoleBinding with call error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.UpdateMembershipRBACRoleBindingRequest(), + ); + request.rbacrolebinding ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.UpdateMembershipRBACRoleBindingRequest', + ['rbacrolebinding', 'name'], + ); + request.rbacrolebinding.name = defaultValue1; + const expectedHeaderRequestParams = `rbacrolebinding.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateMembershipRbacRoleBinding = + stubLongRunningCall(undefined, expectedError); + await assert.rejects( + client.updateMembershipRBACRoleBinding(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.updateMembershipRbacRoleBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateMembershipRbacRoleBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateMembershipRBACRoleBinding with LRO error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.UpdateMembershipRBACRoleBindingRequest() - ); - request.rbacrolebinding ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.UpdateMembershipRBACRoleBindingRequest', ['rbacrolebinding', 'name']); - request.rbacrolebinding.name = defaultValue1; - const expectedHeaderRequestParams = `rbacrolebinding.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateMembershipRbacRoleBinding = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateMembershipRBACRoleBinding(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateMembershipRbacRoleBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateMembershipRbacRoleBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateMembershipRBACRoleBinding with LRO error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.UpdateMembershipRBACRoleBindingRequest(), + ); + request.rbacrolebinding ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.UpdateMembershipRBACRoleBindingRequest', + ['rbacrolebinding', 'name'], + ); + request.rbacrolebinding.name = defaultValue1; + const expectedHeaderRequestParams = `rbacrolebinding.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateMembershipRbacRoleBinding = + stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.updateMembershipRBACRoleBinding(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateMembershipRbacRoleBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateMembershipRbacRoleBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateMembershipRBACRoleBindingProgress without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateMembershipRBACRoleBindingProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkUpdateMembershipRBACRoleBindingProgress without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = + await client.checkUpdateMembershipRBACRoleBindingProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkUpdateMembershipRBACRoleBindingProgress with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateMembershipRBACRoleBindingProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkUpdateMembershipRBACRoleBindingProgress with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateMembershipRBACRoleBindingProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteMembershipRBACRoleBinding', () => { + it('invokes deleteMembershipRBACRoleBinding without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.DeleteMembershipRBACRoleBindingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.DeleteMembershipRBACRoleBindingRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteMembershipRbacRoleBinding = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteMembershipRBACRoleBinding(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteMembershipRbacRoleBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteMembershipRbacRoleBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteMembershipRBACRoleBinding', () => { - it('invokes deleteMembershipRBACRoleBinding without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.DeleteMembershipRBACRoleBindingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.DeleteMembershipRBACRoleBindingRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteMembershipRbacRoleBinding = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteMembershipRBACRoleBinding(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteMembershipRbacRoleBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteMembershipRbacRoleBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteMembershipRBACRoleBinding without error using callback', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.DeleteMembershipRBACRoleBindingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.DeleteMembershipRBACRoleBindingRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteMembershipRbacRoleBinding = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteMembershipRBACRoleBinding( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteMembershipRbacRoleBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteMembershipRbacRoleBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteMembershipRBACRoleBinding without error using callback', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.DeleteMembershipRBACRoleBindingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.DeleteMembershipRBACRoleBindingRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteMembershipRbacRoleBinding = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteMembershipRBACRoleBinding( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteMembershipRbacRoleBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteMembershipRbacRoleBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteMembershipRBACRoleBinding with call error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.DeleteMembershipRBACRoleBindingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.DeleteMembershipRBACRoleBindingRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteMembershipRbacRoleBinding = + stubLongRunningCall(undefined, expectedError); + await assert.rejects( + client.deleteMembershipRBACRoleBinding(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.deleteMembershipRbacRoleBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteMembershipRbacRoleBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteMembershipRBACRoleBinding with call error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.DeleteMembershipRBACRoleBindingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.DeleteMembershipRBACRoleBindingRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteMembershipRbacRoleBinding = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteMembershipRBACRoleBinding(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteMembershipRbacRoleBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteMembershipRbacRoleBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteMembershipRBACRoleBinding with LRO error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.DeleteMembershipRBACRoleBindingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.DeleteMembershipRBACRoleBindingRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteMembershipRbacRoleBinding = + stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = await client.deleteMembershipRBACRoleBinding(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteMembershipRbacRoleBinding as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteMembershipRbacRoleBinding as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteMembershipRBACRoleBinding with LRO error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.DeleteMembershipRBACRoleBindingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.DeleteMembershipRBACRoleBindingRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteMembershipRbacRoleBinding = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteMembershipRBACRoleBinding(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteMembershipRbacRoleBinding as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteMembershipRbacRoleBinding as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteMembershipRBACRoleBindingProgress without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = + await client.checkDeleteMembershipRBACRoleBindingProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkDeleteMembershipRBACRoleBindingProgress without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteMembershipRBACRoleBindingProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkDeleteMembershipRBACRoleBindingProgress with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteMembershipRBACRoleBindingProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listMemberships', () => { + it('invokes listMemberships without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListMembershipsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListMembershipsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.gkehub.v1.Membership()), + generateSampleMessage(new protos.google.cloud.gkehub.v1.Membership()), + generateSampleMessage(new protos.google.cloud.gkehub.v1.Membership()), + ]; + client.innerApiCalls.listMemberships = stubSimpleCall(expectedResponse); + const [response] = await client.listMemberships(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listMemberships as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMemberships as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteMembershipRBACRoleBindingProgress with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteMembershipRBACRoleBindingProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes listMemberships without error using callback', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListMembershipsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListMembershipsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.gkehub.v1.Membership()), + generateSampleMessage(new protos.google.cloud.gkehub.v1.Membership()), + generateSampleMessage(new protos.google.cloud.gkehub.v1.Membership()), + ]; + client.innerApiCalls.listMemberships = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listMemberships( + request, + ( + err?: Error | null, + result?: protos.google.cloud.gkehub.v1.IMembership[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listMemberships as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMemberships as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listMemberships', () => { - it('invokes listMemberships without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListMembershipsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListMembershipsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkehub.v1.Membership()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.Membership()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.Membership()), - ]; - client.innerApiCalls.listMemberships = stubSimpleCall(expectedResponse); - const [response] = await client.listMemberships(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listMemberships as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listMemberships as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listMemberships with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListMembershipsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListMembershipsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listMemberships = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listMemberships(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listMemberships as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMemberships as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listMemberships without error using callback', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListMembershipsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListMembershipsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkehub.v1.Membership()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.Membership()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.Membership()), - ]; - client.innerApiCalls.listMemberships = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listMemberships( - request, - (err?: Error|null, result?: protos.google.cloud.gkehub.v1.IMembership[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listMemberships as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listMemberships as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listMembershipsStream without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListMembershipsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListMembershipsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.gkehub.v1.Membership()), + generateSampleMessage(new protos.google.cloud.gkehub.v1.Membership()), + generateSampleMessage(new protos.google.cloud.gkehub.v1.Membership()), + ]; + client.descriptors.page.listMemberships.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listMembershipsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.gkehub.v1.Membership[] = []; + stream.on( + 'data', + (response: protos.google.cloud.gkehub.v1.Membership) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listMemberships.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listMemberships, request), + ); + assert( + (client.descriptors.page.listMemberships.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listMemberships with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListMembershipsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListMembershipsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listMemberships = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listMemberships(request), expectedError); - const actualRequest = (client.innerApiCalls.listMemberships as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listMemberships as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listMembershipsStream with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListMembershipsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListMembershipsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listMemberships.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listMembershipsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.gkehub.v1.Membership[] = []; + stream.on( + 'data', + (response: protos.google.cloud.gkehub.v1.Membership) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listMemberships.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listMemberships, request), + ); + assert( + (client.descriptors.page.listMemberships.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listMembershipsStream without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListMembershipsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListMembershipsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkehub.v1.Membership()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.Membership()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.Membership()), - ]; - client.descriptors.page.listMemberships.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listMembershipsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.gkehub.v1.Membership[] = []; - stream.on('data', (response: protos.google.cloud.gkehub.v1.Membership) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listMemberships.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listMemberships, request)); - assert( - (client.descriptors.page.listMemberships.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listMemberships without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListMembershipsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListMembershipsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.gkehub.v1.Membership()), + generateSampleMessage(new protos.google.cloud.gkehub.v1.Membership()), + generateSampleMessage(new protos.google.cloud.gkehub.v1.Membership()), + ]; + client.descriptors.page.listMemberships.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.gkehub.v1.IMembership[] = []; + const iterable = client.listMembershipsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listMemberships.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listMemberships.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listMembershipsStream with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListMembershipsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListMembershipsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listMemberships.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listMembershipsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.gkehub.v1.Membership[] = []; - stream.on('data', (response: protos.google.cloud.gkehub.v1.Membership) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listMemberships.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listMemberships, request)); - assert( - (client.descriptors.page.listMemberships.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listMemberships with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListMembershipsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListMembershipsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listMemberships.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listMembershipsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.gkehub.v1.IMembership[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listMemberships.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listMemberships.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listBoundMemberships', () => { + it('invokes listBoundMemberships without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListBoundMembershipsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListBoundMembershipsRequest', + ['scopeName'], + ); + request.scopeName = defaultValue1; + const expectedHeaderRequestParams = `scope_name=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.gkehub.v1.Membership()), + generateSampleMessage(new protos.google.cloud.gkehub.v1.Membership()), + generateSampleMessage(new protos.google.cloud.gkehub.v1.Membership()), + ]; + client.innerApiCalls.listBoundMemberships = + stubSimpleCall(expectedResponse); + const [response] = await client.listBoundMemberships(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listBoundMemberships as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listBoundMemberships as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listMemberships without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListMembershipsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListMembershipsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkehub.v1.Membership()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.Membership()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.Membership()), - ]; - client.descriptors.page.listMemberships.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.gkehub.v1.IMembership[] = []; - const iterable = client.listMembershipsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listBoundMemberships without error using callback', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListBoundMembershipsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListBoundMembershipsRequest', + ['scopeName'], + ); + request.scopeName = defaultValue1; + const expectedHeaderRequestParams = `scope_name=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.gkehub.v1.Membership()), + generateSampleMessage(new protos.google.cloud.gkehub.v1.Membership()), + generateSampleMessage(new protos.google.cloud.gkehub.v1.Membership()), + ]; + client.innerApiCalls.listBoundMemberships = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listBoundMemberships( + request, + ( + err?: Error | null, + result?: protos.google.cloud.gkehub.v1.IMembership[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listMemberships.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listMemberships.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listMemberships with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListMembershipsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListMembershipsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listMemberships.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listMembershipsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.gkehub.v1.IMembership[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listMemberships.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listMemberships.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.listBoundMemberships as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listBoundMemberships as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listBoundMemberships', () => { - it('invokes listBoundMemberships without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListBoundMembershipsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListBoundMembershipsRequest', ['scopeName']); - request.scopeName = defaultValue1; - const expectedHeaderRequestParams = `scope_name=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkehub.v1.Membership()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.Membership()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.Membership()), - ]; - client.innerApiCalls.listBoundMemberships = stubSimpleCall(expectedResponse); - const [response] = await client.listBoundMemberships(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listBoundMemberships as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listBoundMemberships as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listBoundMemberships with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListBoundMembershipsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListBoundMembershipsRequest', + ['scopeName'], + ); + request.scopeName = defaultValue1; + const expectedHeaderRequestParams = `scope_name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listBoundMemberships = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listBoundMemberships(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listBoundMemberships as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listBoundMemberships as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listBoundMemberships without error using callback', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListBoundMembershipsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListBoundMembershipsRequest', ['scopeName']); - request.scopeName = defaultValue1; - const expectedHeaderRequestParams = `scope_name=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkehub.v1.Membership()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.Membership()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.Membership()), - ]; - client.innerApiCalls.listBoundMemberships = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listBoundMemberships( - request, - (err?: Error|null, result?: protos.google.cloud.gkehub.v1.IMembership[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listBoundMemberships as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listBoundMemberships as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listBoundMembershipsStream without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListBoundMembershipsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListBoundMembershipsRequest', + ['scopeName'], + ); + request.scopeName = defaultValue1; + const expectedHeaderRequestParams = `scope_name=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.gkehub.v1.Membership()), + generateSampleMessage(new protos.google.cloud.gkehub.v1.Membership()), + generateSampleMessage(new protos.google.cloud.gkehub.v1.Membership()), + ]; + client.descriptors.page.listBoundMemberships.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listBoundMembershipsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.gkehub.v1.Membership[] = []; + stream.on( + 'data', + (response: protos.google.cloud.gkehub.v1.Membership) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listBoundMemberships.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listBoundMemberships, request), + ); + assert( + (client.descriptors.page.listBoundMemberships.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listBoundMemberships with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListBoundMembershipsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListBoundMembershipsRequest', ['scopeName']); - request.scopeName = defaultValue1; - const expectedHeaderRequestParams = `scope_name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listBoundMemberships = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listBoundMemberships(request), expectedError); - const actualRequest = (client.innerApiCalls.listBoundMemberships as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listBoundMemberships as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listBoundMembershipsStream with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListBoundMembershipsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListBoundMembershipsRequest', + ['scopeName'], + ); + request.scopeName = defaultValue1; + const expectedHeaderRequestParams = `scope_name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listBoundMemberships.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listBoundMembershipsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.gkehub.v1.Membership[] = []; + stream.on( + 'data', + (response: protos.google.cloud.gkehub.v1.Membership) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listBoundMemberships.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listBoundMemberships, request), + ); + assert( + (client.descriptors.page.listBoundMemberships.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listBoundMembershipsStream without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListBoundMembershipsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListBoundMembershipsRequest', ['scopeName']); - request.scopeName = defaultValue1; - const expectedHeaderRequestParams = `scope_name=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkehub.v1.Membership()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.Membership()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.Membership()), - ]; - client.descriptors.page.listBoundMemberships.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listBoundMembershipsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.gkehub.v1.Membership[] = []; - stream.on('data', (response: protos.google.cloud.gkehub.v1.Membership) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listBoundMemberships.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listBoundMemberships, request)); - assert( - (client.descriptors.page.listBoundMemberships.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listBoundMemberships without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListBoundMembershipsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListBoundMembershipsRequest', + ['scopeName'], + ); + request.scopeName = defaultValue1; + const expectedHeaderRequestParams = `scope_name=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.gkehub.v1.Membership()), + generateSampleMessage(new protos.google.cloud.gkehub.v1.Membership()), + generateSampleMessage(new protos.google.cloud.gkehub.v1.Membership()), + ]; + client.descriptors.page.listBoundMemberships.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.gkehub.v1.IMembership[] = []; + const iterable = client.listBoundMembershipsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listBoundMemberships.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listBoundMemberships.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listBoundMembershipsStream with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListBoundMembershipsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListBoundMembershipsRequest', ['scopeName']); - request.scopeName = defaultValue1; - const expectedHeaderRequestParams = `scope_name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listBoundMemberships.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listBoundMembershipsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.gkehub.v1.Membership[] = []; - stream.on('data', (response: protos.google.cloud.gkehub.v1.Membership) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listBoundMemberships.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listBoundMemberships, request)); - assert( - (client.descriptors.page.listBoundMemberships.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listBoundMemberships with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListBoundMembershipsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListBoundMembershipsRequest', + ['scopeName'], + ); + request.scopeName = defaultValue1; + const expectedHeaderRequestParams = `scope_name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listBoundMemberships.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listBoundMembershipsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.gkehub.v1.IMembership[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listBoundMemberships.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listBoundMemberships.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listFeatures', () => { + it('invokes listFeatures without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListFeaturesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListFeaturesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.gkehub.v1.Feature()), + generateSampleMessage(new protos.google.cloud.gkehub.v1.Feature()), + generateSampleMessage(new protos.google.cloud.gkehub.v1.Feature()), + ]; + client.innerApiCalls.listFeatures = stubSimpleCall(expectedResponse); + const [response] = await client.listFeatures(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listFeatures as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listFeatures as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listBoundMemberships without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListBoundMembershipsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListBoundMembershipsRequest', ['scopeName']); - request.scopeName = defaultValue1; - const expectedHeaderRequestParams = `scope_name=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkehub.v1.Membership()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.Membership()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.Membership()), - ]; - client.descriptors.page.listBoundMemberships.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.gkehub.v1.IMembership[] = []; - const iterable = client.listBoundMembershipsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listFeatures without error using callback', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListFeaturesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListFeaturesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.gkehub.v1.Feature()), + generateSampleMessage(new protos.google.cloud.gkehub.v1.Feature()), + generateSampleMessage(new protos.google.cloud.gkehub.v1.Feature()), + ]; + client.innerApiCalls.listFeatures = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listFeatures( + request, + ( + err?: Error | null, + result?: protos.google.cloud.gkehub.v1.IFeature[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listBoundMemberships.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listBoundMemberships.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listBoundMemberships with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListBoundMembershipsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListBoundMembershipsRequest', ['scopeName']); - request.scopeName = defaultValue1; - const expectedHeaderRequestParams = `scope_name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listBoundMemberships.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listBoundMembershipsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.gkehub.v1.IMembership[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listBoundMemberships.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listBoundMemberships.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.listFeatures as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listFeatures as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listFeatures', () => { - it('invokes listFeatures without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListFeaturesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListFeaturesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkehub.v1.Feature()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.Feature()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.Feature()), - ]; - client.innerApiCalls.listFeatures = stubSimpleCall(expectedResponse); - const [response] = await client.listFeatures(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listFeatures as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listFeatures as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listFeatures with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListFeaturesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListFeaturesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listFeatures = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listFeatures(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listFeatures as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listFeatures as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listFeatures without error using callback', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListFeaturesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListFeaturesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkehub.v1.Feature()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.Feature()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.Feature()), - ]; - client.innerApiCalls.listFeatures = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listFeatures( - request, - (err?: Error|null, result?: protos.google.cloud.gkehub.v1.IFeature[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listFeatures as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listFeatures as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listFeaturesStream without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListFeaturesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListFeaturesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.gkehub.v1.Feature()), + generateSampleMessage(new protos.google.cloud.gkehub.v1.Feature()), + generateSampleMessage(new protos.google.cloud.gkehub.v1.Feature()), + ]; + client.descriptors.page.listFeatures.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listFeaturesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.gkehub.v1.Feature[] = []; + stream.on('data', (response: protos.google.cloud.gkehub.v1.Feature) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listFeatures.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listFeatures, request), + ); + assert( + (client.descriptors.page.listFeatures.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listFeatures with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListFeaturesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListFeaturesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listFeatures = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listFeatures(request), expectedError); - const actualRequest = (client.innerApiCalls.listFeatures as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listFeatures as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listFeaturesStream with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListFeaturesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListFeaturesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listFeatures.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listFeaturesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.gkehub.v1.Feature[] = []; + stream.on('data', (response: protos.google.cloud.gkehub.v1.Feature) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listFeatures.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listFeatures, request), + ); + assert( + (client.descriptors.page.listFeatures.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listFeaturesStream without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListFeaturesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListFeaturesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkehub.v1.Feature()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.Feature()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.Feature()), - ]; - client.descriptors.page.listFeatures.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listFeaturesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.gkehub.v1.Feature[] = []; - stream.on('data', (response: protos.google.cloud.gkehub.v1.Feature) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listFeatures.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listFeatures, request)); - assert( - (client.descriptors.page.listFeatures.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listFeatures without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListFeaturesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListFeaturesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.gkehub.v1.Feature()), + generateSampleMessage(new protos.google.cloud.gkehub.v1.Feature()), + generateSampleMessage(new protos.google.cloud.gkehub.v1.Feature()), + ]; + client.descriptors.page.listFeatures.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.gkehub.v1.IFeature[] = []; + const iterable = client.listFeaturesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listFeatures.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listFeatures.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listFeaturesStream with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListFeaturesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListFeaturesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listFeatures.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listFeaturesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.gkehub.v1.Feature[] = []; - stream.on('data', (response: protos.google.cloud.gkehub.v1.Feature) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listFeatures.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listFeatures, request)); - assert( - (client.descriptors.page.listFeatures.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listFeatures with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListFeaturesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListFeaturesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listFeatures.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listFeaturesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.gkehub.v1.IFeature[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listFeatures.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listFeatures.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listFleets', () => { + it('invokes listFleets without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListFleetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListFleetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.gkehub.v1.Fleet()), + generateSampleMessage(new protos.google.cloud.gkehub.v1.Fleet()), + generateSampleMessage(new protos.google.cloud.gkehub.v1.Fleet()), + ]; + client.innerApiCalls.listFleets = stubSimpleCall(expectedResponse); + const [response] = await client.listFleets(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listFleets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listFleets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listFeatures without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListFeaturesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListFeaturesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkehub.v1.Feature()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.Feature()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.Feature()), - ]; - client.descriptors.page.listFeatures.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.gkehub.v1.IFeature[] = []; - const iterable = client.listFeaturesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listFleets without error using callback', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListFleetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListFleetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.gkehub.v1.Fleet()), + generateSampleMessage(new protos.google.cloud.gkehub.v1.Fleet()), + generateSampleMessage(new protos.google.cloud.gkehub.v1.Fleet()), + ]; + client.innerApiCalls.listFleets = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listFleets( + request, + ( + err?: Error | null, + result?: protos.google.cloud.gkehub.v1.IFleet[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listFeatures.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listFeatures.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listFeatures with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListFeaturesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListFeaturesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listFeatures.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listFeaturesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.gkehub.v1.IFeature[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listFeatures.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listFeatures.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.listFleets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listFleets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listFleets', () => { - it('invokes listFleets without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListFleetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListFleetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkehub.v1.Fleet()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.Fleet()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.Fleet()), - ]; - client.innerApiCalls.listFleets = stubSimpleCall(expectedResponse); - const [response] = await client.listFleets(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listFleets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listFleets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listFleets with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListFleetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListFleetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listFleets = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listFleets(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listFleets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listFleets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listFleets without error using callback', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListFleetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListFleetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkehub.v1.Fleet()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.Fleet()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.Fleet()), - ]; - client.innerApiCalls.listFleets = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listFleets( - request, - (err?: Error|null, result?: protos.google.cloud.gkehub.v1.IFleet[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listFleets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listFleets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listFleetsStream without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListFleetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListFleetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.gkehub.v1.Fleet()), + generateSampleMessage(new protos.google.cloud.gkehub.v1.Fleet()), + generateSampleMessage(new protos.google.cloud.gkehub.v1.Fleet()), + ]; + client.descriptors.page.listFleets.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listFleetsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.gkehub.v1.Fleet[] = []; + stream.on('data', (response: protos.google.cloud.gkehub.v1.Fleet) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listFleets.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listFleets, request), + ); + assert( + (client.descriptors.page.listFleets.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listFleets with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListFleetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListFleetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listFleets = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listFleets(request), expectedError); - const actualRequest = (client.innerApiCalls.listFleets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listFleets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listFleetsStream with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListFleetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListFleetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listFleets.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listFleetsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.gkehub.v1.Fleet[] = []; + stream.on('data', (response: protos.google.cloud.gkehub.v1.Fleet) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listFleets.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listFleets, request), + ); + assert( + (client.descriptors.page.listFleets.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listFleetsStream without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListFleetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListFleetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkehub.v1.Fleet()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.Fleet()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.Fleet()), - ]; - client.descriptors.page.listFleets.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listFleetsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.gkehub.v1.Fleet[] = []; - stream.on('data', (response: protos.google.cloud.gkehub.v1.Fleet) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listFleets.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listFleets, request)); - assert( - (client.descriptors.page.listFleets.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listFleets without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListFleetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListFleetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.gkehub.v1.Fleet()), + generateSampleMessage(new protos.google.cloud.gkehub.v1.Fleet()), + generateSampleMessage(new protos.google.cloud.gkehub.v1.Fleet()), + ]; + client.descriptors.page.listFleets.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.gkehub.v1.IFleet[] = []; + const iterable = client.listFleetsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listFleets.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.listFleets.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listFleetsStream with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListFleetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListFleetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listFleets.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listFleetsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.gkehub.v1.Fleet[] = []; - stream.on('data', (response: protos.google.cloud.gkehub.v1.Fleet) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listFleets.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listFleets, request)); - assert( - (client.descriptors.page.listFleets.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listFleets with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListFleetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListFleetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listFleets.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError, + ); + const iterable = client.listFleetsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.gkehub.v1.IFleet[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listFleets.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.listFleets.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listScopeNamespaces', () => { + it('invokes listScopeNamespaces without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListScopeNamespacesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListScopeNamespacesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.gkehub.v1.Namespace()), + generateSampleMessage(new protos.google.cloud.gkehub.v1.Namespace()), + generateSampleMessage(new protos.google.cloud.gkehub.v1.Namespace()), + ]; + client.innerApiCalls.listScopeNamespaces = + stubSimpleCall(expectedResponse); + const [response] = await client.listScopeNamespaces(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listScopeNamespaces as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listScopeNamespaces as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listFleets without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListFleetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListFleetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkehub.v1.Fleet()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.Fleet()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.Fleet()), - ]; - client.descriptors.page.listFleets.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.gkehub.v1.IFleet[] = []; - const iterable = client.listFleetsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listScopeNamespaces without error using callback', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListScopeNamespacesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListScopeNamespacesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.gkehub.v1.Namespace()), + generateSampleMessage(new protos.google.cloud.gkehub.v1.Namespace()), + generateSampleMessage(new protos.google.cloud.gkehub.v1.Namespace()), + ]; + client.innerApiCalls.listScopeNamespaces = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listScopeNamespaces( + request, + ( + err?: Error | null, + result?: protos.google.cloud.gkehub.v1.INamespace[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listFleets.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listFleets.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listFleets with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListFleetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListFleetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listFleets.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listFleetsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.gkehub.v1.IFleet[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listFleets.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listFleets.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.listScopeNamespaces as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listScopeNamespaces as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listScopeNamespaces', () => { - it('invokes listScopeNamespaces without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListScopeNamespacesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListScopeNamespacesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkehub.v1.Namespace()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.Namespace()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.Namespace()), - ]; - client.innerApiCalls.listScopeNamespaces = stubSimpleCall(expectedResponse); - const [response] = await client.listScopeNamespaces(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listScopeNamespaces as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listScopeNamespaces as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listScopeNamespaces with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListScopeNamespacesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListScopeNamespacesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listScopeNamespaces = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listScopeNamespaces(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listScopeNamespaces as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listScopeNamespaces as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listScopeNamespaces without error using callback', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListScopeNamespacesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListScopeNamespacesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkehub.v1.Namespace()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.Namespace()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.Namespace()), - ]; - client.innerApiCalls.listScopeNamespaces = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listScopeNamespaces( - request, - (err?: Error|null, result?: protos.google.cloud.gkehub.v1.INamespace[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listScopeNamespaces as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listScopeNamespaces as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listScopeNamespacesStream without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListScopeNamespacesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListScopeNamespacesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.gkehub.v1.Namespace()), + generateSampleMessage(new protos.google.cloud.gkehub.v1.Namespace()), + generateSampleMessage(new protos.google.cloud.gkehub.v1.Namespace()), + ]; + client.descriptors.page.listScopeNamespaces.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listScopeNamespacesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.gkehub.v1.Namespace[] = []; + stream.on( + 'data', + (response: protos.google.cloud.gkehub.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.listScopeNamespaces.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listScopeNamespaces, request), + ); + assert( + (client.descriptors.page.listScopeNamespaces.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listScopeNamespaces with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListScopeNamespacesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListScopeNamespacesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listScopeNamespaces = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listScopeNamespaces(request), expectedError); - const actualRequest = (client.innerApiCalls.listScopeNamespaces as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listScopeNamespaces as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listScopeNamespacesStream with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListScopeNamespacesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListScopeNamespacesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listScopeNamespaces.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listScopeNamespacesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.gkehub.v1.Namespace[] = []; + stream.on( + 'data', + (response: protos.google.cloud.gkehub.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.listScopeNamespaces.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listScopeNamespaces, request), + ); + assert( + (client.descriptors.page.listScopeNamespaces.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listScopeNamespacesStream without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListScopeNamespacesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListScopeNamespacesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkehub.v1.Namespace()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.Namespace()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.Namespace()), - ]; - client.descriptors.page.listScopeNamespaces.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listScopeNamespacesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.gkehub.v1.Namespace[] = []; - stream.on('data', (response: protos.google.cloud.gkehub.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.listScopeNamespaces.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listScopeNamespaces, request)); - assert( - (client.descriptors.page.listScopeNamespaces.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listScopeNamespaces without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListScopeNamespacesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListScopeNamespacesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.gkehub.v1.Namespace()), + generateSampleMessage(new protos.google.cloud.gkehub.v1.Namespace()), + generateSampleMessage(new protos.google.cloud.gkehub.v1.Namespace()), + ]; + client.descriptors.page.listScopeNamespaces.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.gkehub.v1.INamespace[] = []; + const iterable = client.listScopeNamespacesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listScopeNamespaces.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listScopeNamespaces.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listScopeNamespacesStream with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListScopeNamespacesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListScopeNamespacesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listScopeNamespaces.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listScopeNamespacesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.gkehub.v1.Namespace[] = []; - stream.on('data', (response: protos.google.cloud.gkehub.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.listScopeNamespaces.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listScopeNamespaces, request)); - assert( - (client.descriptors.page.listScopeNamespaces.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listScopeNamespaces with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListScopeNamespacesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListScopeNamespacesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listScopeNamespaces.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listScopeNamespacesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.gkehub.v1.INamespace[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listScopeNamespaces.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listScopeNamespaces.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listScopeRBACRoleBindings', () => { + it('invokes listScopeRBACRoleBindings without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListScopeRBACRoleBindingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListScopeRBACRoleBindingsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.gkehub.v1.RBACRoleBinding(), + ), + generateSampleMessage( + new protos.google.cloud.gkehub.v1.RBACRoleBinding(), + ), + generateSampleMessage( + new protos.google.cloud.gkehub.v1.RBACRoleBinding(), + ), + ]; + client.innerApiCalls.listScopeRbacRoleBindings = + stubSimpleCall(expectedResponse); + const [response] = await client.listScopeRBACRoleBindings(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listScopeRbacRoleBindings as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listScopeRbacRoleBindings as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listScopeNamespaces without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListScopeNamespacesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListScopeNamespacesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkehub.v1.Namespace()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.Namespace()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.Namespace()), - ]; - client.descriptors.page.listScopeNamespaces.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.gkehub.v1.INamespace[] = []; - const iterable = client.listScopeNamespacesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listScopeRBACRoleBindings without error using callback', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListScopeRBACRoleBindingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListScopeRBACRoleBindingsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.gkehub.v1.RBACRoleBinding(), + ), + generateSampleMessage( + new protos.google.cloud.gkehub.v1.RBACRoleBinding(), + ), + generateSampleMessage( + new protos.google.cloud.gkehub.v1.RBACRoleBinding(), + ), + ]; + client.innerApiCalls.listScopeRbacRoleBindings = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listScopeRBACRoleBindings( + request, + ( + err?: Error | null, + result?: protos.google.cloud.gkehub.v1.IRBACRoleBinding[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listScopeNamespaces.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listScopeNamespaces.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listScopeNamespaces with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListScopeNamespacesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListScopeNamespacesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listScopeNamespaces.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listScopeNamespacesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.gkehub.v1.INamespace[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listScopeNamespaces.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listScopeNamespaces.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.listScopeRbacRoleBindings as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listScopeRbacRoleBindings as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listScopeRBACRoleBindings', () => { - it('invokes listScopeRBACRoleBindings without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListScopeRBACRoleBindingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListScopeRBACRoleBindingsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkehub.v1.RBACRoleBinding()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.RBACRoleBinding()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.RBACRoleBinding()), - ]; - client.innerApiCalls.listScopeRbacRoleBindings = stubSimpleCall(expectedResponse); - const [response] = await client.listScopeRBACRoleBindings(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listScopeRbacRoleBindings as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listScopeRbacRoleBindings as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listScopeRBACRoleBindings with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListScopeRBACRoleBindingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListScopeRBACRoleBindingsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listScopeRbacRoleBindings = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.listScopeRBACRoleBindings(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.listScopeRbacRoleBindings as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listScopeRbacRoleBindings as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listScopeRBACRoleBindings without error using callback', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListScopeRBACRoleBindingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListScopeRBACRoleBindingsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkehub.v1.RBACRoleBinding()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.RBACRoleBinding()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.RBACRoleBinding()), - ]; - client.innerApiCalls.listScopeRbacRoleBindings = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listScopeRBACRoleBindings( - request, - (err?: Error|null, result?: protos.google.cloud.gkehub.v1.IRBACRoleBinding[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listScopeRbacRoleBindings as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listScopeRbacRoleBindings as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listScopeRBACRoleBindingsStream without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListScopeRBACRoleBindingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListScopeRBACRoleBindingsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.gkehub.v1.RBACRoleBinding(), + ), + generateSampleMessage( + new protos.google.cloud.gkehub.v1.RBACRoleBinding(), + ), + generateSampleMessage( + new protos.google.cloud.gkehub.v1.RBACRoleBinding(), + ), + ]; + client.descriptors.page.listScopeRBACRoleBindings.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listScopeRBACRoleBindingsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.gkehub.v1.RBACRoleBinding[] = []; + stream.on( + 'data', + (response: protos.google.cloud.gkehub.v1.RBACRoleBinding) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + ( + client.descriptors.page.listScopeRBACRoleBindings + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.listScopeRbacRoleBindings, request), + ); + assert( + ( + client.descriptors.page.listScopeRBACRoleBindings + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listScopeRBACRoleBindings with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListScopeRBACRoleBindingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListScopeRBACRoleBindingsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listScopeRbacRoleBindings = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listScopeRBACRoleBindings(request), expectedError); - const actualRequest = (client.innerApiCalls.listScopeRbacRoleBindings as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listScopeRbacRoleBindings as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listScopeRBACRoleBindingsStream with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListScopeRBACRoleBindingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListScopeRBACRoleBindingsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listScopeRBACRoleBindings.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listScopeRBACRoleBindingsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.gkehub.v1.RBACRoleBinding[] = []; + stream.on( + 'data', + (response: protos.google.cloud.gkehub.v1.RBACRoleBinding) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + ( + client.descriptors.page.listScopeRBACRoleBindings + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.listScopeRbacRoleBindings, request), + ); + assert( + ( + client.descriptors.page.listScopeRBACRoleBindings + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listScopeRBACRoleBindingsStream without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListScopeRBACRoleBindingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListScopeRBACRoleBindingsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkehub.v1.RBACRoleBinding()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.RBACRoleBinding()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.RBACRoleBinding()), - ]; - client.descriptors.page.listScopeRBACRoleBindings.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listScopeRBACRoleBindingsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.gkehub.v1.RBACRoleBinding[] = []; - stream.on('data', (response: protos.google.cloud.gkehub.v1.RBACRoleBinding) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listScopeRBACRoleBindings.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listScopeRbacRoleBindings, request)); - assert( - (client.descriptors.page.listScopeRBACRoleBindings.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listScopeRBACRoleBindings without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListScopeRBACRoleBindingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListScopeRBACRoleBindingsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.gkehub.v1.RBACRoleBinding(), + ), + generateSampleMessage( + new protos.google.cloud.gkehub.v1.RBACRoleBinding(), + ), + generateSampleMessage( + new protos.google.cloud.gkehub.v1.RBACRoleBinding(), + ), + ]; + client.descriptors.page.listScopeRBACRoleBindings.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.gkehub.v1.IRBACRoleBinding[] = []; + const iterable = client.listScopeRBACRoleBindingsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listScopeRBACRoleBindings + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listScopeRBACRoleBindings + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listScopeRBACRoleBindingsStream with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListScopeRBACRoleBindingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListScopeRBACRoleBindingsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listScopeRBACRoleBindings.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listScopeRBACRoleBindingsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.gkehub.v1.RBACRoleBinding[] = []; - stream.on('data', (response: protos.google.cloud.gkehub.v1.RBACRoleBinding) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listScopeRBACRoleBindings.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listScopeRbacRoleBindings, request)); - assert( - (client.descriptors.page.listScopeRBACRoleBindings.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listScopeRBACRoleBindings with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListScopeRBACRoleBindingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListScopeRBACRoleBindingsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listScopeRBACRoleBindings.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listScopeRBACRoleBindingsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.gkehub.v1.IRBACRoleBinding[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listScopeRBACRoleBindings + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listScopeRBACRoleBindings + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + + describe('listScopes', () => { + it('invokes listScopes without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListScopesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListScopesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.gkehub.v1.Scope()), + generateSampleMessage(new protos.google.cloud.gkehub.v1.Scope()), + generateSampleMessage(new protos.google.cloud.gkehub.v1.Scope()), + ]; + client.innerApiCalls.listScopes = stubSimpleCall(expectedResponse); + const [response] = await client.listScopes(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listScopes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listScopes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listScopeRBACRoleBindings without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListScopeRBACRoleBindingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListScopeRBACRoleBindingsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkehub.v1.RBACRoleBinding()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.RBACRoleBinding()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.RBACRoleBinding()), - ]; - client.descriptors.page.listScopeRBACRoleBindings.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.gkehub.v1.IRBACRoleBinding[] = []; - const iterable = client.listScopeRBACRoleBindingsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listScopes without error using callback', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListScopesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListScopesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.gkehub.v1.Scope()), + generateSampleMessage(new protos.google.cloud.gkehub.v1.Scope()), + generateSampleMessage(new protos.google.cloud.gkehub.v1.Scope()), + ]; + client.innerApiCalls.listScopes = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listScopes( + request, + ( + err?: Error | null, + result?: protos.google.cloud.gkehub.v1.IScope[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listScopeRBACRoleBindings.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listScopeRBACRoleBindings.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listScopeRBACRoleBindings with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListScopeRBACRoleBindingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListScopeRBACRoleBindingsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listScopeRBACRoleBindings.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listScopeRBACRoleBindingsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.gkehub.v1.IRBACRoleBinding[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listScopeRBACRoleBindings.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listScopeRBACRoleBindings.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.listScopes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listScopes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listScopes', () => { - it('invokes listScopes without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListScopesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListScopesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkehub.v1.Scope()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.Scope()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.Scope()), - ]; - client.innerApiCalls.listScopes = stubSimpleCall(expectedResponse); - const [response] = await client.listScopes(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listScopes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listScopes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listScopes with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListScopesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListScopesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listScopes = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listScopes(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listScopes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listScopes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listScopes without error using callback', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListScopesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListScopesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkehub.v1.Scope()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.Scope()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.Scope()), - ]; - client.innerApiCalls.listScopes = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listScopes( - request, - (err?: Error|null, result?: protos.google.cloud.gkehub.v1.IScope[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listScopes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listScopes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listScopesStream without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListScopesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListScopesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.gkehub.v1.Scope()), + generateSampleMessage(new protos.google.cloud.gkehub.v1.Scope()), + generateSampleMessage(new protos.google.cloud.gkehub.v1.Scope()), + ]; + client.descriptors.page.listScopes.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listScopesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.gkehub.v1.Scope[] = []; + stream.on('data', (response: protos.google.cloud.gkehub.v1.Scope) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listScopes.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listScopes, request), + ); + assert( + (client.descriptors.page.listScopes.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listScopes with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListScopesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListScopesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listScopes = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listScopes(request), expectedError); - const actualRequest = (client.innerApiCalls.listScopes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listScopes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listScopesStream with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListScopesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListScopesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listScopes.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listScopesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.gkehub.v1.Scope[] = []; + stream.on('data', (response: protos.google.cloud.gkehub.v1.Scope) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listScopes.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listScopes, request), + ); + assert( + (client.descriptors.page.listScopes.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listScopesStream without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListScopesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListScopesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkehub.v1.Scope()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.Scope()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.Scope()), - ]; - client.descriptors.page.listScopes.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listScopesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.gkehub.v1.Scope[] = []; - stream.on('data', (response: protos.google.cloud.gkehub.v1.Scope) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listScopes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listScopes, request)); - assert( - (client.descriptors.page.listScopes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listScopes without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListScopesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListScopesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.gkehub.v1.Scope()), + generateSampleMessage(new protos.google.cloud.gkehub.v1.Scope()), + generateSampleMessage(new protos.google.cloud.gkehub.v1.Scope()), + ]; + client.descriptors.page.listScopes.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.gkehub.v1.IScope[] = []; + const iterable = client.listScopesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listScopes.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.listScopes.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listScopesStream with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListScopesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListScopesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listScopes.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listScopesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.gkehub.v1.Scope[] = []; - stream.on('data', (response: protos.google.cloud.gkehub.v1.Scope) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listScopes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listScopes, request)); - assert( - (client.descriptors.page.listScopes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listScopes with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListScopesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListScopesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listScopes.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError, + ); + const iterable = client.listScopesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.gkehub.v1.IScope[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listScopes.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.listScopes.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listPermittedScopes', () => { + it('invokes listPermittedScopes without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListPermittedScopesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListPermittedScopesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.gkehub.v1.Scope()), + generateSampleMessage(new protos.google.cloud.gkehub.v1.Scope()), + generateSampleMessage(new protos.google.cloud.gkehub.v1.Scope()), + ]; + client.innerApiCalls.listPermittedScopes = + stubSimpleCall(expectedResponse); + const [response] = await client.listPermittedScopes(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listPermittedScopes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listPermittedScopes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listScopes without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListScopesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListScopesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkehub.v1.Scope()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.Scope()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.Scope()), - ]; - client.descriptors.page.listScopes.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.gkehub.v1.IScope[] = []; - const iterable = client.listScopesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listPermittedScopes without error using callback', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListPermittedScopesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListPermittedScopesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.gkehub.v1.Scope()), + generateSampleMessage(new protos.google.cloud.gkehub.v1.Scope()), + generateSampleMessage(new protos.google.cloud.gkehub.v1.Scope()), + ]; + client.innerApiCalls.listPermittedScopes = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listPermittedScopes( + request, + ( + err?: Error | null, + result?: protos.google.cloud.gkehub.v1.IScope[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listScopes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listScopes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listScopes with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListScopesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListScopesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listScopes.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listScopesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.gkehub.v1.IScope[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listScopes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listScopes.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.listPermittedScopes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listPermittedScopes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listPermittedScopes', () => { - it('invokes listPermittedScopes without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListPermittedScopesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListPermittedScopesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkehub.v1.Scope()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.Scope()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.Scope()), - ]; - client.innerApiCalls.listPermittedScopes = stubSimpleCall(expectedResponse); - const [response] = await client.listPermittedScopes(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listPermittedScopes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listPermittedScopes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listPermittedScopes with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListPermittedScopesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListPermittedScopesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listPermittedScopes = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listPermittedScopes(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listPermittedScopes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listPermittedScopes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listPermittedScopes without error using callback', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListPermittedScopesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListPermittedScopesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkehub.v1.Scope()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.Scope()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.Scope()), - ]; - client.innerApiCalls.listPermittedScopes = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listPermittedScopes( - request, - (err?: Error|null, result?: protos.google.cloud.gkehub.v1.IScope[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listPermittedScopes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listPermittedScopes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listPermittedScopesStream without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListPermittedScopesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListPermittedScopesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.gkehub.v1.Scope()), + generateSampleMessage(new protos.google.cloud.gkehub.v1.Scope()), + generateSampleMessage(new protos.google.cloud.gkehub.v1.Scope()), + ]; + client.descriptors.page.listPermittedScopes.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listPermittedScopesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.gkehub.v1.Scope[] = []; + stream.on('data', (response: protos.google.cloud.gkehub.v1.Scope) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listPermittedScopes.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listPermittedScopes, request), + ); + assert( + (client.descriptors.page.listPermittedScopes.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listPermittedScopes with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListPermittedScopesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListPermittedScopesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listPermittedScopes = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listPermittedScopes(request), expectedError); - const actualRequest = (client.innerApiCalls.listPermittedScopes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listPermittedScopes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listPermittedScopesStream with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListPermittedScopesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListPermittedScopesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listPermittedScopes.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listPermittedScopesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.gkehub.v1.Scope[] = []; + stream.on('data', (response: protos.google.cloud.gkehub.v1.Scope) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listPermittedScopes.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listPermittedScopes, request), + ); + assert( + (client.descriptors.page.listPermittedScopes.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listPermittedScopesStream without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListPermittedScopesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListPermittedScopesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkehub.v1.Scope()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.Scope()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.Scope()), - ]; - client.descriptors.page.listPermittedScopes.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listPermittedScopesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.gkehub.v1.Scope[] = []; - stream.on('data', (response: protos.google.cloud.gkehub.v1.Scope) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listPermittedScopes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listPermittedScopes, request)); - assert( - (client.descriptors.page.listPermittedScopes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listPermittedScopes without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListPermittedScopesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListPermittedScopesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.gkehub.v1.Scope()), + generateSampleMessage(new protos.google.cloud.gkehub.v1.Scope()), + generateSampleMessage(new protos.google.cloud.gkehub.v1.Scope()), + ]; + client.descriptors.page.listPermittedScopes.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.gkehub.v1.IScope[] = []; + const iterable = client.listPermittedScopesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listPermittedScopes.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listPermittedScopes.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listPermittedScopesStream with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListPermittedScopesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListPermittedScopesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listPermittedScopes.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listPermittedScopesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.gkehub.v1.Scope[] = []; - stream.on('data', (response: protos.google.cloud.gkehub.v1.Scope) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listPermittedScopes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listPermittedScopes, request)); - assert( - (client.descriptors.page.listPermittedScopes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listPermittedScopes with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListPermittedScopesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListPermittedScopesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listPermittedScopes.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listPermittedScopesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.gkehub.v1.IScope[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listPermittedScopes.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listPermittedScopes.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listMembershipBindings', () => { + it('invokes listMembershipBindings without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListMembershipBindingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListMembershipBindingsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.gkehub.v1.MembershipBinding(), + ), + generateSampleMessage( + new protos.google.cloud.gkehub.v1.MembershipBinding(), + ), + generateSampleMessage( + new protos.google.cloud.gkehub.v1.MembershipBinding(), + ), + ]; + client.innerApiCalls.listMembershipBindings = + stubSimpleCall(expectedResponse); + const [response] = await client.listMembershipBindings(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listMembershipBindings as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMembershipBindings as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listPermittedScopes without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListPermittedScopesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListPermittedScopesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkehub.v1.Scope()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.Scope()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.Scope()), - ]; - client.descriptors.page.listPermittedScopes.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.gkehub.v1.IScope[] = []; - const iterable = client.listPermittedScopesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listMembershipBindings without error using callback', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListMembershipBindingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListMembershipBindingsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.gkehub.v1.MembershipBinding(), + ), + generateSampleMessage( + new protos.google.cloud.gkehub.v1.MembershipBinding(), + ), + generateSampleMessage( + new protos.google.cloud.gkehub.v1.MembershipBinding(), + ), + ]; + client.innerApiCalls.listMembershipBindings = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listMembershipBindings( + request, + ( + err?: Error | null, + result?: protos.google.cloud.gkehub.v1.IMembershipBinding[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listPermittedScopes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listPermittedScopes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listPermittedScopes with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListPermittedScopesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListPermittedScopesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listPermittedScopes.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listPermittedScopesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.gkehub.v1.IScope[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listPermittedScopes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listPermittedScopes.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.listMembershipBindings as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMembershipBindings as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listMembershipBindings', () => { - it('invokes listMembershipBindings without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListMembershipBindingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListMembershipBindingsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkehub.v1.MembershipBinding()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.MembershipBinding()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.MembershipBinding()), - ]; - client.innerApiCalls.listMembershipBindings = stubSimpleCall(expectedResponse); - const [response] = await client.listMembershipBindings(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listMembershipBindings as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listMembershipBindings as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listMembershipBindings with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListMembershipBindingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListMembershipBindingsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listMembershipBindings = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.listMembershipBindings(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.listMembershipBindings as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMembershipBindings as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listMembershipBindings without error using callback', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListMembershipBindingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListMembershipBindingsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkehub.v1.MembershipBinding()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.MembershipBinding()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.MembershipBinding()), - ]; - client.innerApiCalls.listMembershipBindings = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listMembershipBindings( - request, - (err?: Error|null, result?: protos.google.cloud.gkehub.v1.IMembershipBinding[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listMembershipBindings as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listMembershipBindings as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listMembershipBindingsStream without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListMembershipBindingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListMembershipBindingsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.gkehub.v1.MembershipBinding(), + ), + generateSampleMessage( + new protos.google.cloud.gkehub.v1.MembershipBinding(), + ), + generateSampleMessage( + new protos.google.cloud.gkehub.v1.MembershipBinding(), + ), + ]; + client.descriptors.page.listMembershipBindings.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listMembershipBindingsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.gkehub.v1.MembershipBinding[] = []; + stream.on( + 'data', + (response: protos.google.cloud.gkehub.v1.MembershipBinding) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + ( + client.descriptors.page.listMembershipBindings + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.listMembershipBindings, request), + ); + assert( + ( + client.descriptors.page.listMembershipBindings + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listMembershipBindings with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListMembershipBindingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListMembershipBindingsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listMembershipBindings = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listMembershipBindings(request), expectedError); - const actualRequest = (client.innerApiCalls.listMembershipBindings as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listMembershipBindings as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listMembershipBindingsStream with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListMembershipBindingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListMembershipBindingsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listMembershipBindings.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listMembershipBindingsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.gkehub.v1.MembershipBinding[] = []; + stream.on( + 'data', + (response: protos.google.cloud.gkehub.v1.MembershipBinding) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + ( + client.descriptors.page.listMembershipBindings + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.listMembershipBindings, request), + ); + assert( + ( + client.descriptors.page.listMembershipBindings + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listMembershipBindingsStream without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListMembershipBindingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListMembershipBindingsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkehub.v1.MembershipBinding()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.MembershipBinding()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.MembershipBinding()), - ]; - client.descriptors.page.listMembershipBindings.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listMembershipBindingsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.gkehub.v1.MembershipBinding[] = []; - stream.on('data', (response: protos.google.cloud.gkehub.v1.MembershipBinding) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listMembershipBindings.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listMembershipBindings, request)); - assert( - (client.descriptors.page.listMembershipBindings.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listMembershipBindings without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListMembershipBindingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListMembershipBindingsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.gkehub.v1.MembershipBinding(), + ), + generateSampleMessage( + new protos.google.cloud.gkehub.v1.MembershipBinding(), + ), + generateSampleMessage( + new protos.google.cloud.gkehub.v1.MembershipBinding(), + ), + ]; + client.descriptors.page.listMembershipBindings.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.gkehub.v1.IMembershipBinding[] = []; + const iterable = client.listMembershipBindingsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listMembershipBindings + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listMembershipBindings + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listMembershipBindingsStream with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListMembershipBindingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListMembershipBindingsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listMembershipBindings.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listMembershipBindingsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.gkehub.v1.MembershipBinding[] = []; - stream.on('data', (response: protos.google.cloud.gkehub.v1.MembershipBinding) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listMembershipBindings.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listMembershipBindings, request)); - assert( - (client.descriptors.page.listMembershipBindings.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listMembershipBindings with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListMembershipBindingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListMembershipBindingsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listMembershipBindings.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listMembershipBindingsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.gkehub.v1.IMembershipBinding[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listMembershipBindings + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listMembershipBindings + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + + describe('listMembershipRBACRoleBindings', () => { + it('invokes listMembershipRBACRoleBindings without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListMembershipRBACRoleBindingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListMembershipRBACRoleBindingsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.gkehub.v1.RBACRoleBinding(), + ), + generateSampleMessage( + new protos.google.cloud.gkehub.v1.RBACRoleBinding(), + ), + generateSampleMessage( + new protos.google.cloud.gkehub.v1.RBACRoleBinding(), + ), + ]; + client.innerApiCalls.listMembershipRbacRoleBindings = + stubSimpleCall(expectedResponse); + const [response] = await client.listMembershipRBACRoleBindings(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listMembershipRbacRoleBindings as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMembershipRbacRoleBindings as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listMembershipBindings without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListMembershipBindingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListMembershipBindingsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkehub.v1.MembershipBinding()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.MembershipBinding()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.MembershipBinding()), - ]; - client.descriptors.page.listMembershipBindings.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.gkehub.v1.IMembershipBinding[] = []; - const iterable = client.listMembershipBindingsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listMembershipRBACRoleBindings without error using callback', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListMembershipRBACRoleBindingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListMembershipRBACRoleBindingsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.gkehub.v1.RBACRoleBinding(), + ), + generateSampleMessage( + new protos.google.cloud.gkehub.v1.RBACRoleBinding(), + ), + generateSampleMessage( + new protos.google.cloud.gkehub.v1.RBACRoleBinding(), + ), + ]; + client.innerApiCalls.listMembershipRbacRoleBindings = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listMembershipRBACRoleBindings( + request, + ( + err?: Error | null, + result?: protos.google.cloud.gkehub.v1.IRBACRoleBinding[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listMembershipBindings.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listMembershipBindings.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listMembershipBindings with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListMembershipBindingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListMembershipBindingsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listMembershipBindings.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listMembershipBindingsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.gkehub.v1.IMembershipBinding[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listMembershipBindings.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listMembershipBindings.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.listMembershipRbacRoleBindings as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMembershipRbacRoleBindings as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listMembershipRBACRoleBindings', () => { - it('invokes listMembershipRBACRoleBindings without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListMembershipRBACRoleBindingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListMembershipRBACRoleBindingsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkehub.v1.RBACRoleBinding()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.RBACRoleBinding()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.RBACRoleBinding()), - ]; - client.innerApiCalls.listMembershipRbacRoleBindings = stubSimpleCall(expectedResponse); - const [response] = await client.listMembershipRBACRoleBindings(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listMembershipRbacRoleBindings as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listMembershipRbacRoleBindings as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listMembershipRBACRoleBindings without error using callback', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListMembershipRBACRoleBindingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListMembershipRBACRoleBindingsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkehub.v1.RBACRoleBinding()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.RBACRoleBinding()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.RBACRoleBinding()), - ]; - client.innerApiCalls.listMembershipRbacRoleBindings = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listMembershipRBACRoleBindings( - request, - (err?: Error|null, result?: protos.google.cloud.gkehub.v1.IRBACRoleBinding[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listMembershipRbacRoleBindings as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listMembershipRbacRoleBindings as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listMembershipRBACRoleBindings with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListMembershipRBACRoleBindingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListMembershipRBACRoleBindingsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listMembershipRbacRoleBindings = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listMembershipRBACRoleBindings(request), expectedError); - const actualRequest = (client.innerApiCalls.listMembershipRbacRoleBindings as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listMembershipRbacRoleBindings as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listMembershipRBACRoleBindingsStream without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListMembershipRBACRoleBindingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListMembershipRBACRoleBindingsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkehub.v1.RBACRoleBinding()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.RBACRoleBinding()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.RBACRoleBinding()), - ]; - client.descriptors.page.listMembershipRBACRoleBindings.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listMembershipRBACRoleBindingsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.gkehub.v1.RBACRoleBinding[] = []; - stream.on('data', (response: protos.google.cloud.gkehub.v1.RBACRoleBinding) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listMembershipRBACRoleBindings.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listMembershipRbacRoleBindings, request)); - assert( - (client.descriptors.page.listMembershipRBACRoleBindings.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listMembershipRBACRoleBindings with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListMembershipRBACRoleBindingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListMembershipRBACRoleBindingsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listMembershipRbacRoleBindings = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.listMembershipRBACRoleBindings(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.listMembershipRbacRoleBindings as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMembershipRbacRoleBindings as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listMembershipRBACRoleBindingsStream with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListMembershipRBACRoleBindingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListMembershipRBACRoleBindingsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listMembershipRBACRoleBindings.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listMembershipRBACRoleBindingsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.gkehub.v1.RBACRoleBinding[] = []; - stream.on('data', (response: protos.google.cloud.gkehub.v1.RBACRoleBinding) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listMembershipRBACRoleBindings.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listMembershipRbacRoleBindings, request)); - assert( - (client.descriptors.page.listMembershipRBACRoleBindings.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listMembershipRBACRoleBindingsStream without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListMembershipRBACRoleBindingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListMembershipRBACRoleBindingsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.gkehub.v1.RBACRoleBinding(), + ), + generateSampleMessage( + new protos.google.cloud.gkehub.v1.RBACRoleBinding(), + ), + generateSampleMessage( + new protos.google.cloud.gkehub.v1.RBACRoleBinding(), + ), + ]; + client.descriptors.page.listMembershipRBACRoleBindings.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listMembershipRBACRoleBindingsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.gkehub.v1.RBACRoleBinding[] = []; + stream.on( + 'data', + (response: protos.google.cloud.gkehub.v1.RBACRoleBinding) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + ( + client.descriptors.page.listMembershipRBACRoleBindings + .createStream as SinonStub + ) + .getCall(0) + .calledWith( + client.innerApiCalls.listMembershipRbacRoleBindings, + request, + ), + ); + assert( + ( + client.descriptors.page.listMembershipRBACRoleBindings + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('uses async iteration with listMembershipRBACRoleBindings without error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListMembershipRBACRoleBindingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListMembershipRBACRoleBindingsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkehub.v1.RBACRoleBinding()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.RBACRoleBinding()), - generateSampleMessage(new protos.google.cloud.gkehub.v1.RBACRoleBinding()), - ]; - client.descriptors.page.listMembershipRBACRoleBindings.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.gkehub.v1.IRBACRoleBinding[] = []; - const iterable = client.listMembershipRBACRoleBindingsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listMembershipRBACRoleBindings.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listMembershipRBACRoleBindings.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listMembershipRBACRoleBindingsStream with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListMembershipRBACRoleBindingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListMembershipRBACRoleBindingsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listMembershipRBACRoleBindings.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listMembershipRBACRoleBindingsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.gkehub.v1.RBACRoleBinding[] = []; + stream.on( + 'data', + (response: protos.google.cloud.gkehub.v1.RBACRoleBinding) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + ( + client.descriptors.page.listMembershipRBACRoleBindings + .createStream as SinonStub + ) + .getCall(0) + .calledWith( + client.innerApiCalls.listMembershipRbacRoleBindings, + request, + ), + ); + assert( + ( + client.descriptors.page.listMembershipRBACRoleBindings + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('uses async iteration with listMembershipRBACRoleBindings with error', async () => { - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1.ListMembershipRBACRoleBindingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1.ListMembershipRBACRoleBindingsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listMembershipRBACRoleBindings.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listMembershipRBACRoleBindingsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.gkehub.v1.IRBACRoleBinding[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listMembershipRBACRoleBindings.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listMembershipRBACRoleBindings.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listMembershipRBACRoleBindings without error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListMembershipRBACRoleBindingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListMembershipRBACRoleBindingsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.gkehub.v1.RBACRoleBinding(), + ), + generateSampleMessage( + new protos.google.cloud.gkehub.v1.RBACRoleBinding(), + ), + generateSampleMessage( + new protos.google.cloud.gkehub.v1.RBACRoleBinding(), + ), + ]; + client.descriptors.page.listMembershipRBACRoleBindings.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.gkehub.v1.IRBACRoleBinding[] = []; + const iterable = client.listMembershipRBACRoleBindingsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listMembershipRBACRoleBindings + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listMembershipRBACRoleBindings + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); }); - describe('Path templates', () => { - - describe('feature', async () => { - const fakePath = "/rendered/path/feature"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - feature: "featureValue", - }; - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.featurePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.featurePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('featurePath', () => { - const result = client.featurePath("projectValue", "locationValue", "featureValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.featurePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromFeatureName', () => { - const result = client.matchProjectFromFeatureName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.featurePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromFeatureName', () => { - const result = client.matchLocationFromFeatureName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.featurePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchFeatureFromFeatureName', () => { - const result = client.matchFeatureFromFeatureName(fakePath); - assert.strictEqual(result, "featureValue"); - assert((client.pathTemplates.featurePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('uses async iteration with listMembershipRBACRoleBindings with error', async () => { + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1.ListMembershipRBACRoleBindingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1.ListMembershipRBACRoleBindingsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listMembershipRBACRoleBindings.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listMembershipRBACRoleBindingsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.gkehub.v1.IRBACRoleBinding[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listMembershipRBACRoleBindings + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listMembershipRBACRoleBindings + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + + describe('Path templates', () => { + describe('feature', async () => { + const fakePath = '/rendered/path/feature'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + feature: 'featureValue', + }; + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.featurePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.featurePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('featurePath', () => { + const result = client.featurePath( + 'projectValue', + 'locationValue', + 'featureValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.featurePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromFeatureName', () => { + const result = client.matchProjectFromFeatureName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.featurePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromFeatureName', () => { + const result = client.matchLocationFromFeatureName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.featurePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchFeatureFromFeatureName', () => { + const result = client.matchFeatureFromFeatureName(fakePath); + assert.strictEqual(result, 'featureValue'); + assert( + (client.pathTemplates.featurePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('location', async () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new gkehubModule.v1.GkeHubClient({ - 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 gkehubModule.v1.GkeHubClient({ + 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('membership', async () => { - const fakePath = "/rendered/path/membership"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - membership: "membershipValue", - }; - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.membershipPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.membershipPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('membershipPath', () => { - const result = client.membershipPath("projectValue", "locationValue", "membershipValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.membershipPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromMembershipName', () => { - const result = client.matchProjectFromMembershipName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.membershipPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromMembershipName', () => { - const result = client.matchLocationFromMembershipName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.membershipPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchMembershipFromMembershipName', () => { - const result = client.matchMembershipFromMembershipName(fakePath); - assert.strictEqual(result, "membershipValue"); - assert((client.pathTemplates.membershipPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('membership', async () => { + const fakePath = '/rendered/path/membership'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + membership: 'membershipValue', + }; + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.membershipPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.membershipPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('membershipPath', () => { + const result = client.membershipPath( + 'projectValue', + 'locationValue', + 'membershipValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.membershipPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromMembershipName', () => { + const result = client.matchProjectFromMembershipName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.membershipPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromMembershipName', () => { + const result = client.matchLocationFromMembershipName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.membershipPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchMembershipFromMembershipName', () => { + const result = client.matchMembershipFromMembershipName(fakePath); + assert.strictEqual(result, 'membershipValue'); + assert( + (client.pathTemplates.membershipPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('membershipBinding', async () => { - const fakePath = "/rendered/path/membershipBinding"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - membership: "membershipValue", - membershipbinding: "membershipbindingValue", - }; - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.membershipBindingPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.membershipBindingPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('membershipBindingPath', () => { - const result = client.membershipBindingPath("projectValue", "locationValue", "membershipValue", "membershipbindingValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.membershipBindingPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromMembershipBindingName', () => { - const result = client.matchProjectFromMembershipBindingName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.membershipBindingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromMembershipBindingName', () => { - const result = client.matchLocationFromMembershipBindingName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.membershipBindingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchMembershipFromMembershipBindingName', () => { - const result = client.matchMembershipFromMembershipBindingName(fakePath); - assert.strictEqual(result, "membershipValue"); - assert((client.pathTemplates.membershipBindingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchMembershipbindingFromMembershipBindingName', () => { - const result = client.matchMembershipbindingFromMembershipBindingName(fakePath); - assert.strictEqual(result, "membershipbindingValue"); - assert((client.pathTemplates.membershipBindingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('membershipBinding', async () => { + const fakePath = '/rendered/path/membershipBinding'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + membership: 'membershipValue', + membershipbinding: 'membershipbindingValue', + }; + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.membershipBindingPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.membershipBindingPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('membershipBindingPath', () => { + const result = client.membershipBindingPath( + 'projectValue', + 'locationValue', + 'membershipValue', + 'membershipbindingValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.membershipBindingPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromMembershipBindingName', () => { + const result = client.matchProjectFromMembershipBindingName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.membershipBindingPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromMembershipBindingName', () => { + const result = client.matchLocationFromMembershipBindingName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.membershipBindingPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchMembershipFromMembershipBindingName', () => { + const result = + client.matchMembershipFromMembershipBindingName(fakePath); + assert.strictEqual(result, 'membershipValue'); + assert( + ( + client.pathTemplates.membershipBindingPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchMembershipbindingFromMembershipBindingName', () => { + const result = + client.matchMembershipbindingFromMembershipBindingName(fakePath); + assert.strictEqual(result, 'membershipbindingValue'); + assert( + ( + client.pathTemplates.membershipBindingPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('namespace', async () => { - const fakePath = "/rendered/path/namespace"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - scope: "scopeValue", - namespace: "namespaceValue", - }; - const client = new gkehubModule.v1.GkeHubClient({ - 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", "scopeValue", "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('matchScopeFromNamespaceName', () => { - const result = client.matchScopeFromNamespaceName(fakePath); - assert.strictEqual(result, "scopeValue"); - 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', + scope: 'scopeValue', + namespace: 'namespaceValue', + }; + const client = new gkehubModule.v1.GkeHubClient({ + 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', + 'scopeValue', + '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('matchScopeFromNamespaceName', () => { + const result = client.matchScopeFromNamespaceName(fakePath); + assert.strictEqual(result, 'scopeValue'); + 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('organizationLocationFleet', async () => { - const fakePath = "/rendered/path/organizationLocationFleet"; - const expectedParameters = { - organization: "organizationValue", - location: "locationValue", - fleet: "fleetValue", - }; - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationLocationFleetPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationLocationFleetPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationLocationFleetPath', () => { - const result = client.organizationLocationFleetPath("organizationValue", "locationValue", "fleetValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationLocationFleetPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationLocationFleetName', () => { - const result = client.matchOrganizationFromOrganizationLocationFleetName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationLocationFleetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromOrganizationLocationFleetName', () => { - const result = client.matchLocationFromOrganizationLocationFleetName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.organizationLocationFleetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchFleetFromOrganizationLocationFleetName', () => { - const result = client.matchFleetFromOrganizationLocationFleetName(fakePath); - assert.strictEqual(result, "fleetValue"); - assert((client.pathTemplates.organizationLocationFleetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('organizationLocationFleet', async () => { + const fakePath = '/rendered/path/organizationLocationFleet'; + const expectedParameters = { + organization: 'organizationValue', + location: 'locationValue', + fleet: 'fleetValue', + }; + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.organizationLocationFleetPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationLocationFleetPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationLocationFleetPath', () => { + const result = client.organizationLocationFleetPath( + 'organizationValue', + 'locationValue', + 'fleetValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.organizationLocationFleetPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationLocationFleetName', () => { + const result = + client.matchOrganizationFromOrganizationLocationFleetName(fakePath); + assert.strictEqual(result, 'organizationValue'); + assert( + ( + client.pathTemplates.organizationLocationFleetPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromOrganizationLocationFleetName', () => { + const result = + client.matchLocationFromOrganizationLocationFleetName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.organizationLocationFleetPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchFleetFromOrganizationLocationFleetName', () => { + const result = + client.matchFleetFromOrganizationLocationFleetName(fakePath); + assert.strictEqual(result, 'fleetValue'); + assert( + ( + client.pathTemplates.organizationLocationFleetPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('project', async () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new gkehubModule.v1.GkeHubClient({ - 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 gkehubModule.v1.GkeHubClient({ + 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('projectLocationFleet', async () => { - const fakePath = "/rendered/path/projectLocationFleet"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - fleet: "fleetValue", - }; - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectLocationFleetPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationFleetPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationFleetPath', () => { - const result = client.projectLocationFleetPath("projectValue", "locationValue", "fleetValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationFleetPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationFleetName', () => { - const result = client.matchProjectFromProjectLocationFleetName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationFleetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationFleetName', () => { - const result = client.matchLocationFromProjectLocationFleetName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationFleetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchFleetFromProjectLocationFleetName', () => { - const result = client.matchFleetFromProjectLocationFleetName(fakePath); - assert.strictEqual(result, "fleetValue"); - assert((client.pathTemplates.projectLocationFleetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectLocationFleet', async () => { + const fakePath = '/rendered/path/projectLocationFleet'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + fleet: 'fleetValue', + }; + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectLocationFleetPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectLocationFleetPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectLocationFleetPath', () => { + const result = client.projectLocationFleetPath( + 'projectValue', + 'locationValue', + 'fleetValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectLocationFleetPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectLocationFleetName', () => { + const result = + client.matchProjectFromProjectLocationFleetName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.projectLocationFleetPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromProjectLocationFleetName', () => { + const result = + client.matchLocationFromProjectLocationFleetName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.projectLocationFleetPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchFleetFromProjectLocationFleetName', () => { + const result = client.matchFleetFromProjectLocationFleetName(fakePath); + assert.strictEqual(result, 'fleetValue'); + assert( + ( + client.pathTemplates.projectLocationFleetPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('projectLocationMembershipRbacrolebinding', async () => { - const fakePath = "/rendered/path/projectLocationMembershipRbacrolebinding"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - membership: "membershipValue", - rbacrolebinding: "rbacrolebindingValue", - }; - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectLocationMembershipRbacrolebindingPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationMembershipRbacrolebindingPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationMembershipRbacrolebindingPath', () => { - const result = client.projectLocationMembershipRbacrolebindingPath("projectValue", "locationValue", "membershipValue", "rbacrolebindingValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationMembershipRbacrolebindingPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationMembershipRbacrolebindingName', () => { - const result = client.matchProjectFromProjectLocationMembershipRbacrolebindingName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationMembershipRbacrolebindingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationMembershipRbacrolebindingName', () => { - const result = client.matchLocationFromProjectLocationMembershipRbacrolebindingName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationMembershipRbacrolebindingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchMembershipFromProjectLocationMembershipRbacrolebindingName', () => { - const result = client.matchMembershipFromProjectLocationMembershipRbacrolebindingName(fakePath); - assert.strictEqual(result, "membershipValue"); - assert((client.pathTemplates.projectLocationMembershipRbacrolebindingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRbacrolebindingFromProjectLocationMembershipRbacrolebindingName', () => { - const result = client.matchRbacrolebindingFromProjectLocationMembershipRbacrolebindingName(fakePath); - assert.strictEqual(result, "rbacrolebindingValue"); - assert((client.pathTemplates.projectLocationMembershipRbacrolebindingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectLocationMembershipRbacrolebinding', async () => { + const fakePath = + '/rendered/path/projectLocationMembershipRbacrolebinding'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + membership: 'membershipValue', + rbacrolebinding: 'rbacrolebindingValue', + }; + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectLocationMembershipRbacrolebindingPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationMembershipRbacrolebindingPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationMembershipRbacrolebindingPath', () => { + const result = client.projectLocationMembershipRbacrolebindingPath( + 'projectValue', + 'locationValue', + 'membershipValue', + 'rbacrolebindingValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates + .projectLocationMembershipRbacrolebindingPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectLocationMembershipRbacrolebindingName', () => { + const result = + client.matchProjectFromProjectLocationMembershipRbacrolebindingName( + fakePath, + ); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates + .projectLocationMembershipRbacrolebindingPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromProjectLocationMembershipRbacrolebindingName', () => { + const result = + client.matchLocationFromProjectLocationMembershipRbacrolebindingName( + fakePath, + ); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates + .projectLocationMembershipRbacrolebindingPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchMembershipFromProjectLocationMembershipRbacrolebindingName', () => { + const result = + client.matchMembershipFromProjectLocationMembershipRbacrolebindingName( + fakePath, + ); + assert.strictEqual(result, 'membershipValue'); + assert( + ( + client.pathTemplates + .projectLocationMembershipRbacrolebindingPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRbacrolebindingFromProjectLocationMembershipRbacrolebindingName', () => { + const result = + client.matchRbacrolebindingFromProjectLocationMembershipRbacrolebindingName( + fakePath, + ); + assert.strictEqual(result, 'rbacrolebindingValue'); + assert( + ( + client.pathTemplates + .projectLocationMembershipRbacrolebindingPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('projectLocationScopeRbacrolebinding', async () => { - const fakePath = "/rendered/path/projectLocationScopeRbacrolebinding"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - scope: "scopeValue", - rbacrolebinding: "rbacrolebindingValue", - }; - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectLocationScopeRbacrolebindingPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationScopeRbacrolebindingPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationScopeRbacrolebindingPath', () => { - const result = client.projectLocationScopeRbacrolebindingPath("projectValue", "locationValue", "scopeValue", "rbacrolebindingValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationScopeRbacrolebindingPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationScopeRbacrolebindingName', () => { - const result = client.matchProjectFromProjectLocationScopeRbacrolebindingName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationScopeRbacrolebindingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationScopeRbacrolebindingName', () => { - const result = client.matchLocationFromProjectLocationScopeRbacrolebindingName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationScopeRbacrolebindingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchScopeFromProjectLocationScopeRbacrolebindingName', () => { - const result = client.matchScopeFromProjectLocationScopeRbacrolebindingName(fakePath); - assert.strictEqual(result, "scopeValue"); - assert((client.pathTemplates.projectLocationScopeRbacrolebindingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRbacrolebindingFromProjectLocationScopeRbacrolebindingName', () => { - const result = client.matchRbacrolebindingFromProjectLocationScopeRbacrolebindingName(fakePath); - assert.strictEqual(result, "rbacrolebindingValue"); - assert((client.pathTemplates.projectLocationScopeRbacrolebindingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectLocationScopeRbacrolebinding', async () => { + const fakePath = '/rendered/path/projectLocationScopeRbacrolebinding'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + scope: 'scopeValue', + rbacrolebinding: 'rbacrolebindingValue', + }; + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectLocationScopeRbacrolebindingPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationScopeRbacrolebindingPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationScopeRbacrolebindingPath', () => { + const result = client.projectLocationScopeRbacrolebindingPath( + 'projectValue', + 'locationValue', + 'scopeValue', + 'rbacrolebindingValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectLocationScopeRbacrolebindingPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectLocationScopeRbacrolebindingName', () => { + const result = + client.matchProjectFromProjectLocationScopeRbacrolebindingName( + fakePath, + ); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.projectLocationScopeRbacrolebindingPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromProjectLocationScopeRbacrolebindingName', () => { + const result = + client.matchLocationFromProjectLocationScopeRbacrolebindingName( + fakePath, + ); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.projectLocationScopeRbacrolebindingPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchScopeFromProjectLocationScopeRbacrolebindingName', () => { + const result = + client.matchScopeFromProjectLocationScopeRbacrolebindingName( + fakePath, + ); + assert.strictEqual(result, 'scopeValue'); + assert( + ( + client.pathTemplates.projectLocationScopeRbacrolebindingPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRbacrolebindingFromProjectLocationScopeRbacrolebindingName', () => { + const result = + client.matchRbacrolebindingFromProjectLocationScopeRbacrolebindingName( + fakePath, + ); + assert.strictEqual(result, 'rbacrolebindingValue'); + assert( + ( + client.pathTemplates.projectLocationScopeRbacrolebindingPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('scope', async () => { - const fakePath = "/rendered/path/scope"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - scope: "scopeValue", - }; - const client = new gkehubModule.v1.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.scopePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.scopePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('scopePath', () => { - const result = client.scopePath("projectValue", "locationValue", "scopeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.scopePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromScopeName', () => { - const result = client.matchProjectFromScopeName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.scopePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromScopeName', () => { - const result = client.matchLocationFromScopeName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.scopePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchScopeFromScopeName', () => { - const result = client.matchScopeFromScopeName(fakePath); - assert.strictEqual(result, "scopeValue"); - assert((client.pathTemplates.scopePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('scope', async () => { + const fakePath = '/rendered/path/scope'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + scope: 'scopeValue', + }; + const client = new gkehubModule.v1.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.scopePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.scopePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('scopePath', () => { + const result = client.scopePath( + 'projectValue', + 'locationValue', + 'scopeValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.scopePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromScopeName', () => { + const result = client.matchProjectFromScopeName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.scopePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromScopeName', () => { + const result = client.matchLocationFromScopeName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.scopePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchScopeFromScopeName', () => { + const result = client.matchScopeFromScopeName(fakePath); + assert.strictEqual(result, 'scopeValue'); + assert( + (client.pathTemplates.scopePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-gkehub/test/gapic_gke_hub_v1alpha.ts b/packages/google-cloud-gkehub/test/gapic_gke_hub_v1alpha.ts index f7d35c143873..9d73f51e8a67 100644 --- a/packages/google-cloud-gkehub/test/gapic_gke_hub_v1alpha.ts +++ b/packages/google-cloud-gkehub/test/gapic_gke_hub_v1alpha.ts @@ -19,1123 +19,1414 @@ 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 gkehubModule 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('v1alpha.GkeHubClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new gkehubModule.v1alpha.GkeHubClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'gkehub.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new gkehubModule.v1alpha.GkeHubClient(); - 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 = gkehubModule.v1alpha.GkeHubClient.servicePath; - assert.strictEqual(servicePath, 'gkehub.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = gkehubModule.v1alpha.GkeHubClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'gkehub.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new gkehubModule.v1alpha.GkeHubClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'gkehub.example.com'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new gkehubModule.v1alpha.GkeHubClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'gkehub.googleapis.com'); + }); - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new gkehubModule.v1alpha.GkeHubClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'gkehub.example.com'); - }); + it('has universeDomain', () => { + const client = new gkehubModule.v1alpha.GkeHubClient(); + 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 gkehubModule.v1alpha.GkeHubClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'gkehub.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 gkehubModule.v1alpha.GkeHubClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'gkehub.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 gkehubModule.v1alpha.GkeHubClient({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 = gkehubModule.v1alpha.GkeHubClient.servicePath; + assert.strictEqual(servicePath, 'gkehub.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = gkehubModule.v1alpha.GkeHubClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'gkehub.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new gkehubModule.v1alpha.GkeHubClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'gkehub.example.com'); + }); - it('has port', () => { - const port = gkehubModule.v1alpha.GkeHubClient.port; - assert(port); - assert(typeof port === 'number'); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new gkehubModule.v1alpha.GkeHubClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'gkehub.example.com'); + }); - it('should create a client with no option', () => { - const client = new gkehubModule.v1alpha.GkeHubClient(); - 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 gkehubModule.v1alpha.GkeHubClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'gkehub.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 gkehubModule.v1alpha.GkeHubClient({ - 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 gkehubModule.v1alpha.GkeHubClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'gkehub.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 gkehubModule.v1alpha.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.gkeHubStub, undefined); - await client.initialize(); - assert(client.gkeHubStub); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new gkehubModule.v1alpha.GkeHubClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('has close method for the initialized client', done => { - const client = new gkehubModule.v1alpha.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.gkeHubStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has port', () => { + const port = gkehubModule.v1alpha.GkeHubClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has close method for the non-initialized client', done => { - const client = new gkehubModule.v1alpha.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.gkeHubStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('should create a client with no option', () => { + const client = new gkehubModule.v1alpha.GkeHubClient(); + assert(client); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new gkehubModule.v1alpha.GkeHubClient({ - 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 gkehubModule.v1alpha.GkeHubClient({ + fallback: true, + }); + assert(client); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new gkehubModule.v1alpha.GkeHubClient({ - 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 gkehubModule.v1alpha.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.gkeHubStub, undefined); + await client.initialize(); + assert(client.gkeHubStub); }); - describe('getFeature', () => { - it('invokes getFeature without error', async () => { - const client = new gkehubModule.v1alpha.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1alpha.GetFeatureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1alpha.GetFeatureRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.gkehub.v1alpha.Feature() - ); - client.innerApiCalls.getFeature = stubSimpleCall(expectedResponse); - const [response] = await client.getFeature(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getFeature as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getFeature 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 gkehubModule.v1alpha.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.gkeHubStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes getFeature without error using callback', async () => { - const client = new gkehubModule.v1alpha.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1alpha.GetFeatureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1alpha.GetFeatureRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.gkehub.v1alpha.Feature() - ); - client.innerApiCalls.getFeature = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getFeature( - request, - (err?: Error|null, result?: protos.google.cloud.gkehub.v1alpha.IFeature|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getFeature as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getFeature 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 gkehubModule.v1alpha.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.gkeHubStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes getFeature with error', async () => { - const client = new gkehubModule.v1alpha.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1alpha.GetFeatureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1alpha.GetFeatureRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getFeature = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getFeature(request), expectedError); - const actualRequest = (client.innerApiCalls.getFeature as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getFeature 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 gkehubModule.v1alpha.GkeHubClient({ + 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 getFeature with closed client', async () => { - const client = new gkehubModule.v1alpha.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1alpha.GetFeatureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1alpha.GetFeatureRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getFeature(request), expectedError); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new gkehubModule.v1alpha.GkeHubClient({ + 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('getFeature', () => { + it('invokes getFeature without error', async () => { + const client = new gkehubModule.v1alpha.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1alpha.GetFeatureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1alpha.GetFeatureRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.gkehub.v1alpha.Feature(), + ); + client.innerApiCalls.getFeature = stubSimpleCall(expectedResponse); + const [response] = await client.getFeature(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createFeature', () => { - it('invokes createFeature without error', async () => { - const client = new gkehubModule.v1alpha.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1alpha.CreateFeatureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1alpha.CreateFeatureRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createFeature = stubLongRunningCall(expectedResponse); - const [operation] = await client.createFeature(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createFeature as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createFeature as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getFeature without error using callback', async () => { + const client = new gkehubModule.v1alpha.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1alpha.GetFeatureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1alpha.GetFeatureRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.gkehub.v1alpha.Feature(), + ); + client.innerApiCalls.getFeature = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getFeature( + request, + ( + err?: Error | null, + result?: protos.google.cloud.gkehub.v1alpha.IFeature | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createFeature without error using callback', async () => { - const client = new gkehubModule.v1alpha.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1alpha.CreateFeatureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1alpha.CreateFeatureRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createFeature = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createFeature( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createFeature as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createFeature as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getFeature with error', async () => { + const client = new gkehubModule.v1alpha.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1alpha.GetFeatureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1alpha.GetFeatureRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getFeature = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getFeature(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createFeature with call error', async () => { - const client = new gkehubModule.v1alpha.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1alpha.CreateFeatureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1alpha.CreateFeatureRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createFeature = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createFeature(request), expectedError); - const actualRequest = (client.innerApiCalls.createFeature as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createFeature as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getFeature with closed client', async () => { + const client = new gkehubModule.v1alpha.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1alpha.GetFeatureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1alpha.GetFeatureRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getFeature(request), expectedError); + }); + }); + + describe('createFeature', () => { + it('invokes createFeature without error', async () => { + const client = new gkehubModule.v1alpha.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1alpha.CreateFeatureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1alpha.CreateFeatureRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createFeature = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createFeature(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createFeature with LRO error', async () => { - const client = new gkehubModule.v1alpha.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1alpha.CreateFeatureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1alpha.CreateFeatureRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createFeature = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createFeature(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createFeature as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createFeature as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createFeature without error using callback', async () => { + const client = new gkehubModule.v1alpha.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1alpha.CreateFeatureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1alpha.CreateFeatureRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createFeature = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createFeature( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.gkehub.v1alpha.IFeature, + protos.google.cloud.gkehub.v1alpha.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.gkehub.v1alpha.IFeature, + protos.google.cloud.gkehub.v1alpha.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateFeatureProgress without error', async () => { - const client = new gkehubModule.v1alpha.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateFeatureProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createFeature with call error', async () => { + const client = new gkehubModule.v1alpha.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1alpha.CreateFeatureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1alpha.CreateFeatureRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createFeature = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createFeature(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateFeatureProgress with error', async () => { - const client = new gkehubModule.v1alpha.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateFeatureProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes createFeature with LRO error', async () => { + const client = new gkehubModule.v1alpha.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1alpha.CreateFeatureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1alpha.CreateFeatureRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createFeature = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createFeature(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteFeature', () => { - it('invokes deleteFeature without error', async () => { - const client = new gkehubModule.v1alpha.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1alpha.DeleteFeatureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1alpha.DeleteFeatureRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteFeature = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteFeature(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteFeature as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteFeature as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateFeatureProgress without error', async () => { + const client = new gkehubModule.v1alpha.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateFeatureProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes deleteFeature without error using callback', async () => { - const client = new gkehubModule.v1alpha.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1alpha.DeleteFeatureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1alpha.DeleteFeatureRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteFeature = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteFeature( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteFeature as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteFeature as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateFeatureProgress with error', async () => { + const client = new gkehubModule.v1alpha.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateFeatureProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteFeature', () => { + it('invokes deleteFeature without error', async () => { + const client = new gkehubModule.v1alpha.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1alpha.DeleteFeatureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1alpha.DeleteFeatureRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteFeature = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteFeature(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteFeature with call error', async () => { - const client = new gkehubModule.v1alpha.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1alpha.DeleteFeatureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1alpha.DeleteFeatureRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteFeature = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteFeature(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteFeature as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteFeature as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteFeature without error using callback', async () => { + const client = new gkehubModule.v1alpha.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1alpha.DeleteFeatureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1alpha.DeleteFeatureRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteFeature = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteFeature( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1alpha.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1alpha.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteFeature with LRO error', async () => { - const client = new gkehubModule.v1alpha.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1alpha.DeleteFeatureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1alpha.DeleteFeatureRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteFeature = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteFeature(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteFeature as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteFeature as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteFeature with call error', async () => { + const client = new gkehubModule.v1alpha.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1alpha.DeleteFeatureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1alpha.DeleteFeatureRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteFeature = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteFeature(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteFeatureProgress without error', async () => { - const client = new gkehubModule.v1alpha.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteFeatureProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes deleteFeature with LRO error', async () => { + const client = new gkehubModule.v1alpha.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1alpha.DeleteFeatureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1alpha.DeleteFeatureRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteFeature = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteFeature(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteFeatureProgress with error', async () => { - const client = new gkehubModule.v1alpha.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteFeatureProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkDeleteFeatureProgress without error', async () => { + const client = new gkehubModule.v1alpha.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteFeatureProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('updateFeature', () => { - it('invokes updateFeature without error', async () => { - const client = new gkehubModule.v1alpha.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1alpha.UpdateFeatureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1alpha.UpdateFeatureRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateFeature = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateFeature(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateFeature as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateFeature as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteFeatureProgress with error', async () => { + const client = new gkehubModule.v1alpha.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteFeatureProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateFeature', () => { + it('invokes updateFeature without error', async () => { + const client = new gkehubModule.v1alpha.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1alpha.UpdateFeatureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1alpha.UpdateFeatureRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateFeature = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateFeature(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateFeature without error using callback', async () => { - const client = new gkehubModule.v1alpha.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1alpha.UpdateFeatureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1alpha.UpdateFeatureRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateFeature = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateFeature( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateFeature as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateFeature as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateFeature without error using callback', async () => { + const client = new gkehubModule.v1alpha.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1alpha.UpdateFeatureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1alpha.UpdateFeatureRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateFeature = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateFeature( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.gkehub.v1alpha.IFeature, + protos.google.cloud.gkehub.v1alpha.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.gkehub.v1alpha.IFeature, + protos.google.cloud.gkehub.v1alpha.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateFeature with call error', async () => { - const client = new gkehubModule.v1alpha.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1alpha.UpdateFeatureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1alpha.UpdateFeatureRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateFeature = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateFeature(request), expectedError); - const actualRequest = (client.innerApiCalls.updateFeature as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateFeature as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateFeature with call error', async () => { + const client = new gkehubModule.v1alpha.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1alpha.UpdateFeatureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1alpha.UpdateFeatureRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateFeature = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateFeature(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateFeature with LRO error', async () => { - const client = new gkehubModule.v1alpha.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1alpha.UpdateFeatureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1alpha.UpdateFeatureRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateFeature = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateFeature(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateFeature as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateFeature as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateFeature with LRO error', async () => { + const client = new gkehubModule.v1alpha.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1alpha.UpdateFeatureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1alpha.UpdateFeatureRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateFeature = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateFeature(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateFeatureProgress without error', async () => { - const client = new gkehubModule.v1alpha.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateFeatureProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkUpdateFeatureProgress without error', async () => { + const client = new gkehubModule.v1alpha.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdateFeatureProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkUpdateFeatureProgress with error', async () => { - const client = new gkehubModule.v1alpha.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateFeatureProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkUpdateFeatureProgress with error', async () => { + const client = new gkehubModule.v1alpha.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateFeatureProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listFeatures', () => { + it('invokes listFeatures without error', async () => { + const client = new gkehubModule.v1alpha.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1alpha.ListFeaturesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1alpha.ListFeaturesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.gkehub.v1alpha.Feature()), + generateSampleMessage(new protos.google.cloud.gkehub.v1alpha.Feature()), + generateSampleMessage(new protos.google.cloud.gkehub.v1alpha.Feature()), + ]; + client.innerApiCalls.listFeatures = stubSimpleCall(expectedResponse); + const [response] = await client.listFeatures(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listFeatures as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listFeatures as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listFeatures', () => { - it('invokes listFeatures without error', async () => { - const client = new gkehubModule.v1alpha.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1alpha.ListFeaturesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1alpha.ListFeaturesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkehub.v1alpha.Feature()), - generateSampleMessage(new protos.google.cloud.gkehub.v1alpha.Feature()), - generateSampleMessage(new protos.google.cloud.gkehub.v1alpha.Feature()), - ]; - client.innerApiCalls.listFeatures = stubSimpleCall(expectedResponse); - const [response] = await client.listFeatures(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listFeatures as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listFeatures as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listFeatures without error using callback', async () => { + const client = new gkehubModule.v1alpha.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1alpha.ListFeaturesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1alpha.ListFeaturesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.gkehub.v1alpha.Feature()), + generateSampleMessage(new protos.google.cloud.gkehub.v1alpha.Feature()), + generateSampleMessage(new protos.google.cloud.gkehub.v1alpha.Feature()), + ]; + client.innerApiCalls.listFeatures = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listFeatures( + request, + ( + err?: Error | null, + result?: protos.google.cloud.gkehub.v1alpha.IFeature[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listFeatures as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listFeatures as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listFeatures without error using callback', async () => { - const client = new gkehubModule.v1alpha.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1alpha.ListFeaturesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1alpha.ListFeaturesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkehub.v1alpha.Feature()), - generateSampleMessage(new protos.google.cloud.gkehub.v1alpha.Feature()), - generateSampleMessage(new protos.google.cloud.gkehub.v1alpha.Feature()), - ]; - client.innerApiCalls.listFeatures = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listFeatures( - request, - (err?: Error|null, result?: protos.google.cloud.gkehub.v1alpha.IFeature[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listFeatures as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listFeatures as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listFeatures with error', async () => { + const client = new gkehubModule.v1alpha.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1alpha.ListFeaturesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1alpha.ListFeaturesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listFeatures = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listFeatures(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listFeatures as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listFeatures as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listFeatures with error', async () => { - const client = new gkehubModule.v1alpha.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1alpha.ListFeaturesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1alpha.ListFeaturesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listFeatures = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listFeatures(request), expectedError); - const actualRequest = (client.innerApiCalls.listFeatures as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listFeatures as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes listFeaturesStream without error', async () => { + const client = new gkehubModule.v1alpha.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1alpha.ListFeaturesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1alpha.ListFeaturesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.gkehub.v1alpha.Feature()), + generateSampleMessage(new protos.google.cloud.gkehub.v1alpha.Feature()), + generateSampleMessage(new protos.google.cloud.gkehub.v1alpha.Feature()), + ]; + client.descriptors.page.listFeatures.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listFeaturesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.gkehub.v1alpha.Feature[] = []; + stream.on( + 'data', + (response: protos.google.cloud.gkehub.v1alpha.Feature) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('invokes listFeaturesStream without error', async () => { - const client = new gkehubModule.v1alpha.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1alpha.ListFeaturesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1alpha.ListFeaturesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkehub.v1alpha.Feature()), - generateSampleMessage(new protos.google.cloud.gkehub.v1alpha.Feature()), - generateSampleMessage(new protos.google.cloud.gkehub.v1alpha.Feature()), - ]; - client.descriptors.page.listFeatures.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listFeaturesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.gkehub.v1alpha.Feature[] = []; - stream.on('data', (response: protos.google.cloud.gkehub.v1alpha.Feature) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listFeatures.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listFeatures, request)); - assert( - (client.descriptors.page.listFeatures.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.listFeatures.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listFeatures, request), + ); + assert( + (client.descriptors.page.listFeatures.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listFeaturesStream with error', async () => { - const client = new gkehubModule.v1alpha.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1alpha.ListFeaturesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1alpha.ListFeaturesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listFeatures.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listFeaturesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.gkehub.v1alpha.Feature[] = []; - stream.on('data', (response: protos.google.cloud.gkehub.v1alpha.Feature) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listFeatures.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listFeatures, request)); - assert( - (client.descriptors.page.listFeatures.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); + it('invokes listFeaturesStream with error', async () => { + const client = new gkehubModule.v1alpha.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1alpha.ListFeaturesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1alpha.ListFeaturesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listFeatures.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listFeaturesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.gkehub.v1alpha.Feature[] = []; + stream.on( + 'data', + (response: protos.google.cloud.gkehub.v1alpha.Feature) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('uses async iteration with listFeatures without error', async () => { - const client = new gkehubModule.v1alpha.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1alpha.ListFeaturesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1alpha.ListFeaturesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkehub.v1alpha.Feature()), - generateSampleMessage(new protos.google.cloud.gkehub.v1alpha.Feature()), - generateSampleMessage(new protos.google.cloud.gkehub.v1alpha.Feature()), - ]; - client.descriptors.page.listFeatures.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.gkehub.v1alpha.IFeature[] = []; - const iterable = client.listFeaturesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listFeatures.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listFeatures.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.listFeatures.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listFeatures, request), + ); + assert( + (client.descriptors.page.listFeatures.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listFeatures with error', async () => { - const client = new gkehubModule.v1alpha.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1alpha.ListFeaturesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1alpha.ListFeaturesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listFeatures.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listFeaturesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.gkehub.v1alpha.IFeature[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listFeatures.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listFeatures.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listFeatures without error', async () => { + const client = new gkehubModule.v1alpha.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1alpha.ListFeaturesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1alpha.ListFeaturesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.gkehub.v1alpha.Feature()), + generateSampleMessage(new protos.google.cloud.gkehub.v1alpha.Feature()), + generateSampleMessage(new protos.google.cloud.gkehub.v1alpha.Feature()), + ]; + client.descriptors.page.listFeatures.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.gkehub.v1alpha.IFeature[] = []; + const iterable = client.listFeaturesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listFeatures.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listFeatures.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); }); - describe('Path templates', () => { - - describe('feature', async () => { - const fakePath = "/rendered/path/feature"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - feature: "featureValue", - }; - const client = new gkehubModule.v1alpha.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.featurePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.featurePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('featurePath', () => { - const result = client.featurePath("projectValue", "locationValue", "featureValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.featurePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromFeatureName', () => { - const result = client.matchProjectFromFeatureName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.featurePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromFeatureName', () => { - const result = client.matchLocationFromFeatureName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.featurePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchFeatureFromFeatureName', () => { - const result = client.matchFeatureFromFeatureName(fakePath); - assert.strictEqual(result, "featureValue"); - assert((client.pathTemplates.featurePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('uses async iteration with listFeatures with error', async () => { + const client = new gkehubModule.v1alpha.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1alpha.ListFeaturesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1alpha.ListFeaturesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listFeatures.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listFeaturesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.gkehub.v1alpha.IFeature[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listFeatures.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listFeatures.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('Path templates', () => { + describe('feature', async () => { + const fakePath = '/rendered/path/feature'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + feature: 'featureValue', + }; + const client = new gkehubModule.v1alpha.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.featurePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.featurePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('featurePath', () => { + const result = client.featurePath( + 'projectValue', + 'locationValue', + 'featureValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.featurePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromFeatureName', () => { + const result = client.matchProjectFromFeatureName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.featurePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromFeatureName', () => { + const result = client.matchLocationFromFeatureName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.featurePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchFeatureFromFeatureName', () => { + const result = client.matchFeatureFromFeatureName(fakePath); + assert.strictEqual(result, 'featureValue'); + assert( + (client.pathTemplates.featurePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-gkehub/test/gapic_gke_hub_v1beta.ts b/packages/google-cloud-gkehub/test/gapic_gke_hub_v1beta.ts index 1d99dac00774..6b98a572fe58 100644 --- a/packages/google-cloud-gkehub/test/gapic_gke_hub_v1beta.ts +++ b/packages/google-cloud-gkehub/test/gapic_gke_hub_v1beta.ts @@ -19,1123 +19,1414 @@ 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 gkehubModule 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('v1beta.GkeHubClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new gkehubModule.v1beta.GkeHubClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'gkehub.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new gkehubModule.v1beta.GkeHubClient(); - 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 = gkehubModule.v1beta.GkeHubClient.servicePath; - assert.strictEqual(servicePath, 'gkehub.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = gkehubModule.v1beta.GkeHubClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'gkehub.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new gkehubModule.v1beta.GkeHubClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'gkehub.example.com'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new gkehubModule.v1beta.GkeHubClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'gkehub.googleapis.com'); + }); - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new gkehubModule.v1beta.GkeHubClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'gkehub.example.com'); - }); + it('has universeDomain', () => { + const client = new gkehubModule.v1beta.GkeHubClient(); + 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 gkehubModule.v1beta.GkeHubClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'gkehub.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 gkehubModule.v1beta.GkeHubClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'gkehub.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 gkehubModule.v1beta.GkeHubClient({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 = gkehubModule.v1beta.GkeHubClient.servicePath; + assert.strictEqual(servicePath, 'gkehub.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = gkehubModule.v1beta.GkeHubClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'gkehub.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new gkehubModule.v1beta.GkeHubClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'gkehub.example.com'); + }); - it('has port', () => { - const port = gkehubModule.v1beta.GkeHubClient.port; - assert(port); - assert(typeof port === 'number'); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new gkehubModule.v1beta.GkeHubClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'gkehub.example.com'); + }); - it('should create a client with no option', () => { - const client = new gkehubModule.v1beta.GkeHubClient(); - 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 gkehubModule.v1beta.GkeHubClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'gkehub.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 gkehubModule.v1beta.GkeHubClient({ - 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 gkehubModule.v1beta.GkeHubClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'gkehub.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 gkehubModule.v1beta.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.gkeHubStub, undefined); - await client.initialize(); - assert(client.gkeHubStub); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new gkehubModule.v1beta.GkeHubClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('has close method for the initialized client', done => { - const client = new gkehubModule.v1beta.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.gkeHubStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has port', () => { + const port = gkehubModule.v1beta.GkeHubClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has close method for the non-initialized client', done => { - const client = new gkehubModule.v1beta.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.gkeHubStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('should create a client with no option', () => { + const client = new gkehubModule.v1beta.GkeHubClient(); + assert(client); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new gkehubModule.v1beta.GkeHubClient({ - 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 gkehubModule.v1beta.GkeHubClient({ + fallback: true, + }); + assert(client); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new gkehubModule.v1beta.GkeHubClient({ - 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 gkehubModule.v1beta.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.gkeHubStub, undefined); + await client.initialize(); + assert(client.gkeHubStub); }); - describe('getFeature', () => { - it('invokes getFeature without error', async () => { - const client = new gkehubModule.v1beta.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta.GetFeatureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta.GetFeatureRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta.Feature() - ); - client.innerApiCalls.getFeature = stubSimpleCall(expectedResponse); - const [response] = await client.getFeature(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getFeature as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getFeature 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 gkehubModule.v1beta.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.gkeHubStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes getFeature without error using callback', async () => { - const client = new gkehubModule.v1beta.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta.GetFeatureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta.GetFeatureRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta.Feature() - ); - client.innerApiCalls.getFeature = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getFeature( - request, - (err?: Error|null, result?: protos.google.cloud.gkehub.v1beta.IFeature|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getFeature as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getFeature 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 gkehubModule.v1beta.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.gkeHubStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes getFeature with error', async () => { - const client = new gkehubModule.v1beta.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta.GetFeatureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta.GetFeatureRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getFeature = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getFeature(request), expectedError); - const actualRequest = (client.innerApiCalls.getFeature as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getFeature 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 gkehubModule.v1beta.GkeHubClient({ + 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 getFeature with closed client', async () => { - const client = new gkehubModule.v1beta.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta.GetFeatureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta.GetFeatureRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getFeature(request), expectedError); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new gkehubModule.v1beta.GkeHubClient({ + 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('getFeature', () => { + it('invokes getFeature without error', async () => { + const client = new gkehubModule.v1beta.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta.GetFeatureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta.GetFeatureRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta.Feature(), + ); + client.innerApiCalls.getFeature = stubSimpleCall(expectedResponse); + const [response] = await client.getFeature(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createFeature', () => { - it('invokes createFeature without error', async () => { - const client = new gkehubModule.v1beta.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta.CreateFeatureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta.CreateFeatureRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createFeature = stubLongRunningCall(expectedResponse); - const [operation] = await client.createFeature(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createFeature as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createFeature as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getFeature without error using callback', async () => { + const client = new gkehubModule.v1beta.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta.GetFeatureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta.GetFeatureRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta.Feature(), + ); + client.innerApiCalls.getFeature = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getFeature( + request, + ( + err?: Error | null, + result?: protos.google.cloud.gkehub.v1beta.IFeature | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createFeature without error using callback', async () => { - const client = new gkehubModule.v1beta.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta.CreateFeatureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta.CreateFeatureRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createFeature = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createFeature( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createFeature as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createFeature as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getFeature with error', async () => { + const client = new gkehubModule.v1beta.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta.GetFeatureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta.GetFeatureRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getFeature = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getFeature(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createFeature with call error', async () => { - const client = new gkehubModule.v1beta.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta.CreateFeatureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta.CreateFeatureRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createFeature = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createFeature(request), expectedError); - const actualRequest = (client.innerApiCalls.createFeature as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createFeature as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getFeature with closed client', async () => { + const client = new gkehubModule.v1beta.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta.GetFeatureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta.GetFeatureRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getFeature(request), expectedError); + }); + }); + + describe('createFeature', () => { + it('invokes createFeature without error', async () => { + const client = new gkehubModule.v1beta.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta.CreateFeatureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta.CreateFeatureRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createFeature = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createFeature(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createFeature with LRO error', async () => { - const client = new gkehubModule.v1beta.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta.CreateFeatureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta.CreateFeatureRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createFeature = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createFeature(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createFeature as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createFeature as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createFeature without error using callback', async () => { + const client = new gkehubModule.v1beta.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta.CreateFeatureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta.CreateFeatureRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createFeature = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createFeature( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.gkehub.v1beta.IFeature, + protos.google.cloud.gkehub.v1beta.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.gkehub.v1beta.IFeature, + protos.google.cloud.gkehub.v1beta.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateFeatureProgress without error', async () => { - const client = new gkehubModule.v1beta.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateFeatureProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createFeature with call error', async () => { + const client = new gkehubModule.v1beta.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta.CreateFeatureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta.CreateFeatureRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createFeature = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createFeature(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateFeatureProgress with error', async () => { - const client = new gkehubModule.v1beta.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateFeatureProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes createFeature with LRO error', async () => { + const client = new gkehubModule.v1beta.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta.CreateFeatureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta.CreateFeatureRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createFeature = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createFeature(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteFeature', () => { - it('invokes deleteFeature without error', async () => { - const client = new gkehubModule.v1beta.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta.DeleteFeatureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta.DeleteFeatureRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteFeature = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteFeature(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteFeature as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteFeature as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateFeatureProgress without error', async () => { + const client = new gkehubModule.v1beta.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateFeatureProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes deleteFeature without error using callback', async () => { - const client = new gkehubModule.v1beta.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta.DeleteFeatureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta.DeleteFeatureRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteFeature = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteFeature( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteFeature as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteFeature as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateFeatureProgress with error', async () => { + const client = new gkehubModule.v1beta.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateFeatureProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteFeature', () => { + it('invokes deleteFeature without error', async () => { + const client = new gkehubModule.v1beta.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta.DeleteFeatureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta.DeleteFeatureRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteFeature = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteFeature(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteFeature with call error', async () => { - const client = new gkehubModule.v1beta.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta.DeleteFeatureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta.DeleteFeatureRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteFeature = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteFeature(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteFeature as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteFeature as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteFeature without error using callback', async () => { + const client = new gkehubModule.v1beta.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta.DeleteFeatureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta.DeleteFeatureRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteFeature = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteFeature( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1beta.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkehub.v1beta.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteFeature with LRO error', async () => { - const client = new gkehubModule.v1beta.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta.DeleteFeatureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta.DeleteFeatureRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteFeature = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteFeature(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteFeature as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteFeature as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteFeature with call error', async () => { + const client = new gkehubModule.v1beta.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta.DeleteFeatureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta.DeleteFeatureRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteFeature = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteFeature(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteFeatureProgress without error', async () => { - const client = new gkehubModule.v1beta.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteFeatureProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes deleteFeature with LRO error', async () => { + const client = new gkehubModule.v1beta.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta.DeleteFeatureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta.DeleteFeatureRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteFeature = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteFeature(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteFeatureProgress with error', async () => { - const client = new gkehubModule.v1beta.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteFeatureProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkDeleteFeatureProgress without error', async () => { + const client = new gkehubModule.v1beta.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteFeatureProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('updateFeature', () => { - it('invokes updateFeature without error', async () => { - const client = new gkehubModule.v1beta.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta.UpdateFeatureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta.UpdateFeatureRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateFeature = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateFeature(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateFeature as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateFeature as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteFeatureProgress with error', async () => { + const client = new gkehubModule.v1beta.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteFeatureProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateFeature', () => { + it('invokes updateFeature without error', async () => { + const client = new gkehubModule.v1beta.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta.UpdateFeatureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta.UpdateFeatureRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateFeature = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateFeature(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateFeature without error using callback', async () => { - const client = new gkehubModule.v1beta.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta.UpdateFeatureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta.UpdateFeatureRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateFeature = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateFeature( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateFeature as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateFeature as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateFeature without error using callback', async () => { + const client = new gkehubModule.v1beta.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta.UpdateFeatureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta.UpdateFeatureRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateFeature = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateFeature( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.gkehub.v1beta.IFeature, + protos.google.cloud.gkehub.v1beta.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.gkehub.v1beta.IFeature, + protos.google.cloud.gkehub.v1beta.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateFeature with call error', async () => { - const client = new gkehubModule.v1beta.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta.UpdateFeatureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta.UpdateFeatureRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateFeature = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateFeature(request), expectedError); - const actualRequest = (client.innerApiCalls.updateFeature as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateFeature as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateFeature with call error', async () => { + const client = new gkehubModule.v1beta.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta.UpdateFeatureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta.UpdateFeatureRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateFeature = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateFeature(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateFeature with LRO error', async () => { - const client = new gkehubModule.v1beta.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta.UpdateFeatureRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta.UpdateFeatureRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateFeature = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateFeature(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateFeature as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateFeature as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateFeature with LRO error', async () => { + const client = new gkehubModule.v1beta.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta.UpdateFeatureRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta.UpdateFeatureRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateFeature = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateFeature(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateFeature as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateFeature as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateFeatureProgress without error', async () => { - const client = new gkehubModule.v1beta.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateFeatureProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkUpdateFeatureProgress without error', async () => { + const client = new gkehubModule.v1beta.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdateFeatureProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkUpdateFeatureProgress with error', async () => { - const client = new gkehubModule.v1beta.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateFeatureProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkUpdateFeatureProgress with error', async () => { + const client = new gkehubModule.v1beta.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateFeatureProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listFeatures', () => { + it('invokes listFeatures without error', async () => { + const client = new gkehubModule.v1beta.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta.ListFeaturesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta.ListFeaturesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.gkehub.v1beta.Feature()), + generateSampleMessage(new protos.google.cloud.gkehub.v1beta.Feature()), + generateSampleMessage(new protos.google.cloud.gkehub.v1beta.Feature()), + ]; + client.innerApiCalls.listFeatures = stubSimpleCall(expectedResponse); + const [response] = await client.listFeatures(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listFeatures as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listFeatures as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listFeatures', () => { - it('invokes listFeatures without error', async () => { - const client = new gkehubModule.v1beta.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta.ListFeaturesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta.ListFeaturesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkehub.v1beta.Feature()), - generateSampleMessage(new protos.google.cloud.gkehub.v1beta.Feature()), - generateSampleMessage(new protos.google.cloud.gkehub.v1beta.Feature()), - ]; - client.innerApiCalls.listFeatures = stubSimpleCall(expectedResponse); - const [response] = await client.listFeatures(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listFeatures as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listFeatures as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listFeatures without error using callback', async () => { + const client = new gkehubModule.v1beta.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta.ListFeaturesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta.ListFeaturesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.gkehub.v1beta.Feature()), + generateSampleMessage(new protos.google.cloud.gkehub.v1beta.Feature()), + generateSampleMessage(new protos.google.cloud.gkehub.v1beta.Feature()), + ]; + client.innerApiCalls.listFeatures = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listFeatures( + request, + ( + err?: Error | null, + result?: protos.google.cloud.gkehub.v1beta.IFeature[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listFeatures as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listFeatures as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listFeatures without error using callback', async () => { - const client = new gkehubModule.v1beta.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta.ListFeaturesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta.ListFeaturesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkehub.v1beta.Feature()), - generateSampleMessage(new protos.google.cloud.gkehub.v1beta.Feature()), - generateSampleMessage(new protos.google.cloud.gkehub.v1beta.Feature()), - ]; - client.innerApiCalls.listFeatures = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listFeatures( - request, - (err?: Error|null, result?: protos.google.cloud.gkehub.v1beta.IFeature[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listFeatures as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listFeatures as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listFeatures with error', async () => { + const client = new gkehubModule.v1beta.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta.ListFeaturesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta.ListFeaturesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listFeatures = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listFeatures(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listFeatures as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listFeatures as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listFeatures with error', async () => { - const client = new gkehubModule.v1beta.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta.ListFeaturesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta.ListFeaturesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listFeatures = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listFeatures(request), expectedError); - const actualRequest = (client.innerApiCalls.listFeatures as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listFeatures as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes listFeaturesStream without error', async () => { + const client = new gkehubModule.v1beta.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta.ListFeaturesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta.ListFeaturesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.gkehub.v1beta.Feature()), + generateSampleMessage(new protos.google.cloud.gkehub.v1beta.Feature()), + generateSampleMessage(new protos.google.cloud.gkehub.v1beta.Feature()), + ]; + client.descriptors.page.listFeatures.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listFeaturesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.gkehub.v1beta.Feature[] = []; + stream.on( + 'data', + (response: protos.google.cloud.gkehub.v1beta.Feature) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('invokes listFeaturesStream without error', async () => { - const client = new gkehubModule.v1beta.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta.ListFeaturesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta.ListFeaturesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkehub.v1beta.Feature()), - generateSampleMessage(new protos.google.cloud.gkehub.v1beta.Feature()), - generateSampleMessage(new protos.google.cloud.gkehub.v1beta.Feature()), - ]; - client.descriptors.page.listFeatures.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listFeaturesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.gkehub.v1beta.Feature[] = []; - stream.on('data', (response: protos.google.cloud.gkehub.v1beta.Feature) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listFeatures.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listFeatures, request)); - assert( - (client.descriptors.page.listFeatures.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.listFeatures.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listFeatures, request), + ); + assert( + (client.descriptors.page.listFeatures.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listFeaturesStream with error', async () => { - const client = new gkehubModule.v1beta.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta.ListFeaturesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta.ListFeaturesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listFeatures.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listFeaturesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.gkehub.v1beta.Feature[] = []; - stream.on('data', (response: protos.google.cloud.gkehub.v1beta.Feature) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listFeatures.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listFeatures, request)); - assert( - (client.descriptors.page.listFeatures.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); + it('invokes listFeaturesStream with error', async () => { + const client = new gkehubModule.v1beta.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta.ListFeaturesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta.ListFeaturesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listFeatures.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listFeaturesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.gkehub.v1beta.Feature[] = []; + stream.on( + 'data', + (response: protos.google.cloud.gkehub.v1beta.Feature) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('uses async iteration with listFeatures without error', async () => { - const client = new gkehubModule.v1beta.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta.ListFeaturesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta.ListFeaturesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkehub.v1beta.Feature()), - generateSampleMessage(new protos.google.cloud.gkehub.v1beta.Feature()), - generateSampleMessage(new protos.google.cloud.gkehub.v1beta.Feature()), - ]; - client.descriptors.page.listFeatures.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.gkehub.v1beta.IFeature[] = []; - const iterable = client.listFeaturesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listFeatures.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listFeatures.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.listFeatures.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listFeatures, request), + ); + assert( + (client.descriptors.page.listFeatures.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listFeatures with error', async () => { - const client = new gkehubModule.v1beta.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkehub.v1beta.ListFeaturesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkehub.v1beta.ListFeaturesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listFeatures.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listFeaturesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.gkehub.v1beta.IFeature[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listFeatures.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listFeatures.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listFeatures without error', async () => { + const client = new gkehubModule.v1beta.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta.ListFeaturesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta.ListFeaturesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.gkehub.v1beta.Feature()), + generateSampleMessage(new protos.google.cloud.gkehub.v1beta.Feature()), + generateSampleMessage(new protos.google.cloud.gkehub.v1beta.Feature()), + ]; + client.descriptors.page.listFeatures.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.gkehub.v1beta.IFeature[] = []; + const iterable = client.listFeaturesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listFeatures.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listFeatures.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); }); - describe('Path templates', () => { - - describe('feature', async () => { - const fakePath = "/rendered/path/feature"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - feature: "featureValue", - }; - const client = new gkehubModule.v1beta.GkeHubClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.featurePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.featurePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('featurePath', () => { - const result = client.featurePath("projectValue", "locationValue", "featureValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.featurePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromFeatureName', () => { - const result = client.matchProjectFromFeatureName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.featurePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromFeatureName', () => { - const result = client.matchLocationFromFeatureName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.featurePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchFeatureFromFeatureName', () => { - const result = client.matchFeatureFromFeatureName(fakePath); - assert.strictEqual(result, "featureValue"); - assert((client.pathTemplates.featurePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('uses async iteration with listFeatures with error', async () => { + const client = new gkehubModule.v1beta.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkehub.v1beta.ListFeaturesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkehub.v1beta.ListFeaturesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listFeatures.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listFeaturesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.gkehub.v1beta.IFeature[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listFeatures.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listFeatures.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('Path templates', () => { + describe('feature', async () => { + const fakePath = '/rendered/path/feature'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + feature: 'featureValue', + }; + const client = new gkehubModule.v1beta.GkeHubClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.featurePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.featurePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('featurePath', () => { + const result = client.featurePath( + 'projectValue', + 'locationValue', + 'featureValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.featurePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromFeatureName', () => { + const result = client.matchProjectFromFeatureName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.featurePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromFeatureName', () => { + const result = client.matchLocationFromFeatureName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.featurePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchFeatureFromFeatureName', () => { + const result = client.matchFeatureFromFeatureName(fakePath); + assert.strictEqual(result, 'featureValue'); + assert( + (client.pathTemplates.featurePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-gkehub/webpack.config.js b/packages/google-cloud-gkehub/webpack.config.js index ffe724d16f06..71afa3a607d6 100644 --- a/packages/google-cloud-gkehub/webpack.config.js +++ b/packages/google-cloud-gkehub/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-gkemulticloud/.eslintignore b/packages/google-cloud-gkemulticloud/.eslintignore new file mode 100644 index 000000000000..cfc348ec4d11 --- /dev/null +++ b/packages/google-cloud-gkemulticloud/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/packages/google-cloud-gkemulticloud/.eslintrc.json b/packages/google-cloud-gkemulticloud/.eslintrc.json new file mode 100644 index 000000000000..3e8d97ccb390 --- /dev/null +++ b/packages/google-cloud-gkemulticloud/.eslintrc.json @@ -0,0 +1,4 @@ +{ + "extends": "./node_modules/gts", + "root": true +} diff --git a/packages/google-cloud-gkemulticloud/README.md b/packages/google-cloud-gkemulticloud/README.md index d1483f4dda33..de4351e98f93 100644 --- a/packages/google-cloud-gkemulticloud/README.md +++ b/packages/google-cloud-gkemulticloud/README.md @@ -136,7 +136,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-gkemulticloud/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`) @@ -146,7 +146,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-gkemulticloud/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-gkemulticloud/protos/protos.d.ts b/packages/google-cloud-gkemulticloud/protos/protos.d.ts index e00e81e9296b..64e654eee4c6 100644 --- a/packages/google-cloud-gkemulticloud/protos/protos.d.ts +++ b/packages/google-cloud-gkemulticloud/protos/protos.d.ts @@ -16982,6 +16982,9 @@ export namespace google { /** CommonLanguageSettings destinations */ destinations?: (google.api.ClientLibraryDestination[]|null); + + /** CommonLanguageSettings selectiveGapicGeneration */ + selectiveGapicGeneration?: (google.api.ISelectiveGapicGeneration|null); } /** Represents a CommonLanguageSettings. */ @@ -16999,6 +17002,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 @@ -17699,6 +17705,9 @@ export namespace google { /** PythonSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** PythonSettings experimentalFeatures */ + experimentalFeatures?: (google.api.PythonSettings.IExperimentalFeatures|null); } /** Represents a PythonSettings. */ @@ -17713,6 +17722,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 @@ -17791,6 +17803,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 { @@ -18117,6 +18241,9 @@ export namespace google { /** GoSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** GoSettings renamedServices */ + renamedServices?: ({ [k: string]: string }|null); } /** Represents a GoSettings. */ @@ -18131,6 +18258,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 @@ -18455,6 +18585,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, @@ -18571,6 +18804,7 @@ export namespace google { /** Edition enum. */ enum Edition { EDITION_UNKNOWN = 0, + EDITION_LEGACY = 900, EDITION_PROTO2 = 998, EDITION_PROTO3 = 999, EDITION_2023 = 1000, @@ -18601,6 +18835,9 @@ export namespace google { /** FileDescriptorProto weakDependency */ weakDependency?: (number[]|null); + /** FileDescriptorProto optionDependency */ + optionDependency?: (string[]|null); + /** FileDescriptorProto messageType */ messageType?: (google.protobuf.IDescriptorProto[]|null); @@ -18650,6 +18887,9 @@ export namespace google { /** FileDescriptorProto weakDependency. */ public weakDependency: number[]; + /** FileDescriptorProto optionDependency. */ + public optionDependency: string[]; + /** FileDescriptorProto messageType. */ public messageType: google.protobuf.IDescriptorProto[]; @@ -18784,6 +19024,9 @@ export namespace google { /** DescriptorProto reservedName */ reservedName?: (string[]|null); + + /** DescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents a DescriptorProto. */ @@ -18825,6 +19068,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 @@ -19672,6 +19918,9 @@ export namespace google { /** EnumDescriptorProto reservedName */ reservedName?: (string[]|null); + + /** EnumDescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents an EnumDescriptorProto. */ @@ -19698,6 +19947,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 @@ -20632,6 +20884,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); @@ -20687,6 +20942,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[]; @@ -20907,6 +21165,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. */ @@ -21145,6 +21518,9 @@ export namespace google { /** EnumValueOptions debugRedact */ debugRedact?: (boolean|null); + /** EnumValueOptions featureSupport */ + featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** EnumValueOptions uninterpretedOption */ uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); } @@ -21167,6 +21543,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[]; @@ -21759,6 +22138,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. */ @@ -21788,6 +22173,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 @@ -21910,6 +22301,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. */ @@ -22029,8 +22530,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. */ @@ -22045,8 +22549,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. @@ -22579,6 +23086,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-gkemulticloud/protos/protos.js b/packages/google-cloud-gkemulticloud/protos/protos.js index cdc01c7312cb..e1dc2e6c46dd 100644 --- a/packages/google-cloud-gkemulticloud/protos/protos.js +++ b/packages/google-cloud-gkemulticloud/protos/protos.js @@ -41772,6 +41772,7 @@ * @interface ICommonLanguageSettings * @property {string|null} [referenceDocsUri] CommonLanguageSettings referenceDocsUri * @property {Array.|null} [destinations] CommonLanguageSettings destinations + * @property {google.api.ISelectiveGapicGeneration|null} [selectiveGapicGeneration] CommonLanguageSettings selectiveGapicGeneration */ /** @@ -41806,6 +41807,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 @@ -41838,6 +41847,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; }; @@ -41889,6 +41900,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; @@ -41940,6 +41955,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; }; @@ -41982,6 +42002,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; }; @@ -42000,8 +42025,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) { @@ -42009,6 +42036,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; }; @@ -43831,6 +43860,7 @@ * @memberof google.api * @interface IPythonSettings * @property {google.api.ICommonLanguageSettings|null} [common] PythonSettings common + * @property {google.api.PythonSettings.IExperimentalFeatures|null} [experimentalFeatures] PythonSettings experimentalFeatures */ /** @@ -43856,6 +43886,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 @@ -43882,6 +43920,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; }; @@ -43922,6 +43962,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; @@ -43962,6 +44006,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; }; @@ -43982,6 +44031,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; }; @@ -43998,10 +44052,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; }; @@ -44031,6 +44089,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; })(); @@ -44907,6 +45217,7 @@ * @memberof google.api * @interface IGoSettings * @property {google.api.ICommonLanguageSettings|null} [common] GoSettings common + * @property {Object.|null} [renamedServices] GoSettings renamedServices */ /** @@ -44918,6 +45229,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) @@ -44932,6 +45244,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 @@ -44958,6 +45278,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; }; @@ -44988,7 +45311,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) @@ -44998,6 +45321,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; @@ -45038,6 +45384,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; }; @@ -45058,6 +45412,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; }; @@ -45074,10 +45435,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; }; @@ -45716,30 +46085,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; @@ -45985,6 +46599,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 @@ -45999,6 +46614,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; @@ -46023,6 +46639,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 @@ -46045,6 +46662,7 @@ this.dependency = []; this.publicDependency = []; this.weakDependency = []; + this.optionDependency = []; this.messageType = []; this.enumType = []; this.service = []; @@ -46095,6 +46713,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 @@ -46216,6 +46842,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; }; @@ -46288,6 +46917,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 = []; @@ -46390,6 +47025,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"; @@ -46444,6 +47086,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -46496,6 +47139,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"); @@ -46559,6 +47209,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -46624,6 +47278,7 @@ object.extension = []; object.publicDependency = []; object.weakDependency = []; + object.optionDependency = []; } if (options.defaults) { object.name = ""; @@ -46680,6 +47335,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; }; @@ -46728,6 +47388,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 */ /** @@ -46833,6 +47494,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 @@ -46885,6 +47554,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; }; @@ -46977,6 +47648,10 @@ message.reservedName.push(reader.string()); break; } + case 11: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -47090,6 +47765,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; }; @@ -47189,6 +47873,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; }; @@ -47218,6 +47922,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; @@ -47263,6 +47968,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; }; @@ -49307,6 +50014,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 */ /** @@ -49367,6 +50075,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 @@ -49404,6 +50120,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; }; @@ -49466,6 +50184,10 @@ message.reservedName.push(reader.string()); break; } + case 6: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -49534,6 +50256,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; }; @@ -49583,6 +50314,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; }; @@ -49607,6 +50358,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; @@ -49627,6 +50379,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; }; @@ -51945,6 +52699,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 @@ -52065,6 +52820,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 @@ -52139,6 +52902,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(); @@ -52240,6 +53005,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 = []; @@ -52375,6 +53144,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"; @@ -52563,6 +53337,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"); @@ -52660,6 +53439,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")) @@ -52692,6 +53472,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) @@ -52964,6 +53746,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -53005,103 +53788,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; @@ -53696,6 +54965,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 */ @@ -53739,6 +55009,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 @@ -53777,6 +55055,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(); @@ -53828,6 +55108,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 = []; @@ -53880,6 +55164,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"; @@ -53913,6 +55202,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"); @@ -53945,6 +55239,7 @@ object.deprecated = false; object.features = null; object.debugRedact = false; + object.featureSupport = null; } if (message.deprecated != null && message.hasOwnProperty("deprecated")) object.deprecated = message.deprecated; @@ -53952,6 +55247,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) @@ -55419,6 +56716,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 */ /** @@ -55484,6 +56783,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 @@ -55520,6 +56835,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; }; @@ -55580,6 +56899,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; @@ -55670,6 +56997,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; }; @@ -55809,6 +57156,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; }; @@ -55832,6 +57227,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; @@ -55845,6 +57242,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; }; @@ -55972,6 +57373,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; })(); @@ -56156,6 +57770,7 @@ default: return "minimumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -56173,6 +57788,7 @@ default: return "maximumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -56221,6 +57837,10 @@ case 0: message.minimumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.minimumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.minimumEdition = 998; @@ -56273,6 +57893,10 @@ case 0: message.maximumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.maximumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.maximumEdition = 998; @@ -56381,7 +58005,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 */ /** @@ -56408,12 +58033,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. @@ -56439,10 +58072,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; }; @@ -56483,8 +58118,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: @@ -56527,6 +58166,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -56539,10 +58179,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; }; @@ -56570,6 +58215,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -56611,10 +58260,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; }; @@ -56633,13 +58287,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; }; @@ -57854,6 +59511,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-gkemulticloud/protos/protos.json b/packages/google-cloud-gkemulticloud/protos/protos.json index 303e96c6f9e0..3c3c842e9bfe 100644 --- a/packages/google-cloud-gkemulticloud/protos/protos.json +++ b/packages/google-cloud-gkemulticloud/protos/protos.json @@ -5269,8 +5269,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": { @@ -5493,6 +5492,10 @@ "rule": "repeated", "type": "ClientLibraryDestination", "id": 2 + }, + "selectiveGapicGeneration": { + "type": "SelectiveGapicGeneration", + "id": 3 } } }, @@ -5633,6 +5636,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 + } + } } } }, @@ -5690,6 +5715,11 @@ "common": { "type": "CommonLanguageSettings", "id": 1 + }, + "renamedServices": { + "keyType": "string", + "type": "string", + "id": 2 } } }, @@ -5751,6 +5781,19 @@ "PACKAGE_MANAGER": 20 } }, + "SelectiveGapicGeneration": { + "fields": { + "methods": { + "rule": "repeated", + "type": "string", + "id": 1 + }, + "generateOmittedAsInternal": { + "type": "bool", + "id": 2 + } + } + }, "LaunchStage": { "values": { "LAUNCH_STAGE_UNSPECIFIED": 0, @@ -5784,12 +5827,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, @@ -5828,6 +5878,11 @@ "type": "int32", "id": 11 }, + "optionDependency": { + "rule": "repeated", + "type": "string", + "id": 15 + }, "messageType": { "rule": "repeated", "type": "DescriptorProto", @@ -5916,6 +5971,10 @@ "rule": "repeated", "type": "string", "id": 10 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 11 } }, "nested": { @@ -6141,6 +6200,10 @@ "rule": "repeated", "type": "string", "id": 5 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 6 } }, "nested": { @@ -6191,7 +6254,14 @@ "type": "ServiceOptions", "id": 3 } - } + }, + "reserved": [ + [ + 4, + 4 + ], + "stream" + ] }, "MethodDescriptorProto": { "edition": "proto2", @@ -6355,6 +6425,7 @@ 42, 42 ], + "php_generic_services", [ 38, 38 @@ -6490,7 +6561,8 @@ "type": "bool", "id": 10, "options": { - "default": false + "default": false, + "deprecated": true } }, "debugRedact": { @@ -6518,6 +6590,10 @@ "type": "FeatureSet", "id": 21 }, + "featureSupport": { + "type": "FeatureSupport", + "id": 22 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -6587,6 +6663,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 + } + } } } }, @@ -6675,6 +6771,10 @@ "default": false } }, + "featureSupport": { + "type": "FieldOptions.FeatureSupport", + "id": 4 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -6817,6 +6917,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_2023", "edition_defaults.value": "EXPLICIT" } @@ -6827,6 +6928,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "OPEN" } @@ -6837,6 +6939,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "PACKED" } @@ -6847,6 +6950,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "VERIFY" } @@ -6857,7 +6961,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" } }, @@ -6867,27 +6972,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, @@ -6932,7 +7048,13 @@ "UTF8_VALIDATION_UNKNOWN": 0, "VERIFY": 2, "NONE": 3 - } + }, + "reserved": [ + [ + 1, + 1 + ] + ] }, "MessageEncoding": { "values": { @@ -6947,6 +7069,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 + } + } + } } } }, @@ -6974,11 +7123,26 @@ "type": "Edition", "id": 3 }, - "features": { + "overridableFeatures": { "type": "FeatureSet", - "id": 2 + "id": 4 + }, + "fixedFeatures": { + "type": "FeatureSet", + "id": 5 } - } + }, + "reserved": [ + [ + 1, + 1 + ], + [ + 2, + 2 + ], + "features" + ] } } }, @@ -6991,6 +7155,12 @@ "id": 1 } }, + "extensions": [ + [ + 536000000, + 536000000 + ] + ], "nested": { "Location": { "fields": { @@ -7076,6 +7246,14 @@ } } }, + "SymbolVisibility": { + "edition": "proto2", + "values": { + "VISIBILITY_UNSET": 0, + "VISIBILITY_LOCAL": 1, + "VISIBILITY_EXPORT": 2 + } + }, "Timestamp": { "fields": { "seconds": { @@ -7162,6 +7340,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-gkemulticloud/samples/generated/v1/snippet_metadata_google.cloud.gkemulticloud.v1.json b/packages/google-cloud-gkemulticloud/samples/generated/v1/snippet_metadata_google.cloud.gkemulticloud.v1.json index 83af11a00d01..cdd0c5f0cafc 100644 --- a/packages/google-cloud-gkemulticloud/samples/generated/v1/snippet_metadata_google.cloud.gkemulticloud.v1.json +++ b/packages/google-cloud-gkemulticloud/samples/generated/v1/snippet_metadata_google.cloud.gkemulticloud.v1.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-gkemulticloud", - "version": "2.3.0", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-gkemulticloud/src/v1/attached_clusters_client.ts b/packages/google-cloud-gkemulticloud/src/v1/attached_clusters_client.ts index 0929e7af0034..ebf5257b7404 100644 --- a/packages/google-cloud-gkemulticloud/src/v1/attached_clusters_client.ts +++ b/packages/google-cloud-gkemulticloud/src/v1/attached_clusters_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 @@ -46,7 +55,7 @@ export class AttachedClustersClient { 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('gkemulticloud'); @@ -59,10 +68,10 @@ export class AttachedClustersClient { 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; - attachedClustersStub?: Promise<{[name: string]: Function}>; + attachedClustersStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of AttachedClustersClient. @@ -103,21 +112,42 @@ export class AttachedClustersClient { * const client = new AttachedClustersClient({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 AttachedClustersClient; - 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 = 'gkemulticloud.' + 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); // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. if (servicePath !== this._servicePath && !('scopes' in opts)) { @@ -139,7 +169,7 @@ export class AttachedClustersClient { 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 +183,7 @@ export class AttachedClustersClient { } // 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,37 +205,37 @@ export class AttachedClustersClient { // Create useful helper objects for these. this.pathTemplates = { attachedClusterPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/attachedClusters/{attached_cluster}' + 'projects/{project}/locations/{location}/attachedClusters/{attached_cluster}', ), attachedServerConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/attachedServerConfig' + 'projects/{project}/locations/{location}/attachedServerConfig', ), awsClusterPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/awsClusters/{aws_cluster}' + 'projects/{project}/locations/{location}/awsClusters/{aws_cluster}', ), awsNodePoolPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/awsClusters/{aws_cluster}/awsNodePools/{aws_node_pool}' + 'projects/{project}/locations/{location}/awsClusters/{aws_cluster}/awsNodePools/{aws_node_pool}', ), awsServerConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/awsServerConfig' + 'projects/{project}/locations/{location}/awsServerConfig', ), azureClientPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/azureClients/{azure_client}' + 'projects/{project}/locations/{location}/azureClients/{azure_client}', ), azureClusterPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/azureClusters/{azure_cluster}' + 'projects/{project}/locations/{location}/azureClusters/{azure_cluster}', ), azureNodePoolPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/azureClusters/{azure_cluster}/azureNodePools/{azure_node_pool}' + 'projects/{project}/locations/{location}/azureClusters/{azure_cluster}/azureNodePools/{azure_node_pool}', ), azureServerConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/azureServerConfig' + 'projects/{project}/locations/{location}/azureServerConfig', ), locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' + 'projects/{project}/locations/{location}', ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' + 'projects/{project}', ), }; @@ -216,8 +243,11 @@ export class AttachedClustersClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listAttachedClusters: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'attachedClusters') + listAttachedClusters: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'attachedClusters', + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -226,53 +256,104 @@ export class AttachedClustersClient { // 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.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.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 createAttachedClusterResponse = protoFilesRoot.lookup( - '.google.cloud.gkemulticloud.v1.AttachedCluster') as gax.protobuf.Type; + '.google.cloud.gkemulticloud.v1.AttachedCluster', + ) as gax.protobuf.Type; const createAttachedClusterMetadata = protoFilesRoot.lookup( - '.google.cloud.gkemulticloud.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.gkemulticloud.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateAttachedClusterResponse = protoFilesRoot.lookup( - '.google.cloud.gkemulticloud.v1.AttachedCluster') as gax.protobuf.Type; + '.google.cloud.gkemulticloud.v1.AttachedCluster', + ) as gax.protobuf.Type; const updateAttachedClusterMetadata = protoFilesRoot.lookup( - '.google.cloud.gkemulticloud.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.gkemulticloud.v1.OperationMetadata', + ) as gax.protobuf.Type; const importAttachedClusterResponse = protoFilesRoot.lookup( - '.google.cloud.gkemulticloud.v1.AttachedCluster') as gax.protobuf.Type; + '.google.cloud.gkemulticloud.v1.AttachedCluster', + ) as gax.protobuf.Type; const importAttachedClusterMetadata = protoFilesRoot.lookup( - '.google.cloud.gkemulticloud.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.gkemulticloud.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteAttachedClusterResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteAttachedClusterMetadata = protoFilesRoot.lookup( - '.google.cloud.gkemulticloud.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.gkemulticloud.v1.OperationMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { createAttachedCluster: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - createAttachedClusterResponse.decode.bind(createAttachedClusterResponse), - createAttachedClusterMetadata.decode.bind(createAttachedClusterMetadata)), + createAttachedClusterResponse.decode.bind( + createAttachedClusterResponse, + ), + createAttachedClusterMetadata.decode.bind( + createAttachedClusterMetadata, + ), + ), updateAttachedCluster: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - updateAttachedClusterResponse.decode.bind(updateAttachedClusterResponse), - updateAttachedClusterMetadata.decode.bind(updateAttachedClusterMetadata)), + updateAttachedClusterResponse.decode.bind( + updateAttachedClusterResponse, + ), + updateAttachedClusterMetadata.decode.bind( + updateAttachedClusterMetadata, + ), + ), importAttachedCluster: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - importAttachedClusterResponse.decode.bind(importAttachedClusterResponse), - importAttachedClusterMetadata.decode.bind(importAttachedClusterMetadata)), + importAttachedClusterResponse.decode.bind( + importAttachedClusterResponse, + ), + importAttachedClusterMetadata.decode.bind( + importAttachedClusterMetadata, + ), + ), deleteAttachedCluster: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - deleteAttachedClusterResponse.decode.bind(deleteAttachedClusterResponse), - deleteAttachedClusterMetadata.decode.bind(deleteAttachedClusterMetadata)) + deleteAttachedClusterResponse.decode.bind( + deleteAttachedClusterResponse, + ), + deleteAttachedClusterMetadata.decode.bind( + deleteAttachedClusterMetadata, + ), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.gkemulticloud.v1.AttachedClusters', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.gkemulticloud.v1.AttachedClusters', + 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 @@ -303,28 +384,43 @@ export class AttachedClustersClient { // Put together the "service stub" for // google.cloud.gkemulticloud.v1.AttachedClusters. this.attachedClustersStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.gkemulticloud.v1.AttachedClusters') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.gkemulticloud.v1.AttachedClusters', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.gkemulticloud.v1.AttachedClusters, - 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 attachedClustersStubMethods = - ['createAttachedCluster', 'updateAttachedCluster', 'importAttachedCluster', 'getAttachedCluster', 'listAttachedClusters', 'deleteAttachedCluster', 'getAttachedServerConfig', 'generateAttachedClusterInstallManifest', 'generateAttachedClusterAgentToken']; + const attachedClustersStubMethods = [ + 'createAttachedCluster', + 'updateAttachedCluster', + 'importAttachedCluster', + 'getAttachedCluster', + 'listAttachedClusters', + 'deleteAttachedCluster', + 'getAttachedServerConfig', + 'generateAttachedClusterInstallManifest', + 'generateAttachedClusterAgentToken', + ]; for (const methodName of attachedClustersStubMethods) { const callPromise = this.attachedClustersStub.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] || @@ -334,7 +430,7 @@ export class AttachedClustersClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -349,8 +445,14 @@ export class AttachedClustersClient { * @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 'gkemulticloud.googleapis.com'; } @@ -361,8 +463,14 @@ export class AttachedClustersClient { * @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 'gkemulticloud.googleapis.com'; } @@ -393,9 +501,7 @@ export class AttachedClustersClient { * @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; @@ -404,8 +510,9 @@ export class AttachedClustersClient { * 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; @@ -416,1090 +523,1574 @@ export class AttachedClustersClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Describes a specific - * {@link protos.google.cloud.gkemulticloud.v1.AttachedCluster|AttachedCluster} resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the - * {@link protos.google.cloud.gkemulticloud.v1.AttachedCluster|AttachedCluster} resource - * to describe. - * - * `AttachedCluster` names are formatted as - * `projects//locations//attachedClusters/`. - * - * See [Resource Names](https://cloud.google.com/apis/design/resource_names) - * for more details on Google Cloud Platform resource names. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.gkemulticloud.v1.AttachedCluster|AttachedCluster}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/attached_clusters.get_attached_cluster.js - * region_tag:gkemulticloud_v1_generated_AttachedClusters_GetAttachedCluster_async - */ + /** + * Describes a specific + * {@link protos.google.cloud.gkemulticloud.v1.AttachedCluster|AttachedCluster} resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the + * {@link protos.google.cloud.gkemulticloud.v1.AttachedCluster|AttachedCluster} resource + * to describe. + * + * `AttachedCluster` names are formatted as + * `projects//locations//attachedClusters/`. + * + * See [Resource Names](https://cloud.google.com/apis/design/resource_names) + * for more details on Google Cloud Platform resource names. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.gkemulticloud.v1.AttachedCluster|AttachedCluster}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/attached_clusters.get_attached_cluster.js + * region_tag:gkemulticloud_v1_generated_AttachedClusters_GetAttachedCluster_async + */ getAttachedCluster( - request?: protos.google.cloud.gkemulticloud.v1.IGetAttachedClusterRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gkemulticloud.v1.IAttachedCluster, - protos.google.cloud.gkemulticloud.v1.IGetAttachedClusterRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkemulticloud.v1.IGetAttachedClusterRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gkemulticloud.v1.IAttachedCluster, + ( + | protos.google.cloud.gkemulticloud.v1.IGetAttachedClusterRequest + | undefined + ), + {} | undefined, + ] + >; getAttachedCluster( - request: protos.google.cloud.gkemulticloud.v1.IGetAttachedClusterRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.gkemulticloud.v1.IAttachedCluster, - protos.google.cloud.gkemulticloud.v1.IGetAttachedClusterRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IGetAttachedClusterRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.gkemulticloud.v1.IAttachedCluster, + | protos.google.cloud.gkemulticloud.v1.IGetAttachedClusterRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getAttachedCluster( - request: protos.google.cloud.gkemulticloud.v1.IGetAttachedClusterRequest, - callback: Callback< - protos.google.cloud.gkemulticloud.v1.IAttachedCluster, - protos.google.cloud.gkemulticloud.v1.IGetAttachedClusterRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IGetAttachedClusterRequest, + callback: Callback< + protos.google.cloud.gkemulticloud.v1.IAttachedCluster, + | protos.google.cloud.gkemulticloud.v1.IGetAttachedClusterRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getAttachedCluster( - request?: protos.google.cloud.gkemulticloud.v1.IGetAttachedClusterRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.gkemulticloud.v1.IAttachedCluster, - protos.google.cloud.gkemulticloud.v1.IGetAttachedClusterRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.gkemulticloud.v1.IGetAttachedClusterRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.gkemulticloud.v1.IAttachedCluster, - protos.google.cloud.gkemulticloud.v1.IGetAttachedClusterRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.gkemulticloud.v1.IAttachedCluster, - protos.google.cloud.gkemulticloud.v1.IGetAttachedClusterRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.gkemulticloud.v1.IGetAttachedClusterRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.gkemulticloud.v1.IAttachedCluster, + | protos.google.cloud.gkemulticloud.v1.IGetAttachedClusterRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.gkemulticloud.v1.IAttachedCluster, + ( + | protos.google.cloud.gkemulticloud.v1.IGetAttachedClusterRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getAttachedCluster request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.gkemulticloud.v1.IAttachedCluster, - protos.google.cloud.gkemulticloud.v1.IGetAttachedClusterRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.gkemulticloud.v1.IAttachedCluster, + | protos.google.cloud.gkemulticloud.v1.IGetAttachedClusterRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getAttachedCluster response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getAttachedCluster(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.gkemulticloud.v1.IAttachedCluster, - protos.google.cloud.gkemulticloud.v1.IGetAttachedClusterRequest|undefined, - {}|undefined - ]) => { - this._log.info('getAttachedCluster response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getAttachedCluster(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.gkemulticloud.v1.IAttachedCluster, + ( + | protos.google.cloud.gkemulticloud.v1.IGetAttachedClusterRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getAttachedCluster response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 information, such as supported Kubernetes versions, on a given - * Google Cloud location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the - * {@link protos.google.cloud.gkemulticloud.v1.AttachedServerConfig|AttachedServerConfig} - * resource to describe. - * - * `AttachedServerConfig` names are formatted as - * `projects//locations//attachedServerConfig`. - * - * See [Resource Names](https://cloud.google.com/apis/design/resource_names) - * for more details on Google Cloud resource names. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.gkemulticloud.v1.AttachedServerConfig|AttachedServerConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/attached_clusters.get_attached_server_config.js - * region_tag:gkemulticloud_v1_generated_AttachedClusters_GetAttachedServerConfig_async - */ + /** + * Returns information, such as supported Kubernetes versions, on a given + * Google Cloud location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the + * {@link protos.google.cloud.gkemulticloud.v1.AttachedServerConfig|AttachedServerConfig} + * resource to describe. + * + * `AttachedServerConfig` names are formatted as + * `projects//locations//attachedServerConfig`. + * + * See [Resource Names](https://cloud.google.com/apis/design/resource_names) + * for more details on Google Cloud resource names. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.gkemulticloud.v1.AttachedServerConfig|AttachedServerConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/attached_clusters.get_attached_server_config.js + * region_tag:gkemulticloud_v1_generated_AttachedClusters_GetAttachedServerConfig_async + */ getAttachedServerConfig( - request?: protos.google.cloud.gkemulticloud.v1.IGetAttachedServerConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gkemulticloud.v1.IAttachedServerConfig, - protos.google.cloud.gkemulticloud.v1.IGetAttachedServerConfigRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkemulticloud.v1.IGetAttachedServerConfigRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gkemulticloud.v1.IAttachedServerConfig, + ( + | protos.google.cloud.gkemulticloud.v1.IGetAttachedServerConfigRequest + | undefined + ), + {} | undefined, + ] + >; getAttachedServerConfig( - request: protos.google.cloud.gkemulticloud.v1.IGetAttachedServerConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.gkemulticloud.v1.IAttachedServerConfig, - protos.google.cloud.gkemulticloud.v1.IGetAttachedServerConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IGetAttachedServerConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.gkemulticloud.v1.IAttachedServerConfig, + | protos.google.cloud.gkemulticloud.v1.IGetAttachedServerConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getAttachedServerConfig( - request: protos.google.cloud.gkemulticloud.v1.IGetAttachedServerConfigRequest, - callback: Callback< - protos.google.cloud.gkemulticloud.v1.IAttachedServerConfig, - protos.google.cloud.gkemulticloud.v1.IGetAttachedServerConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IGetAttachedServerConfigRequest, + callback: Callback< + protos.google.cloud.gkemulticloud.v1.IAttachedServerConfig, + | protos.google.cloud.gkemulticloud.v1.IGetAttachedServerConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getAttachedServerConfig( - request?: protos.google.cloud.gkemulticloud.v1.IGetAttachedServerConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.gkemulticloud.v1.IAttachedServerConfig, - protos.google.cloud.gkemulticloud.v1.IGetAttachedServerConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.gkemulticloud.v1.IGetAttachedServerConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.gkemulticloud.v1.IAttachedServerConfig, - protos.google.cloud.gkemulticloud.v1.IGetAttachedServerConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.gkemulticloud.v1.IAttachedServerConfig, - protos.google.cloud.gkemulticloud.v1.IGetAttachedServerConfigRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.gkemulticloud.v1.IGetAttachedServerConfigRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.gkemulticloud.v1.IAttachedServerConfig, + | protos.google.cloud.gkemulticloud.v1.IGetAttachedServerConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.gkemulticloud.v1.IAttachedServerConfig, + ( + | protos.google.cloud.gkemulticloud.v1.IGetAttachedServerConfigRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getAttachedServerConfig request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.gkemulticloud.v1.IAttachedServerConfig, - protos.google.cloud.gkemulticloud.v1.IGetAttachedServerConfigRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.gkemulticloud.v1.IAttachedServerConfig, + | protos.google.cloud.gkemulticloud.v1.IGetAttachedServerConfigRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getAttachedServerConfig response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getAttachedServerConfig(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.gkemulticloud.v1.IAttachedServerConfig, - protos.google.cloud.gkemulticloud.v1.IGetAttachedServerConfigRequest|undefined, - {}|undefined - ]) => { - this._log.info('getAttachedServerConfig response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getAttachedServerConfig(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.gkemulticloud.v1.IAttachedServerConfig, + ( + | protos.google.cloud.gkemulticloud.v1.IGetAttachedServerConfigRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getAttachedServerConfig response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 the install manifest to be installed on the target cluster. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent location where this - * {@link protos.google.cloud.gkemulticloud.v1.AttachedCluster|AttachedCluster} resource - * will be created. - * - * Location names are formatted as `projects//locations/`. - * - * See [Resource Names](https://cloud.google.com/apis/design/resource_names) - * for more details on Google Cloud resource names. - * @param {string} request.attachedClusterId - * Required. A client provided ID of the resource. Must be unique within the - * parent resource. - * - * The provided ID will be part of the - * {@link protos.google.cloud.gkemulticloud.v1.AttachedCluster|AttachedCluster} resource - * name formatted as - * `projects//locations//attachedClusters/`. - * - * Valid characters are `/{@link protos.0-9|a-z}-/`. Cannot be longer than 63 characters. - * - * When generating an install manifest for importing an existing Membership - * resource, the attached_cluster_id field must be the Membership id. - * - * Membership names are formatted as - * `projects//locations//memberships/`. - * @param {string} request.platformVersion - * Required. The platform version for the cluster (e.g. `1.19.0-gke.1000`). - * - * You can list all supported versions on a given Google Cloud region by - * calling - * {@link protos.google.cloud.gkemulticloud.v1.AttachedClusters.GetAttachedServerConfig|GetAttachedServerConfig}. - * @param {google.cloud.gkemulticloud.v1.AttachedProxyConfig} [request.proxyConfig] - * Optional. Proxy configuration for outbound HTTP(S) traffic. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.gkemulticloud.v1.GenerateAttachedClusterInstallManifestResponse|GenerateAttachedClusterInstallManifestResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/attached_clusters.generate_attached_cluster_install_manifest.js - * region_tag:gkemulticloud_v1_generated_AttachedClusters_GenerateAttachedClusterInstallManifest_async - */ + /** + * Generates the install manifest to be installed on the target cluster. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent location where this + * {@link protos.google.cloud.gkemulticloud.v1.AttachedCluster|AttachedCluster} resource + * will be created. + * + * Location names are formatted as `projects//locations/`. + * + * See [Resource Names](https://cloud.google.com/apis/design/resource_names) + * for more details on Google Cloud resource names. + * @param {string} request.attachedClusterId + * Required. A client provided ID of the resource. Must be unique within the + * parent resource. + * + * The provided ID will be part of the + * {@link protos.google.cloud.gkemulticloud.v1.AttachedCluster|AttachedCluster} resource + * name formatted as + * `projects//locations//attachedClusters/`. + * + * Valid characters are `/{@link protos.0-9|a-z}-/`. Cannot be longer than 63 characters. + * + * When generating an install manifest for importing an existing Membership + * resource, the attached_cluster_id field must be the Membership id. + * + * Membership names are formatted as + * `projects//locations//memberships/`. + * @param {string} request.platformVersion + * Required. The platform version for the cluster (e.g. `1.19.0-gke.1000`). + * + * You can list all supported versions on a given Google Cloud region by + * calling + * {@link protos.google.cloud.gkemulticloud.v1.AttachedClusters.GetAttachedServerConfig|GetAttachedServerConfig}. + * @param {google.cloud.gkemulticloud.v1.AttachedProxyConfig} [request.proxyConfig] + * Optional. Proxy configuration for outbound HTTP(S) traffic. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.gkemulticloud.v1.GenerateAttachedClusterInstallManifestResponse|GenerateAttachedClusterInstallManifestResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/attached_clusters.generate_attached_cluster_install_manifest.js + * region_tag:gkemulticloud_v1_generated_AttachedClusters_GenerateAttachedClusterInstallManifest_async + */ generateAttachedClusterInstallManifest( - request?: protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterInstallManifestRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterInstallManifestResponse, - protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterInstallManifestRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterInstallManifestRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterInstallManifestResponse, + ( + | protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterInstallManifestRequest + | undefined + ), + {} | undefined, + ] + >; generateAttachedClusterInstallManifest( - request: protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterInstallManifestRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterInstallManifestResponse, - protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterInstallManifestRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterInstallManifestRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterInstallManifestResponse, + | protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterInstallManifestRequest + | null + | undefined, + {} | null | undefined + >, + ): void; generateAttachedClusterInstallManifest( - request: protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterInstallManifestRequest, - callback: Callback< - protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterInstallManifestResponse, - protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterInstallManifestRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterInstallManifestRequest, + callback: Callback< + protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterInstallManifestResponse, + | protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterInstallManifestRequest + | null + | undefined, + {} | null | undefined + >, + ): void; generateAttachedClusterInstallManifest( - request?: protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterInstallManifestRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterInstallManifestResponse, - protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterInstallManifestRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterInstallManifestRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterInstallManifestResponse, - protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterInstallManifestRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterInstallManifestResponse, - protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterInstallManifestRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterInstallManifestRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterInstallManifestResponse, + | protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterInstallManifestRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterInstallManifestResponse, + ( + | protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterInstallManifestRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.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('generateAttachedClusterInstallManifest request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterInstallManifestResponse, - protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterInstallManifestRequest|null|undefined, - {}|null|undefined>|undefined = callback + this._log.info( + 'generateAttachedClusterInstallManifest request %j', + request, + ); + const wrappedCallback: + | Callback< + protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterInstallManifestResponse, + | protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterInstallManifestRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { - this._log.info('generateAttachedClusterInstallManifest response %j', response); + this._log.info( + 'generateAttachedClusterInstallManifest response %j', + response, + ); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.generateAttachedClusterInstallManifest(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterInstallManifestResponse, - protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterInstallManifestRequest|undefined, - {}|undefined - ]) => { - this._log.info('generateAttachedClusterInstallManifest response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .generateAttachedClusterInstallManifest(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterInstallManifestResponse, + ( + | protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterInstallManifestRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info( + 'generateAttachedClusterInstallManifest response %j', + response, + ); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 an access token for a cluster agent. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.attachedCluster - * Required. - * @param {string} request.subjectToken - * Required. - * @param {string} request.subjectTokenType - * Required. - * @param {string} request.version - * Required. - * @param {string} [request.grantType] - * Optional. - * @param {string} [request.audience] - * Optional. - * @param {string} [request.scope] - * Optional. - * @param {string} [request.requestedTokenType] - * Optional. - * @param {string} [request.options] - * Optional. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.gkemulticloud.v1.GenerateAttachedClusterAgentTokenResponse|GenerateAttachedClusterAgentTokenResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/attached_clusters.generate_attached_cluster_agent_token.js - * region_tag:gkemulticloud_v1_generated_AttachedClusters_GenerateAttachedClusterAgentToken_async - */ + /** + * Generates an access token for a cluster agent. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.attachedCluster + * Required. + * @param {string} request.subjectToken + * Required. + * @param {string} request.subjectTokenType + * Required. + * @param {string} request.version + * Required. + * @param {string} [request.grantType] + * Optional. + * @param {string} [request.audience] + * Optional. + * @param {string} [request.scope] + * Optional. + * @param {string} [request.requestedTokenType] + * Optional. + * @param {string} [request.options] + * Optional. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.gkemulticloud.v1.GenerateAttachedClusterAgentTokenResponse|GenerateAttachedClusterAgentTokenResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/attached_clusters.generate_attached_cluster_agent_token.js + * region_tag:gkemulticloud_v1_generated_AttachedClusters_GenerateAttachedClusterAgentToken_async + */ generateAttachedClusterAgentToken( - request?: protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterAgentTokenRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterAgentTokenResponse, - protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterAgentTokenRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterAgentTokenRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterAgentTokenResponse, + ( + | protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterAgentTokenRequest + | undefined + ), + {} | undefined, + ] + >; generateAttachedClusterAgentToken( - request: protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterAgentTokenRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterAgentTokenResponse, - protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterAgentTokenRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterAgentTokenRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterAgentTokenResponse, + | protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterAgentTokenRequest + | null + | undefined, + {} | null | undefined + >, + ): void; generateAttachedClusterAgentToken( - request: protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterAgentTokenRequest, - callback: Callback< - protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterAgentTokenResponse, - protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterAgentTokenRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterAgentTokenRequest, + callback: Callback< + protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterAgentTokenResponse, + | protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterAgentTokenRequest + | null + | undefined, + {} | null | undefined + >, + ): void; generateAttachedClusterAgentToken( - request?: protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterAgentTokenRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterAgentTokenResponse, - protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterAgentTokenRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterAgentTokenRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterAgentTokenResponse, - protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterAgentTokenRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterAgentTokenResponse, - protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterAgentTokenRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterAgentTokenRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterAgentTokenResponse, + | protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterAgentTokenRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterAgentTokenResponse, + ( + | protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterAgentTokenRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'attached_cluster': request.attachedCluster ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + attached_cluster: request.attachedCluster ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('generateAttachedClusterAgentToken request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterAgentTokenResponse, - protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterAgentTokenRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterAgentTokenResponse, + | protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterAgentTokenRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { - this._log.info('generateAttachedClusterAgentToken response %j', response); + this._log.info( + 'generateAttachedClusterAgentToken response %j', + response, + ); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.generateAttachedClusterAgentToken(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterAgentTokenResponse, - protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterAgentTokenRequest|undefined, - {}|undefined - ]) => { - this._log.info('generateAttachedClusterAgentToken response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .generateAttachedClusterAgentToken(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterAgentTokenResponse, + ( + | protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterAgentTokenRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info( + 'generateAttachedClusterAgentToken response %j', + response, + ); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 - * {@link protos.google.cloud.gkemulticloud.v1.AttachedCluster|AttachedCluster} resource - * on a given Google Cloud Platform project and region. - * - * If successful, the response contains a newly created - * {@link protos.google.longrunning.Operation|Operation} resource that can be - * described to track the status of the operation. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent location where this - * {@link protos.google.cloud.gkemulticloud.v1.AttachedCluster|AttachedCluster} resource - * will be created. - * - * Location names are formatted as `projects//locations/`. - * - * See [Resource Names](https://cloud.google.com/apis/design/resource_names) - * for more details on Google Cloud resource names. - * @param {google.cloud.gkemulticloud.v1.AttachedCluster} request.attachedCluster - * Required. The specification of the - * {@link protos.google.cloud.gkemulticloud.v1.AttachedCluster|AttachedCluster} to create. - * @param {string} request.attachedClusterId - * Required. A client provided ID the resource. Must be unique within the - * parent resource. - * - * The provided ID will be part of the - * {@link protos.google.cloud.gkemulticloud.v1.AttachedCluster|AttachedCluster} resource - * name formatted as - * `projects//locations//attachedClusters/`. - * - * Valid characters are `/{@link protos.0-9|a-z}-/`. Cannot be longer than 63 characters. - * @param {boolean} request.validateOnly - * If set, only validate the request, but do not actually create the cluster. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/attached_clusters.create_attached_cluster.js - * region_tag:gkemulticloud_v1_generated_AttachedClusters_CreateAttachedCluster_async - */ + /** + * Creates a new + * {@link protos.google.cloud.gkemulticloud.v1.AttachedCluster|AttachedCluster} resource + * on a given Google Cloud Platform project and region. + * + * If successful, the response contains a newly created + * {@link protos.google.longrunning.Operation|Operation} resource that can be + * described to track the status of the operation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent location where this + * {@link protos.google.cloud.gkemulticloud.v1.AttachedCluster|AttachedCluster} resource + * will be created. + * + * Location names are formatted as `projects//locations/`. + * + * See [Resource Names](https://cloud.google.com/apis/design/resource_names) + * for more details on Google Cloud resource names. + * @param {google.cloud.gkemulticloud.v1.AttachedCluster} request.attachedCluster + * Required. The specification of the + * {@link protos.google.cloud.gkemulticloud.v1.AttachedCluster|AttachedCluster} to create. + * @param {string} request.attachedClusterId + * Required. A client provided ID the resource. Must be unique within the + * parent resource. + * + * The provided ID will be part of the + * {@link protos.google.cloud.gkemulticloud.v1.AttachedCluster|AttachedCluster} resource + * name formatted as + * `projects//locations//attachedClusters/`. + * + * Valid characters are `/{@link protos.0-9|a-z}-/`. Cannot be longer than 63 characters. + * @param {boolean} request.validateOnly + * If set, only validate the request, but do not actually create the cluster. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/attached_clusters.create_attached_cluster.js + * region_tag:gkemulticloud_v1_generated_AttachedClusters_CreateAttachedCluster_async + */ createAttachedCluster( - request?: protos.google.cloud.gkemulticloud.v1.ICreateAttachedClusterRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkemulticloud.v1.ICreateAttachedClusterRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.gkemulticloud.v1.IAttachedCluster, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createAttachedCluster( - request: protos.google.cloud.gkemulticloud.v1.ICreateAttachedClusterRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.ICreateAttachedClusterRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAttachedCluster, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createAttachedCluster( - request: protos.google.cloud.gkemulticloud.v1.ICreateAttachedClusterRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.ICreateAttachedClusterRequest, + callback: Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAttachedCluster, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createAttachedCluster( - request?: protos.google.cloud.gkemulticloud.v1.ICreateAttachedClusterRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.gkemulticloud.v1.ICreateAttachedClusterRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAttachedCluster, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAttachedCluster, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.gkemulticloud.v1.IAttachedCluster, + protos.google.cloud.gkemulticloud.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.gkemulticloud.v1.IAttachedCluster, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createAttachedCluster response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createAttachedCluster request %j', request); - return this.innerApiCalls.createAttachedCluster(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createAttachedCluster response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createAttachedCluster(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.gkemulticloud.v1.IAttachedCluster, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createAttachedCluster response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createAttachedCluster()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/attached_clusters.create_attached_cluster.js - * region_tag:gkemulticloud_v1_generated_AttachedClusters_CreateAttachedCluster_async - */ - async checkCreateAttachedClusterProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createAttachedCluster()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/attached_clusters.create_attached_cluster.js + * region_tag:gkemulticloud_v1_generated_AttachedClusters_CreateAttachedCluster_async + */ + async checkCreateAttachedClusterProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.gkemulticloud.v1.AttachedCluster, + protos.google.cloud.gkemulticloud.v1.OperationMetadata + > + > { this._log.info('createAttachedCluster long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createAttachedCluster, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createAttachedCluster, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.gkemulticloud.v1.AttachedCluster, + protos.google.cloud.gkemulticloud.v1.OperationMetadata + >; } -/** - * Updates an - * {@link protos.google.cloud.gkemulticloud.v1.AttachedCluster|AttachedCluster}. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.gkemulticloud.v1.AttachedCluster} request.attachedCluster - * Required. The - * {@link protos.google.cloud.gkemulticloud.v1.AttachedCluster|AttachedCluster} resource - * to update. - * @param {boolean} request.validateOnly - * If set, only validate the request, but do not actually update the cluster. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. Mask of fields to update. At least one path must be supplied in - * this field. The elements of the repeated paths field can only include these - * fields from - * {@link protos.google.cloud.gkemulticloud.v1.AttachedCluster|AttachedCluster}: - * - * * `annotations`. - * * `authorization.admin_groups`. - * * `authorization.admin_users`. - * * `binary_authorization.evaluation_mode`. - * * `description`. - * * `logging_config.component_config.enable_components`. - * * `monitoring_config.managed_prometheus_config.enabled`. - * * `platform_version`. - * * `proxy_config.kubernetes_secret.name`. - * * `proxy_config.kubernetes_secret.namespace`. - * * `security_posture_config.vulnerability_mode` - * * `monitoring_config.cloud_monitoring_config.enabled` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/attached_clusters.update_attached_cluster.js - * region_tag:gkemulticloud_v1_generated_AttachedClusters_UpdateAttachedCluster_async - */ + /** + * Updates an + * {@link protos.google.cloud.gkemulticloud.v1.AttachedCluster|AttachedCluster}. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.gkemulticloud.v1.AttachedCluster} request.attachedCluster + * Required. The + * {@link protos.google.cloud.gkemulticloud.v1.AttachedCluster|AttachedCluster} resource + * to update. + * @param {boolean} request.validateOnly + * If set, only validate the request, but do not actually update the cluster. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. Mask of fields to update. At least one path must be supplied in + * this field. The elements of the repeated paths field can only include these + * fields from + * {@link protos.google.cloud.gkemulticloud.v1.AttachedCluster|AttachedCluster}: + * + * * `annotations`. + * * `authorization.admin_groups`. + * * `authorization.admin_users`. + * * `binary_authorization.evaluation_mode`. + * * `description`. + * * `logging_config.component_config.enable_components`. + * * `monitoring_config.managed_prometheus_config.enabled`. + * * `platform_version`. + * * `proxy_config.kubernetes_secret.name`. + * * `proxy_config.kubernetes_secret.namespace`. + * * `security_posture_config.vulnerability_mode` + * * `monitoring_config.cloud_monitoring_config.enabled` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/attached_clusters.update_attached_cluster.js + * region_tag:gkemulticloud_v1_generated_AttachedClusters_UpdateAttachedCluster_async + */ updateAttachedCluster( - request?: protos.google.cloud.gkemulticloud.v1.IUpdateAttachedClusterRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkemulticloud.v1.IUpdateAttachedClusterRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.gkemulticloud.v1.IAttachedCluster, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateAttachedCluster( - request: protos.google.cloud.gkemulticloud.v1.IUpdateAttachedClusterRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IUpdateAttachedClusterRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAttachedCluster, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateAttachedCluster( - request: protos.google.cloud.gkemulticloud.v1.IUpdateAttachedClusterRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IUpdateAttachedClusterRequest, + callback: Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAttachedCluster, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateAttachedCluster( - request?: protos.google.cloud.gkemulticloud.v1.IUpdateAttachedClusterRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.gkemulticloud.v1.IUpdateAttachedClusterRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAttachedCluster, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAttachedCluster, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.gkemulticloud.v1.IAttachedCluster, + protos.google.cloud.gkemulticloud.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({ - 'attached_cluster.name': request.attachedCluster!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'attached_cluster.name': request.attachedCluster!.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.gkemulticloud.v1.IAttachedCluster, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateAttachedCluster response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateAttachedCluster request %j', request); - return this.innerApiCalls.updateAttachedCluster(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateAttachedCluster response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateAttachedCluster(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.gkemulticloud.v1.IAttachedCluster, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateAttachedCluster response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateAttachedCluster()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/attached_clusters.update_attached_cluster.js - * region_tag:gkemulticloud_v1_generated_AttachedClusters_UpdateAttachedCluster_async - */ - async checkUpdateAttachedClusterProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateAttachedCluster()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/attached_clusters.update_attached_cluster.js + * region_tag:gkemulticloud_v1_generated_AttachedClusters_UpdateAttachedCluster_async + */ + async checkUpdateAttachedClusterProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.gkemulticloud.v1.AttachedCluster, + protos.google.cloud.gkemulticloud.v1.OperationMetadata + > + > { this._log.info('updateAttachedCluster long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.updateAttachedCluster, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateAttachedCluster, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.gkemulticloud.v1.AttachedCluster, + protos.google.cloud.gkemulticloud.v1.OperationMetadata + >; } -/** - * Imports creates a new - * {@link protos.google.cloud.gkemulticloud.v1.AttachedCluster|AttachedCluster} resource - * by importing an existing Fleet Membership resource. - * - * Attached Clusters created before the introduction of the Anthos Multi-Cloud - * API can be imported through this method. - * - * If successful, the response contains a newly created - * {@link protos.google.longrunning.Operation|Operation} resource that can be - * described to track the status of the operation. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent location where this - * {@link protos.google.cloud.gkemulticloud.v1.AttachedCluster|AttachedCluster} resource - * will be created. - * - * Location names are formatted as `projects//locations/`. - * - * See [Resource Names](https://cloud.google.com/apis/design/resource_names) - * for more details on Google Cloud resource names. - * @param {boolean} request.validateOnly - * If set, only validate the request, but do not actually import the cluster. - * @param {string} request.fleetMembership - * Required. The name of the fleet membership resource to import. - * @param {string} request.platformVersion - * Required. The platform version for the cluster (e.g. `1.19.0-gke.1000`). - * - * You can list all supported versions on a given Google Cloud region by - * calling - * {@link protos.google.cloud.gkemulticloud.v1.AttachedClusters.GetAttachedServerConfig|GetAttachedServerConfig}. - * @param {string} request.distribution - * Required. The Kubernetes distribution of the underlying attached cluster. - * - * Supported values: ["eks", "aks", "generic"]. - * @param {google.cloud.gkemulticloud.v1.AttachedProxyConfig} [request.proxyConfig] - * Optional. Proxy configuration for outbound HTTP(S) traffic. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/attached_clusters.import_attached_cluster.js - * region_tag:gkemulticloud_v1_generated_AttachedClusters_ImportAttachedCluster_async - */ + /** + * Imports creates a new + * {@link protos.google.cloud.gkemulticloud.v1.AttachedCluster|AttachedCluster} resource + * by importing an existing Fleet Membership resource. + * + * Attached Clusters created before the introduction of the Anthos Multi-Cloud + * API can be imported through this method. + * + * If successful, the response contains a newly created + * {@link protos.google.longrunning.Operation|Operation} resource that can be + * described to track the status of the operation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent location where this + * {@link protos.google.cloud.gkemulticloud.v1.AttachedCluster|AttachedCluster} resource + * will be created. + * + * Location names are formatted as `projects//locations/`. + * + * See [Resource Names](https://cloud.google.com/apis/design/resource_names) + * for more details on Google Cloud resource names. + * @param {boolean} request.validateOnly + * If set, only validate the request, but do not actually import the cluster. + * @param {string} request.fleetMembership + * Required. The name of the fleet membership resource to import. + * @param {string} request.platformVersion + * Required. The platform version for the cluster (e.g. `1.19.0-gke.1000`). + * + * You can list all supported versions on a given Google Cloud region by + * calling + * {@link protos.google.cloud.gkemulticloud.v1.AttachedClusters.GetAttachedServerConfig|GetAttachedServerConfig}. + * @param {string} request.distribution + * Required. The Kubernetes distribution of the underlying attached cluster. + * + * Supported values: ["eks", "aks", "generic"]. + * @param {google.cloud.gkemulticloud.v1.AttachedProxyConfig} [request.proxyConfig] + * Optional. Proxy configuration for outbound HTTP(S) traffic. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/attached_clusters.import_attached_cluster.js + * region_tag:gkemulticloud_v1_generated_AttachedClusters_ImportAttachedCluster_async + */ importAttachedCluster( - request?: protos.google.cloud.gkemulticloud.v1.IImportAttachedClusterRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkemulticloud.v1.IImportAttachedClusterRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.gkemulticloud.v1.IAttachedCluster, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; importAttachedCluster( - request: protos.google.cloud.gkemulticloud.v1.IImportAttachedClusterRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IImportAttachedClusterRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAttachedCluster, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; importAttachedCluster( - request: protos.google.cloud.gkemulticloud.v1.IImportAttachedClusterRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IImportAttachedClusterRequest, + callback: Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAttachedCluster, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; importAttachedCluster( - request?: protos.google.cloud.gkemulticloud.v1.IImportAttachedClusterRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.gkemulticloud.v1.IImportAttachedClusterRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAttachedCluster, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAttachedCluster, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.gkemulticloud.v1.IAttachedCluster, + protos.google.cloud.gkemulticloud.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.gkemulticloud.v1.IAttachedCluster, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('importAttachedCluster response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('importAttachedCluster request %j', request); - return this.innerApiCalls.importAttachedCluster(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('importAttachedCluster response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .importAttachedCluster(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.gkemulticloud.v1.IAttachedCluster, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('importAttachedCluster response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `importAttachedCluster()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/attached_clusters.import_attached_cluster.js - * region_tag:gkemulticloud_v1_generated_AttachedClusters_ImportAttachedCluster_async - */ - async checkImportAttachedClusterProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `importAttachedCluster()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/attached_clusters.import_attached_cluster.js + * region_tag:gkemulticloud_v1_generated_AttachedClusters_ImportAttachedCluster_async + */ + async checkImportAttachedClusterProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.gkemulticloud.v1.AttachedCluster, + protos.google.cloud.gkemulticloud.v1.OperationMetadata + > + > { this._log.info('importAttachedCluster long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.importAttachedCluster, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.importAttachedCluster, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.gkemulticloud.v1.AttachedCluster, + protos.google.cloud.gkemulticloud.v1.OperationMetadata + >; } -/** - * Deletes a specific - * {@link protos.google.cloud.gkemulticloud.v1.AttachedCluster|AttachedCluster} resource. - * - * If successful, the response contains a newly created - * {@link protos.google.longrunning.Operation|Operation} resource that can be - * described to track the status of the operation. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name the - * {@link protos.google.cloud.gkemulticloud.v1.AttachedCluster|AttachedCluster} to delete. - * - * `AttachedCluster` names are formatted as - * `projects//locations//attachedClusters/`. - * - * See [Resource Names](https://cloud.google.com/apis/design/resource_names) - * for more details on Google Cloud Platform resource names. - * @param {boolean} request.validateOnly - * If set, only validate the request, but do not actually delete the resource. - * @param {boolean} request.allowMissing - * If set to true, and the - * {@link protos.google.cloud.gkemulticloud.v1.AttachedCluster|AttachedCluster} resource - * is not found, the request will succeed but no action will be taken on the - * server and a completed {@link protos.google.longrunning.Operation|Operation} will be - * returned. - * - * Useful for idempotent deletion. - * @param {boolean} request.ignoreErrors - * If set to true, the deletion of - * {@link protos.google.cloud.gkemulticloud.v1.AttachedCluster|AttachedCluster} resource - * will succeed even if errors occur during deleting in cluster resources. - * Using this parameter may result in orphaned resources in the cluster. - * @param {string} request.etag - * The current etag of the - * {@link protos.google.cloud.gkemulticloud.v1.AttachedCluster|AttachedCluster}. - * - * Allows clients to perform deletions through optimistic concurrency control. - * - * If the provided etag does not match the current etag of the cluster, - * the request will fail and an ABORTED 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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/attached_clusters.delete_attached_cluster.js - * region_tag:gkemulticloud_v1_generated_AttachedClusters_DeleteAttachedCluster_async - */ + /** + * Deletes a specific + * {@link protos.google.cloud.gkemulticloud.v1.AttachedCluster|AttachedCluster} resource. + * + * If successful, the response contains a newly created + * {@link protos.google.longrunning.Operation|Operation} resource that can be + * described to track the status of the operation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name the + * {@link protos.google.cloud.gkemulticloud.v1.AttachedCluster|AttachedCluster} to delete. + * + * `AttachedCluster` names are formatted as + * `projects//locations//attachedClusters/`. + * + * See [Resource Names](https://cloud.google.com/apis/design/resource_names) + * for more details on Google Cloud Platform resource names. + * @param {boolean} request.validateOnly + * If set, only validate the request, but do not actually delete the resource. + * @param {boolean} request.allowMissing + * If set to true, and the + * {@link protos.google.cloud.gkemulticloud.v1.AttachedCluster|AttachedCluster} resource + * is not found, the request will succeed but no action will be taken on the + * server and a completed {@link protos.google.longrunning.Operation|Operation} will be + * returned. + * + * Useful for idempotent deletion. + * @param {boolean} request.ignoreErrors + * If set to true, the deletion of + * {@link protos.google.cloud.gkemulticloud.v1.AttachedCluster|AttachedCluster} resource + * will succeed even if errors occur during deleting in cluster resources. + * Using this parameter may result in orphaned resources in the cluster. + * @param {string} request.etag + * The current etag of the + * {@link protos.google.cloud.gkemulticloud.v1.AttachedCluster|AttachedCluster}. + * + * Allows clients to perform deletions through optimistic concurrency control. + * + * If the provided etag does not match the current etag of the cluster, + * the request will fail and an ABORTED 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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/attached_clusters.delete_attached_cluster.js + * region_tag:gkemulticloud_v1_generated_AttachedClusters_DeleteAttachedCluster_async + */ deleteAttachedCluster( - request?: protos.google.cloud.gkemulticloud.v1.IDeleteAttachedClusterRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkemulticloud.v1.IDeleteAttachedClusterRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteAttachedCluster( - request: protos.google.cloud.gkemulticloud.v1.IDeleteAttachedClusterRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IDeleteAttachedClusterRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteAttachedCluster( - request: protos.google.cloud.gkemulticloud.v1.IDeleteAttachedClusterRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IDeleteAttachedClusterRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteAttachedCluster( - request?: protos.google.cloud.gkemulticloud.v1.IDeleteAttachedClusterRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.gkemulticloud.v1.IDeleteAttachedClusterRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkemulticloud.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.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteAttachedCluster response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteAttachedCluster request %j', request); - return this.innerApiCalls.deleteAttachedCluster(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteAttachedCluster response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteAttachedCluster(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteAttachedCluster response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteAttachedCluster()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/attached_clusters.delete_attached_cluster.js - * region_tag:gkemulticloud_v1_generated_AttachedClusters_DeleteAttachedCluster_async - */ - async checkDeleteAttachedClusterProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteAttachedCluster()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/attached_clusters.delete_attached_cluster.js + * region_tag:gkemulticloud_v1_generated_AttachedClusters_DeleteAttachedCluster_async + */ + async checkDeleteAttachedClusterProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.gkemulticloud.v1.OperationMetadata + > + > { this._log.info('deleteAttachedCluster long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteAttachedCluster, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists all {@link protos.google.cloud.gkemulticloud.v1.AttachedCluster|AttachedCluster} - * resources on a given Google Cloud project and region. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent location which owns this collection of - * {@link protos.google.cloud.gkemulticloud.v1.AttachedCluster|AttachedCluster} resources. - * - * Location names are formatted as `projects//locations/`. - * - * See [Resource Names](https://cloud.google.com/apis/design/resource_names) - * for more details on Google Cloud Platform resource names. - * @param {number} request.pageSize - * The maximum number of items to return. - * - * If not specified, a default value of 50 will be used by the service. - * Regardless of the pageSize value, the response can include a partial list - * and a caller should only rely on response's - * {@link protos.google.cloud.gkemulticloud.v1.ListAttachedClustersResponse.next_page_token|nextPageToken} - * to determine if there are more instances left to be queried. - * @param {string} request.pageToken - * The `nextPageToken` value returned from a previous - * {@link protos.google.cloud.gkemulticloud.v1.AttachedClusters.ListAttachedClusters|attachedClusters.list} - * request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link protos.google.cloud.gkemulticloud.v1.AttachedCluster|AttachedCluster}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listAttachedClustersAsync()` - * method described below for async iteration which you can stop as 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.deleteAttachedCluster, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.gkemulticloud.v1.OperationMetadata + >; + } + /** + * Lists all {@link protos.google.cloud.gkemulticloud.v1.AttachedCluster|AttachedCluster} + * resources on a given Google Cloud project and region. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent location which owns this collection of + * {@link protos.google.cloud.gkemulticloud.v1.AttachedCluster|AttachedCluster} resources. + * + * Location names are formatted as `projects//locations/`. + * + * See [Resource Names](https://cloud.google.com/apis/design/resource_names) + * for more details on Google Cloud Platform resource names. + * @param {number} request.pageSize + * The maximum number of items to return. + * + * If not specified, a default value of 50 will be used by the service. + * Regardless of the pageSize value, the response can include a partial list + * and a caller should only rely on response's + * {@link protos.google.cloud.gkemulticloud.v1.ListAttachedClustersResponse.next_page_token|nextPageToken} + * to determine if there are more instances left to be queried. + * @param {string} request.pageToken + * The `nextPageToken` value returned from a previous + * {@link protos.google.cloud.gkemulticloud.v1.AttachedClusters.ListAttachedClusters|attachedClusters.list} + * request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.gkemulticloud.v1.AttachedCluster|AttachedCluster}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listAttachedClustersAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listAttachedClusters( - request?: protos.google.cloud.gkemulticloud.v1.IListAttachedClustersRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gkemulticloud.v1.IAttachedCluster[], - protos.google.cloud.gkemulticloud.v1.IListAttachedClustersRequest|null, - protos.google.cloud.gkemulticloud.v1.IListAttachedClustersResponse - ]>; + request?: protos.google.cloud.gkemulticloud.v1.IListAttachedClustersRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gkemulticloud.v1.IAttachedCluster[], + protos.google.cloud.gkemulticloud.v1.IListAttachedClustersRequest | null, + protos.google.cloud.gkemulticloud.v1.IListAttachedClustersResponse, + ] + >; listAttachedClusters( - request: protos.google.cloud.gkemulticloud.v1.IListAttachedClustersRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.gkemulticloud.v1.IListAttachedClustersRequest, - protos.google.cloud.gkemulticloud.v1.IListAttachedClustersResponse|null|undefined, - protos.google.cloud.gkemulticloud.v1.IAttachedCluster>): void; + request: protos.google.cloud.gkemulticloud.v1.IListAttachedClustersRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.gkemulticloud.v1.IListAttachedClustersRequest, + | protos.google.cloud.gkemulticloud.v1.IListAttachedClustersResponse + | null + | undefined, + protos.google.cloud.gkemulticloud.v1.IAttachedCluster + >, + ): void; listAttachedClusters( - request: protos.google.cloud.gkemulticloud.v1.IListAttachedClustersRequest, - callback: PaginationCallback< - protos.google.cloud.gkemulticloud.v1.IListAttachedClustersRequest, - protos.google.cloud.gkemulticloud.v1.IListAttachedClustersResponse|null|undefined, - protos.google.cloud.gkemulticloud.v1.IAttachedCluster>): void; + request: protos.google.cloud.gkemulticloud.v1.IListAttachedClustersRequest, + callback: PaginationCallback< + protos.google.cloud.gkemulticloud.v1.IListAttachedClustersRequest, + | protos.google.cloud.gkemulticloud.v1.IListAttachedClustersResponse + | null + | undefined, + protos.google.cloud.gkemulticloud.v1.IAttachedCluster + >, + ): void; listAttachedClusters( - request?: protos.google.cloud.gkemulticloud.v1.IListAttachedClustersRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.gkemulticloud.v1.IListAttachedClustersRequest, - protos.google.cloud.gkemulticloud.v1.IListAttachedClustersResponse|null|undefined, - protos.google.cloud.gkemulticloud.v1.IAttachedCluster>, - callback?: PaginationCallback< + request?: protos.google.cloud.gkemulticloud.v1.IListAttachedClustersRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.gkemulticloud.v1.IListAttachedClustersRequest, - protos.google.cloud.gkemulticloud.v1.IListAttachedClustersResponse|null|undefined, - protos.google.cloud.gkemulticloud.v1.IAttachedCluster>): - Promise<[ - protos.google.cloud.gkemulticloud.v1.IAttachedCluster[], - protos.google.cloud.gkemulticloud.v1.IListAttachedClustersRequest|null, - protos.google.cloud.gkemulticloud.v1.IListAttachedClustersResponse - ]>|void { + | protos.google.cloud.gkemulticloud.v1.IListAttachedClustersResponse + | null + | undefined, + protos.google.cloud.gkemulticloud.v1.IAttachedCluster + >, + callback?: PaginationCallback< + protos.google.cloud.gkemulticloud.v1.IListAttachedClustersRequest, + | protos.google.cloud.gkemulticloud.v1.IListAttachedClustersResponse + | null + | undefined, + protos.google.cloud.gkemulticloud.v1.IAttachedCluster + >, + ): Promise< + [ + protos.google.cloud.gkemulticloud.v1.IAttachedCluster[], + protos.google.cloud.gkemulticloud.v1.IListAttachedClustersRequest | null, + protos.google.cloud.gkemulticloud.v1.IListAttachedClustersResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-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.gkemulticloud.v1.IListAttachedClustersRequest, - protos.google.cloud.gkemulticloud.v1.IListAttachedClustersResponse|null|undefined, - protos.google.cloud.gkemulticloud.v1.IAttachedCluster>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.gkemulticloud.v1.IListAttachedClustersRequest, + | protos.google.cloud.gkemulticloud.v1.IListAttachedClustersResponse + | null + | undefined, + protos.google.cloud.gkemulticloud.v1.IAttachedCluster + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listAttachedClusters values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1508,137 +2099,141 @@ export class AttachedClustersClient { this._log.info('listAttachedClusters request %j', request); return this.innerApiCalls .listAttachedClusters(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.gkemulticloud.v1.IAttachedCluster[], - protos.google.cloud.gkemulticloud.v1.IListAttachedClustersRequest|null, - protos.google.cloud.gkemulticloud.v1.IListAttachedClustersResponse - ]) => { - this._log.info('listAttachedClusters values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.gkemulticloud.v1.IAttachedCluster[], + protos.google.cloud.gkemulticloud.v1.IListAttachedClustersRequest | null, + protos.google.cloud.gkemulticloud.v1.IListAttachedClustersResponse, + ]) => { + this._log.info('listAttachedClusters values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listAttachedClusters`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent location which owns this collection of - * {@link protos.google.cloud.gkemulticloud.v1.AttachedCluster|AttachedCluster} resources. - * - * Location names are formatted as `projects//locations/`. - * - * See [Resource Names](https://cloud.google.com/apis/design/resource_names) - * for more details on Google Cloud Platform resource names. - * @param {number} request.pageSize - * The maximum number of items to return. - * - * If not specified, a default value of 50 will be used by the service. - * Regardless of the pageSize value, the response can include a partial list - * and a caller should only rely on response's - * {@link protos.google.cloud.gkemulticloud.v1.ListAttachedClustersResponse.next_page_token|nextPageToken} - * to determine if there are more instances left to be queried. - * @param {string} request.pageToken - * The `nextPageToken` value returned from a previous - * {@link protos.google.cloud.gkemulticloud.v1.AttachedClusters.ListAttachedClusters|attachedClusters.list} - * request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.gkemulticloud.v1.AttachedCluster|AttachedCluster} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listAttachedClustersAsync()` - * method described below for async iteration which you can stop as 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 `listAttachedClusters`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent location which owns this collection of + * {@link protos.google.cloud.gkemulticloud.v1.AttachedCluster|AttachedCluster} resources. + * + * Location names are formatted as `projects//locations/`. + * + * See [Resource Names](https://cloud.google.com/apis/design/resource_names) + * for more details on Google Cloud Platform resource names. + * @param {number} request.pageSize + * The maximum number of items to return. + * + * If not specified, a default value of 50 will be used by the service. + * Regardless of the pageSize value, the response can include a partial list + * and a caller should only rely on response's + * {@link protos.google.cloud.gkemulticloud.v1.ListAttachedClustersResponse.next_page_token|nextPageToken} + * to determine if there are more instances left to be queried. + * @param {string} request.pageToken + * The `nextPageToken` value returned from a previous + * {@link protos.google.cloud.gkemulticloud.v1.AttachedClusters.ListAttachedClusters|attachedClusters.list} + * request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.gkemulticloud.v1.AttachedCluster|AttachedCluster} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listAttachedClustersAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listAttachedClustersStream( - request?: protos.google.cloud.gkemulticloud.v1.IListAttachedClustersRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.gkemulticloud.v1.IListAttachedClustersRequest, + 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['listAttachedClusters']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listAttachedClusters stream %j', request); return this.descriptors.page.listAttachedClusters.createStream( this.innerApiCalls.listAttachedClusters as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listAttachedClusters`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used 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 location which owns this collection of - * {@link protos.google.cloud.gkemulticloud.v1.AttachedCluster|AttachedCluster} resources. - * - * Location names are formatted as `projects//locations/`. - * - * See [Resource Names](https://cloud.google.com/apis/design/resource_names) - * for more details on Google Cloud Platform resource names. - * @param {number} request.pageSize - * The maximum number of items to return. - * - * If not specified, a default value of 50 will be used by the service. - * Regardless of the pageSize value, the response can include a partial list - * and a caller should only rely on response's - * {@link protos.google.cloud.gkemulticloud.v1.ListAttachedClustersResponse.next_page_token|nextPageToken} - * to determine if there are more instances left to be queried. - * @param {string} request.pageToken - * The `nextPageToken` value returned from a previous - * {@link protos.google.cloud.gkemulticloud.v1.AttachedClusters.ListAttachedClusters|attachedClusters.list} - * request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.gkemulticloud.v1.AttachedCluster|AttachedCluster}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@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/attached_clusters.list_attached_clusters.js - * region_tag:gkemulticloud_v1_generated_AttachedClusters_ListAttachedClusters_async - */ + /** + * Equivalent to `listAttachedClusters`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used 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 location which owns this collection of + * {@link protos.google.cloud.gkemulticloud.v1.AttachedCluster|AttachedCluster} resources. + * + * Location names are formatted as `projects//locations/`. + * + * See [Resource Names](https://cloud.google.com/apis/design/resource_names) + * for more details on Google Cloud Platform resource names. + * @param {number} request.pageSize + * The maximum number of items to return. + * + * If not specified, a default value of 50 will be used by the service. + * Regardless of the pageSize value, the response can include a partial list + * and a caller should only rely on response's + * {@link protos.google.cloud.gkemulticloud.v1.ListAttachedClustersResponse.next_page_token|nextPageToken} + * to determine if there are more instances left to be queried. + * @param {string} request.pageToken + * The `nextPageToken` value returned from a previous + * {@link protos.google.cloud.gkemulticloud.v1.AttachedClusters.ListAttachedClusters|attachedClusters.list} + * request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.gkemulticloud.v1.AttachedCluster|AttachedCluster}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@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/attached_clusters.list_attached_clusters.js + * region_tag:gkemulticloud_v1_generated_AttachedClusters_ListAttachedClusters_async + */ listAttachedClustersAsync( - request?: protos.google.cloud.gkemulticloud.v1.IListAttachedClustersRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.gkemulticloud.v1.IListAttachedClustersRequest, + 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['listAttachedClusters']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listAttachedClusters iterate %j', request); return this.descriptors.page.listAttachedClusters.asyncIterate( this.innerApiCalls['listAttachedClusters'] 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. @@ -1681,22 +2276,22 @@ export class AttachedClustersClient { 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); } /** @@ -1731,15 +2326,15 @@ export class AttachedClustersClient { */ 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); } /** @@ -1773,7 +2368,7 @@ export class AttachedClustersClient { * await client.cancelOperation({name: ''}); * ``` */ - cancelOperation( + cancelOperation( request: protos.google.longrunning.CancelOperationRequest, optionsOrCallback?: | gax.CallOptions @@ -1786,25 +2381,24 @@ export class AttachedClustersClient { 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 @@ -1843,22 +2437,22 @@ export class AttachedClustersClient { 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); } @@ -1874,7 +2468,11 @@ export class AttachedClustersClient { * @param {string} attached_cluster * @returns {string} Resource name string. */ - attachedClusterPath(project:string,location:string,attachedCluster:string) { + attachedClusterPath( + project: string, + location: string, + attachedCluster: string, + ) { return this.pathTemplates.attachedClusterPathTemplate.render({ project: project, location: location, @@ -1890,7 +2488,9 @@ export class AttachedClustersClient { * @returns {string} A string representing the project. */ matchProjectFromAttachedClusterName(attachedClusterName: string) { - return this.pathTemplates.attachedClusterPathTemplate.match(attachedClusterName).project; + return this.pathTemplates.attachedClusterPathTemplate.match( + attachedClusterName, + ).project; } /** @@ -1901,7 +2501,9 @@ export class AttachedClustersClient { * @returns {string} A string representing the location. */ matchLocationFromAttachedClusterName(attachedClusterName: string) { - return this.pathTemplates.attachedClusterPathTemplate.match(attachedClusterName).location; + return this.pathTemplates.attachedClusterPathTemplate.match( + attachedClusterName, + ).location; } /** @@ -1912,7 +2514,9 @@ export class AttachedClustersClient { * @returns {string} A string representing the attached_cluster. */ matchAttachedClusterFromAttachedClusterName(attachedClusterName: string) { - return this.pathTemplates.attachedClusterPathTemplate.match(attachedClusterName).attached_cluster; + return this.pathTemplates.attachedClusterPathTemplate.match( + attachedClusterName, + ).attached_cluster; } /** @@ -1922,7 +2526,7 @@ export class AttachedClustersClient { * @param {string} location * @returns {string} Resource name string. */ - attachedServerConfigPath(project:string,location:string) { + attachedServerConfigPath(project: string, location: string) { return this.pathTemplates.attachedServerConfigPathTemplate.render({ project: project, location: location, @@ -1937,7 +2541,9 @@ export class AttachedClustersClient { * @returns {string} A string representing the project. */ matchProjectFromAttachedServerConfigName(attachedServerConfigName: string) { - return this.pathTemplates.attachedServerConfigPathTemplate.match(attachedServerConfigName).project; + return this.pathTemplates.attachedServerConfigPathTemplate.match( + attachedServerConfigName, + ).project; } /** @@ -1948,7 +2554,9 @@ export class AttachedClustersClient { * @returns {string} A string representing the location. */ matchLocationFromAttachedServerConfigName(attachedServerConfigName: string) { - return this.pathTemplates.attachedServerConfigPathTemplate.match(attachedServerConfigName).location; + return this.pathTemplates.attachedServerConfigPathTemplate.match( + attachedServerConfigName, + ).location; } /** @@ -1959,7 +2567,7 @@ export class AttachedClustersClient { * @param {string} aws_cluster * @returns {string} Resource name string. */ - awsClusterPath(project:string,location:string,awsCluster:string) { + awsClusterPath(project: string, location: string, awsCluster: string) { return this.pathTemplates.awsClusterPathTemplate.render({ project: project, location: location, @@ -1975,7 +2583,8 @@ export class AttachedClustersClient { * @returns {string} A string representing the project. */ matchProjectFromAwsClusterName(awsClusterName: string) { - return this.pathTemplates.awsClusterPathTemplate.match(awsClusterName).project; + return this.pathTemplates.awsClusterPathTemplate.match(awsClusterName) + .project; } /** @@ -1986,7 +2595,8 @@ export class AttachedClustersClient { * @returns {string} A string representing the location. */ matchLocationFromAwsClusterName(awsClusterName: string) { - return this.pathTemplates.awsClusterPathTemplate.match(awsClusterName).location; + return this.pathTemplates.awsClusterPathTemplate.match(awsClusterName) + .location; } /** @@ -1997,7 +2607,8 @@ export class AttachedClustersClient { * @returns {string} A string representing the aws_cluster. */ matchAwsClusterFromAwsClusterName(awsClusterName: string) { - return this.pathTemplates.awsClusterPathTemplate.match(awsClusterName).aws_cluster; + return this.pathTemplates.awsClusterPathTemplate.match(awsClusterName) + .aws_cluster; } /** @@ -2009,7 +2620,12 @@ export class AttachedClustersClient { * @param {string} aws_node_pool * @returns {string} Resource name string. */ - awsNodePoolPath(project:string,location:string,awsCluster:string,awsNodePool:string) { + awsNodePoolPath( + project: string, + location: string, + awsCluster: string, + awsNodePool: string, + ) { return this.pathTemplates.awsNodePoolPathTemplate.render({ project: project, location: location, @@ -2026,7 +2642,8 @@ export class AttachedClustersClient { * @returns {string} A string representing the project. */ matchProjectFromAwsNodePoolName(awsNodePoolName: string) { - return this.pathTemplates.awsNodePoolPathTemplate.match(awsNodePoolName).project; + return this.pathTemplates.awsNodePoolPathTemplate.match(awsNodePoolName) + .project; } /** @@ -2037,7 +2654,8 @@ export class AttachedClustersClient { * @returns {string} A string representing the location. */ matchLocationFromAwsNodePoolName(awsNodePoolName: string) { - return this.pathTemplates.awsNodePoolPathTemplate.match(awsNodePoolName).location; + return this.pathTemplates.awsNodePoolPathTemplate.match(awsNodePoolName) + .location; } /** @@ -2048,7 +2666,8 @@ export class AttachedClustersClient { * @returns {string} A string representing the aws_cluster. */ matchAwsClusterFromAwsNodePoolName(awsNodePoolName: string) { - return this.pathTemplates.awsNodePoolPathTemplate.match(awsNodePoolName).aws_cluster; + return this.pathTemplates.awsNodePoolPathTemplate.match(awsNodePoolName) + .aws_cluster; } /** @@ -2059,7 +2678,8 @@ export class AttachedClustersClient { * @returns {string} A string representing the aws_node_pool. */ matchAwsNodePoolFromAwsNodePoolName(awsNodePoolName: string) { - return this.pathTemplates.awsNodePoolPathTemplate.match(awsNodePoolName).aws_node_pool; + return this.pathTemplates.awsNodePoolPathTemplate.match(awsNodePoolName) + .aws_node_pool; } /** @@ -2069,7 +2689,7 @@ export class AttachedClustersClient { * @param {string} location * @returns {string} Resource name string. */ - awsServerConfigPath(project:string,location:string) { + awsServerConfigPath(project: string, location: string) { return this.pathTemplates.awsServerConfigPathTemplate.render({ project: project, location: location, @@ -2084,7 +2704,9 @@ export class AttachedClustersClient { * @returns {string} A string representing the project. */ matchProjectFromAwsServerConfigName(awsServerConfigName: string) { - return this.pathTemplates.awsServerConfigPathTemplate.match(awsServerConfigName).project; + return this.pathTemplates.awsServerConfigPathTemplate.match( + awsServerConfigName, + ).project; } /** @@ -2095,7 +2717,9 @@ export class AttachedClustersClient { * @returns {string} A string representing the location. */ matchLocationFromAwsServerConfigName(awsServerConfigName: string) { - return this.pathTemplates.awsServerConfigPathTemplate.match(awsServerConfigName).location; + return this.pathTemplates.awsServerConfigPathTemplate.match( + awsServerConfigName, + ).location; } /** @@ -2106,7 +2730,7 @@ export class AttachedClustersClient { * @param {string} azure_client * @returns {string} Resource name string. */ - azureClientPath(project:string,location:string,azureClient:string) { + azureClientPath(project: string, location: string, azureClient: string) { return this.pathTemplates.azureClientPathTemplate.render({ project: project, location: location, @@ -2122,7 +2746,8 @@ export class AttachedClustersClient { * @returns {string} A string representing the project. */ matchProjectFromAzureClientName(azureClientName: string) { - return this.pathTemplates.azureClientPathTemplate.match(azureClientName).project; + return this.pathTemplates.azureClientPathTemplate.match(azureClientName) + .project; } /** @@ -2133,7 +2758,8 @@ export class AttachedClustersClient { * @returns {string} A string representing the location. */ matchLocationFromAzureClientName(azureClientName: string) { - return this.pathTemplates.azureClientPathTemplate.match(azureClientName).location; + return this.pathTemplates.azureClientPathTemplate.match(azureClientName) + .location; } /** @@ -2144,7 +2770,8 @@ export class AttachedClustersClient { * @returns {string} A string representing the azure_client. */ matchAzureClientFromAzureClientName(azureClientName: string) { - return this.pathTemplates.azureClientPathTemplate.match(azureClientName).azure_client; + return this.pathTemplates.azureClientPathTemplate.match(azureClientName) + .azure_client; } /** @@ -2155,7 +2782,7 @@ export class AttachedClustersClient { * @param {string} azure_cluster * @returns {string} Resource name string. */ - azureClusterPath(project:string,location:string,azureCluster:string) { + azureClusterPath(project: string, location: string, azureCluster: string) { return this.pathTemplates.azureClusterPathTemplate.render({ project: project, location: location, @@ -2171,7 +2798,8 @@ export class AttachedClustersClient { * @returns {string} A string representing the project. */ matchProjectFromAzureClusterName(azureClusterName: string) { - return this.pathTemplates.azureClusterPathTemplate.match(azureClusterName).project; + return this.pathTemplates.azureClusterPathTemplate.match(azureClusterName) + .project; } /** @@ -2182,7 +2810,8 @@ export class AttachedClustersClient { * @returns {string} A string representing the location. */ matchLocationFromAzureClusterName(azureClusterName: string) { - return this.pathTemplates.azureClusterPathTemplate.match(azureClusterName).location; + return this.pathTemplates.azureClusterPathTemplate.match(azureClusterName) + .location; } /** @@ -2193,7 +2822,8 @@ export class AttachedClustersClient { * @returns {string} A string representing the azure_cluster. */ matchAzureClusterFromAzureClusterName(azureClusterName: string) { - return this.pathTemplates.azureClusterPathTemplate.match(azureClusterName).azure_cluster; + return this.pathTemplates.azureClusterPathTemplate.match(azureClusterName) + .azure_cluster; } /** @@ -2205,7 +2835,12 @@ export class AttachedClustersClient { * @param {string} azure_node_pool * @returns {string} Resource name string. */ - azureNodePoolPath(project:string,location:string,azureCluster:string,azureNodePool:string) { + azureNodePoolPath( + project: string, + location: string, + azureCluster: string, + azureNodePool: string, + ) { return this.pathTemplates.azureNodePoolPathTemplate.render({ project: project, location: location, @@ -2222,7 +2857,8 @@ export class AttachedClustersClient { * @returns {string} A string representing the project. */ matchProjectFromAzureNodePoolName(azureNodePoolName: string) { - return this.pathTemplates.azureNodePoolPathTemplate.match(azureNodePoolName).project; + return this.pathTemplates.azureNodePoolPathTemplate.match(azureNodePoolName) + .project; } /** @@ -2233,7 +2869,8 @@ export class AttachedClustersClient { * @returns {string} A string representing the location. */ matchLocationFromAzureNodePoolName(azureNodePoolName: string) { - return this.pathTemplates.azureNodePoolPathTemplate.match(azureNodePoolName).location; + return this.pathTemplates.azureNodePoolPathTemplate.match(azureNodePoolName) + .location; } /** @@ -2244,7 +2881,8 @@ export class AttachedClustersClient { * @returns {string} A string representing the azure_cluster. */ matchAzureClusterFromAzureNodePoolName(azureNodePoolName: string) { - return this.pathTemplates.azureNodePoolPathTemplate.match(azureNodePoolName).azure_cluster; + return this.pathTemplates.azureNodePoolPathTemplate.match(azureNodePoolName) + .azure_cluster; } /** @@ -2255,7 +2893,8 @@ export class AttachedClustersClient { * @returns {string} A string representing the azure_node_pool. */ matchAzureNodePoolFromAzureNodePoolName(azureNodePoolName: string) { - return this.pathTemplates.azureNodePoolPathTemplate.match(azureNodePoolName).azure_node_pool; + return this.pathTemplates.azureNodePoolPathTemplate.match(azureNodePoolName) + .azure_node_pool; } /** @@ -2265,7 +2904,7 @@ export class AttachedClustersClient { * @param {string} location * @returns {string} Resource name string. */ - azureServerConfigPath(project:string,location:string) { + azureServerConfigPath(project: string, location: string) { return this.pathTemplates.azureServerConfigPathTemplate.render({ project: project, location: location, @@ -2280,7 +2919,9 @@ export class AttachedClustersClient { * @returns {string} A string representing the project. */ matchProjectFromAzureServerConfigName(azureServerConfigName: string) { - return this.pathTemplates.azureServerConfigPathTemplate.match(azureServerConfigName).project; + return this.pathTemplates.azureServerConfigPathTemplate.match( + azureServerConfigName, + ).project; } /** @@ -2291,7 +2932,9 @@ export class AttachedClustersClient { * @returns {string} A string representing the location. */ matchLocationFromAzureServerConfigName(azureServerConfigName: string) { - return this.pathTemplates.azureServerConfigPathTemplate.match(azureServerConfigName).location; + return this.pathTemplates.azureServerConfigPathTemplate.match( + azureServerConfigName, + ).location; } /** @@ -2301,7 +2944,7 @@ export class AttachedClustersClient { * @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, @@ -2336,7 +2979,7 @@ export class AttachedClustersClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -2361,7 +3004,7 @@ export class AttachedClustersClient { */ close(): Promise { if (this.attachedClustersStub && !this._terminated) { - return this.attachedClustersStub.then(stub => { + return this.attachedClustersStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); @@ -2370,4 +3013,4 @@ export class AttachedClustersClient { } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-gkemulticloud/src/v1/aws_clusters_client.ts b/packages/google-cloud-gkemulticloud/src/v1/aws_clusters_client.ts index 715599ee4a6a..03c427383b6f 100644 --- a/packages/google-cloud-gkemulticloud/src/v1/aws_clusters_client.ts +++ b/packages/google-cloud-gkemulticloud/src/v1/aws_clusters_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 @@ -46,7 +55,7 @@ export class AwsClustersClient { 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('gkemulticloud'); @@ -59,10 +68,10 @@ export class AwsClustersClient { 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; - awsClustersStub?: Promise<{[name: string]: Function}>; + awsClustersStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of AwsClustersClient. @@ -103,21 +112,42 @@ export class AwsClustersClient { * const client = new AwsClustersClient({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 AwsClustersClient; - 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 = 'gkemulticloud.' + 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); // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. if (servicePath !== this._servicePath && !('scopes' in opts)) { @@ -139,7 +169,7 @@ export class AwsClustersClient { 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 +183,7 @@ export class AwsClustersClient { } // 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,37 +205,37 @@ export class AwsClustersClient { // Create useful helper objects for these. this.pathTemplates = { attachedClusterPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/attachedClusters/{attached_cluster}' + 'projects/{project}/locations/{location}/attachedClusters/{attached_cluster}', ), attachedServerConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/attachedServerConfig' + 'projects/{project}/locations/{location}/attachedServerConfig', ), awsClusterPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/awsClusters/{aws_cluster}' + 'projects/{project}/locations/{location}/awsClusters/{aws_cluster}', ), awsNodePoolPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/awsClusters/{aws_cluster}/awsNodePools/{aws_node_pool}' + 'projects/{project}/locations/{location}/awsClusters/{aws_cluster}/awsNodePools/{aws_node_pool}', ), awsServerConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/awsServerConfig' + 'projects/{project}/locations/{location}/awsServerConfig', ), azureClientPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/azureClients/{azure_client}' + 'projects/{project}/locations/{location}/azureClients/{azure_client}', ), azureClusterPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/azureClusters/{azure_cluster}' + 'projects/{project}/locations/{location}/azureClusters/{azure_cluster}', ), azureNodePoolPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/azureClusters/{azure_cluster}/azureNodePools/{azure_node_pool}' + 'projects/{project}/locations/{location}/azureClusters/{azure_cluster}/azureNodePools/{azure_node_pool}', ), azureServerConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/azureServerConfig' + 'projects/{project}/locations/{location}/azureServerConfig', ), locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' + 'projects/{project}/locations/{location}', ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' + 'projects/{project}', ), }; @@ -216,10 +243,16 @@ export class AwsClustersClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listAwsClusters: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'awsClusters'), - listAwsNodePools: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'awsNodePools') + listAwsClusters: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'awsClusters', + ), + listAwsNodePools: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'awsNodePools', + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -228,77 +261,125 @@ export class AwsClustersClient { // 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.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.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 createAwsClusterResponse = protoFilesRoot.lookup( - '.google.cloud.gkemulticloud.v1.AwsCluster') as gax.protobuf.Type; + '.google.cloud.gkemulticloud.v1.AwsCluster', + ) as gax.protobuf.Type; const createAwsClusterMetadata = protoFilesRoot.lookup( - '.google.cloud.gkemulticloud.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.gkemulticloud.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateAwsClusterResponse = protoFilesRoot.lookup( - '.google.cloud.gkemulticloud.v1.AwsCluster') as gax.protobuf.Type; + '.google.cloud.gkemulticloud.v1.AwsCluster', + ) as gax.protobuf.Type; const updateAwsClusterMetadata = protoFilesRoot.lookup( - '.google.cloud.gkemulticloud.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.gkemulticloud.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteAwsClusterResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteAwsClusterMetadata = protoFilesRoot.lookup( - '.google.cloud.gkemulticloud.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.gkemulticloud.v1.OperationMetadata', + ) as gax.protobuf.Type; const createAwsNodePoolResponse = protoFilesRoot.lookup( - '.google.cloud.gkemulticloud.v1.AwsNodePool') as gax.protobuf.Type; + '.google.cloud.gkemulticloud.v1.AwsNodePool', + ) as gax.protobuf.Type; const createAwsNodePoolMetadata = protoFilesRoot.lookup( - '.google.cloud.gkemulticloud.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.gkemulticloud.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateAwsNodePoolResponse = protoFilesRoot.lookup( - '.google.cloud.gkemulticloud.v1.AwsNodePool') as gax.protobuf.Type; + '.google.cloud.gkemulticloud.v1.AwsNodePool', + ) as gax.protobuf.Type; const updateAwsNodePoolMetadata = protoFilesRoot.lookup( - '.google.cloud.gkemulticloud.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.gkemulticloud.v1.OperationMetadata', + ) as gax.protobuf.Type; const rollbackAwsNodePoolUpdateResponse = protoFilesRoot.lookup( - '.google.cloud.gkemulticloud.v1.AwsNodePool') as gax.protobuf.Type; + '.google.cloud.gkemulticloud.v1.AwsNodePool', + ) as gax.protobuf.Type; const rollbackAwsNodePoolUpdateMetadata = protoFilesRoot.lookup( - '.google.cloud.gkemulticloud.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.gkemulticloud.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteAwsNodePoolResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteAwsNodePoolMetadata = protoFilesRoot.lookup( - '.google.cloud.gkemulticloud.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.gkemulticloud.v1.OperationMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { createAwsCluster: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createAwsClusterResponse.decode.bind(createAwsClusterResponse), - createAwsClusterMetadata.decode.bind(createAwsClusterMetadata)), + createAwsClusterMetadata.decode.bind(createAwsClusterMetadata), + ), updateAwsCluster: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateAwsClusterResponse.decode.bind(updateAwsClusterResponse), - updateAwsClusterMetadata.decode.bind(updateAwsClusterMetadata)), + updateAwsClusterMetadata.decode.bind(updateAwsClusterMetadata), + ), deleteAwsCluster: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteAwsClusterResponse.decode.bind(deleteAwsClusterResponse), - deleteAwsClusterMetadata.decode.bind(deleteAwsClusterMetadata)), + deleteAwsClusterMetadata.decode.bind(deleteAwsClusterMetadata), + ), createAwsNodePool: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createAwsNodePoolResponse.decode.bind(createAwsNodePoolResponse), - createAwsNodePoolMetadata.decode.bind(createAwsNodePoolMetadata)), + createAwsNodePoolMetadata.decode.bind(createAwsNodePoolMetadata), + ), updateAwsNodePool: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateAwsNodePoolResponse.decode.bind(updateAwsNodePoolResponse), - updateAwsNodePoolMetadata.decode.bind(updateAwsNodePoolMetadata)), + updateAwsNodePoolMetadata.decode.bind(updateAwsNodePoolMetadata), + ), rollbackAwsNodePoolUpdate: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - rollbackAwsNodePoolUpdateResponse.decode.bind(rollbackAwsNodePoolUpdateResponse), - rollbackAwsNodePoolUpdateMetadata.decode.bind(rollbackAwsNodePoolUpdateMetadata)), + rollbackAwsNodePoolUpdateResponse.decode.bind( + rollbackAwsNodePoolUpdateResponse, + ), + rollbackAwsNodePoolUpdateMetadata.decode.bind( + rollbackAwsNodePoolUpdateMetadata, + ), + ), deleteAwsNodePool: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteAwsNodePoolResponse.decode.bind(deleteAwsNodePoolResponse), - deleteAwsNodePoolMetadata.decode.bind(deleteAwsNodePoolMetadata)) + deleteAwsNodePoolMetadata.decode.bind(deleteAwsNodePoolMetadata), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.gkemulticloud.v1.AwsClusters', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.gkemulticloud.v1.AwsClusters', + 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 @@ -323,35 +404,61 @@ export class AwsClustersClient { initialize() { // If the client stub promise is already initialized, return immediately. if (this.awsClustersStub) { - this.warn('DEP$AwsClusters', 'AwsClusters is deprecated and may be removed in a future version.', 'DeprecationWarning'); + this.warn( + 'DEP$AwsClusters', + 'AwsClusters is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); return this.awsClustersStub; } // Put together the "service stub" for // google.cloud.gkemulticloud.v1.AwsClusters. this.awsClustersStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.gkemulticloud.v1.AwsClusters') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.gkemulticloud.v1.AwsClusters', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.gkemulticloud.v1.AwsClusters, - 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 awsClustersStubMethods = - ['createAwsCluster', 'updateAwsCluster', 'getAwsCluster', 'listAwsClusters', 'deleteAwsCluster', 'generateAwsClusterAgentToken', 'generateAwsAccessToken', 'createAwsNodePool', 'updateAwsNodePool', 'rollbackAwsNodePoolUpdate', 'getAwsNodePool', 'listAwsNodePools', 'deleteAwsNodePool', 'getAwsOpenIdConfig', 'getAwsJsonWebKeys', 'getAwsServerConfig']; + const awsClustersStubMethods = [ + 'createAwsCluster', + 'updateAwsCluster', + 'getAwsCluster', + 'listAwsClusters', + 'deleteAwsCluster', + 'generateAwsClusterAgentToken', + 'generateAwsAccessToken', + 'createAwsNodePool', + 'updateAwsNodePool', + 'rollbackAwsNodePoolUpdate', + 'getAwsNodePool', + 'listAwsNodePools', + 'deleteAwsNodePool', + 'getAwsOpenIdConfig', + 'getAwsJsonWebKeys', + 'getAwsServerConfig', + ]; for (const methodName of awsClustersStubMethods) { const callPromise = this.awsClustersStub.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] || @@ -361,12 +468,16 @@ export class AwsClustersClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; } - this.warn('DEP$AwsClusters', 'AwsClusters is deprecated and may be removed in a future version.', 'DeprecationWarning'); + this.warn( + 'DEP$AwsClusters', + 'AwsClusters is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); return this.awsClustersStub; } @@ -377,8 +488,14 @@ export class AwsClustersClient { * @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 'gkemulticloud.googleapis.com'; } @@ -389,8 +506,14 @@ export class AwsClustersClient { * @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 'gkemulticloud.googleapis.com'; } @@ -421,9 +544,7 @@ export class AwsClustersClient { * @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; @@ -432,8 +553,9 @@ export class AwsClustersClient { * 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; @@ -444,1833 +566,2711 @@ export class AwsClustersClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Describes a specific {@link protos.google.cloud.gkemulticloud.v1.AwsCluster|AwsCluster} - * resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the - * {@link protos.google.cloud.gkemulticloud.v1.AwsCluster|AwsCluster} resource to - * describe. - * - * `AwsCluster` names are formatted as - * `projects//locations//awsClusters/`. - * - * See [Resource Names](https://cloud.google.com/apis/design/resource_names) - * for more details on Google Cloud Platform resource names. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.gkemulticloud.v1.AwsCluster|AwsCluster}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/aws_clusters.get_aws_cluster.js - * region_tag:gkemulticloud_v1_generated_AwsClusters_GetAwsCluster_async - * @deprecated GetAwsCluster is deprecated and may be removed in a future version. - */ + /** + * Describes a specific {@link protos.google.cloud.gkemulticloud.v1.AwsCluster|AwsCluster} + * resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the + * {@link protos.google.cloud.gkemulticloud.v1.AwsCluster|AwsCluster} resource to + * describe. + * + * `AwsCluster` names are formatted as + * `projects//locations//awsClusters/`. + * + * See [Resource Names](https://cloud.google.com/apis/design/resource_names) + * for more details on Google Cloud Platform resource names. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.gkemulticloud.v1.AwsCluster|AwsCluster}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/aws_clusters.get_aws_cluster.js + * region_tag:gkemulticloud_v1_generated_AwsClusters_GetAwsCluster_async + * @deprecated GetAwsCluster is deprecated and may be removed in a future version. + */ getAwsCluster( - request?: protos.google.cloud.gkemulticloud.v1.IGetAwsClusterRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gkemulticloud.v1.IAwsCluster, - protos.google.cloud.gkemulticloud.v1.IGetAwsClusterRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkemulticloud.v1.IGetAwsClusterRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gkemulticloud.v1.IAwsCluster, + protos.google.cloud.gkemulticloud.v1.IGetAwsClusterRequest | undefined, + {} | undefined, + ] + >; getAwsCluster( - request: protos.google.cloud.gkemulticloud.v1.IGetAwsClusterRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.gkemulticloud.v1.IAwsCluster, - protos.google.cloud.gkemulticloud.v1.IGetAwsClusterRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IGetAwsClusterRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.gkemulticloud.v1.IAwsCluster, + | protos.google.cloud.gkemulticloud.v1.IGetAwsClusterRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getAwsCluster( - request: protos.google.cloud.gkemulticloud.v1.IGetAwsClusterRequest, - callback: Callback< - protos.google.cloud.gkemulticloud.v1.IAwsCluster, - protos.google.cloud.gkemulticloud.v1.IGetAwsClusterRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IGetAwsClusterRequest, + callback: Callback< + protos.google.cloud.gkemulticloud.v1.IAwsCluster, + | protos.google.cloud.gkemulticloud.v1.IGetAwsClusterRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getAwsCluster( - request?: protos.google.cloud.gkemulticloud.v1.IGetAwsClusterRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.gkemulticloud.v1.IAwsCluster, - protos.google.cloud.gkemulticloud.v1.IGetAwsClusterRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.gkemulticloud.v1.IGetAwsClusterRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.gkemulticloud.v1.IAwsCluster, - protos.google.cloud.gkemulticloud.v1.IGetAwsClusterRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.gkemulticloud.v1.IAwsCluster, - protos.google.cloud.gkemulticloud.v1.IGetAwsClusterRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.gkemulticloud.v1.IGetAwsClusterRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.gkemulticloud.v1.IAwsCluster, + | protos.google.cloud.gkemulticloud.v1.IGetAwsClusterRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.gkemulticloud.v1.IAwsCluster, + protos.google.cloud.gkemulticloud.v1.IGetAwsClusterRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - this.warn('DEP$AwsClusters-$GetAwsCluster','GetAwsCluster is deprecated and may be removed in a future version.', 'DeprecationWarning'); + this.warn( + 'DEP$AwsClusters-$GetAwsCluster', + 'GetAwsCluster is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); this._log.info('getAwsCluster request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.gkemulticloud.v1.IAwsCluster, - protos.google.cloud.gkemulticloud.v1.IGetAwsClusterRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.gkemulticloud.v1.IAwsCluster, + | protos.google.cloud.gkemulticloud.v1.IGetAwsClusterRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getAwsCluster response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getAwsCluster(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.gkemulticloud.v1.IAwsCluster, - protos.google.cloud.gkemulticloud.v1.IGetAwsClusterRequest|undefined, - {}|undefined - ]) => { - this._log.info('getAwsCluster response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getAwsCluster(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.gkemulticloud.v1.IAwsCluster, + ( + | protos.google.cloud.gkemulticloud.v1.IGetAwsClusterRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getAwsCluster response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 an access token for a cluster agent. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.awsCluster - * Required. - * @param {string} request.subjectToken - * Required. - * @param {string} request.subjectTokenType - * Required. - * @param {string} request.version - * Required. - * @param {string} [request.nodePoolId] - * Optional. - * @param {string} [request.grantType] - * Optional. - * @param {string} [request.audience] - * Optional. - * @param {string} [request.scope] - * Optional. - * @param {string} [request.requestedTokenType] - * Optional. - * @param {string} [request.options] - * Optional. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.gkemulticloud.v1.GenerateAwsClusterAgentTokenResponse|GenerateAwsClusterAgentTokenResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/aws_clusters.generate_aws_cluster_agent_token.js - * region_tag:gkemulticloud_v1_generated_AwsClusters_GenerateAwsClusterAgentToken_async - * @deprecated GenerateAwsClusterAgentToken is deprecated and may be removed in a future version. - */ + /** + * Generates an access token for a cluster agent. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.awsCluster + * Required. + * @param {string} request.subjectToken + * Required. + * @param {string} request.subjectTokenType + * Required. + * @param {string} request.version + * Required. + * @param {string} [request.nodePoolId] + * Optional. + * @param {string} [request.grantType] + * Optional. + * @param {string} [request.audience] + * Optional. + * @param {string} [request.scope] + * Optional. + * @param {string} [request.requestedTokenType] + * Optional. + * @param {string} [request.options] + * Optional. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.gkemulticloud.v1.GenerateAwsClusterAgentTokenResponse|GenerateAwsClusterAgentTokenResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/aws_clusters.generate_aws_cluster_agent_token.js + * region_tag:gkemulticloud_v1_generated_AwsClusters_GenerateAwsClusterAgentToken_async + * @deprecated GenerateAwsClusterAgentToken is deprecated and may be removed in a future version. + */ generateAwsClusterAgentToken( - request?: protos.google.cloud.gkemulticloud.v1.IGenerateAwsClusterAgentTokenRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gkemulticloud.v1.IGenerateAwsClusterAgentTokenResponse, - protos.google.cloud.gkemulticloud.v1.IGenerateAwsClusterAgentTokenRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkemulticloud.v1.IGenerateAwsClusterAgentTokenRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gkemulticloud.v1.IGenerateAwsClusterAgentTokenResponse, + ( + | protos.google.cloud.gkemulticloud.v1.IGenerateAwsClusterAgentTokenRequest + | undefined + ), + {} | undefined, + ] + >; generateAwsClusterAgentToken( - request: protos.google.cloud.gkemulticloud.v1.IGenerateAwsClusterAgentTokenRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.gkemulticloud.v1.IGenerateAwsClusterAgentTokenResponse, - protos.google.cloud.gkemulticloud.v1.IGenerateAwsClusterAgentTokenRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IGenerateAwsClusterAgentTokenRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.gkemulticloud.v1.IGenerateAwsClusterAgentTokenResponse, + | protos.google.cloud.gkemulticloud.v1.IGenerateAwsClusterAgentTokenRequest + | null + | undefined, + {} | null | undefined + >, + ): void; generateAwsClusterAgentToken( - request: protos.google.cloud.gkemulticloud.v1.IGenerateAwsClusterAgentTokenRequest, - callback: Callback< - protos.google.cloud.gkemulticloud.v1.IGenerateAwsClusterAgentTokenResponse, - protos.google.cloud.gkemulticloud.v1.IGenerateAwsClusterAgentTokenRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IGenerateAwsClusterAgentTokenRequest, + callback: Callback< + protos.google.cloud.gkemulticloud.v1.IGenerateAwsClusterAgentTokenResponse, + | protos.google.cloud.gkemulticloud.v1.IGenerateAwsClusterAgentTokenRequest + | null + | undefined, + {} | null | undefined + >, + ): void; generateAwsClusterAgentToken( - request?: protos.google.cloud.gkemulticloud.v1.IGenerateAwsClusterAgentTokenRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.gkemulticloud.v1.IGenerateAwsClusterAgentTokenResponse, - protos.google.cloud.gkemulticloud.v1.IGenerateAwsClusterAgentTokenRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.gkemulticloud.v1.IGenerateAwsClusterAgentTokenRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.gkemulticloud.v1.IGenerateAwsClusterAgentTokenResponse, - protos.google.cloud.gkemulticloud.v1.IGenerateAwsClusterAgentTokenRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.gkemulticloud.v1.IGenerateAwsClusterAgentTokenResponse, - protos.google.cloud.gkemulticloud.v1.IGenerateAwsClusterAgentTokenRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.gkemulticloud.v1.IGenerateAwsClusterAgentTokenRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.gkemulticloud.v1.IGenerateAwsClusterAgentTokenResponse, + | protos.google.cloud.gkemulticloud.v1.IGenerateAwsClusterAgentTokenRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.gkemulticloud.v1.IGenerateAwsClusterAgentTokenResponse, + ( + | protos.google.cloud.gkemulticloud.v1.IGenerateAwsClusterAgentTokenRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'aws_cluster': request.awsCluster ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + aws_cluster: request.awsCluster ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - this.warn('DEP$AwsClusters-$GenerateAwsClusterAgentToken','GenerateAwsClusterAgentToken is deprecated and may be removed in a future version.', 'DeprecationWarning'); + this.warn( + 'DEP$AwsClusters-$GenerateAwsClusterAgentToken', + 'GenerateAwsClusterAgentToken is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); this._log.info('generateAwsClusterAgentToken request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.gkemulticloud.v1.IGenerateAwsClusterAgentTokenResponse, - protos.google.cloud.gkemulticloud.v1.IGenerateAwsClusterAgentTokenRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.gkemulticloud.v1.IGenerateAwsClusterAgentTokenResponse, + | protos.google.cloud.gkemulticloud.v1.IGenerateAwsClusterAgentTokenRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('generateAwsClusterAgentToken response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.generateAwsClusterAgentToken(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.gkemulticloud.v1.IGenerateAwsClusterAgentTokenResponse, - protos.google.cloud.gkemulticloud.v1.IGenerateAwsClusterAgentTokenRequest|undefined, - {}|undefined - ]) => { - this._log.info('generateAwsClusterAgentToken response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .generateAwsClusterAgentToken(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.gkemulticloud.v1.IGenerateAwsClusterAgentTokenResponse, + ( + | protos.google.cloud.gkemulticloud.v1.IGenerateAwsClusterAgentTokenRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('generateAwsClusterAgentToken response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 access token to authenticate to a given - * {@link protos.google.cloud.gkemulticloud.v1.AwsCluster|AwsCluster} resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.awsCluster - * Required. The name of the - * {@link protos.google.cloud.gkemulticloud.v1.AwsCluster|AwsCluster} resource to - * authenticate to. - * - * `AwsCluster` names are formatted as - * `projects//locations//awsClusters/`. - * - * See [Resource Names](https://cloud.google.com/apis/design/resource_names) - * for more details on Google Cloud resource names. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.gkemulticloud.v1.GenerateAwsAccessTokenResponse|GenerateAwsAccessTokenResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/aws_clusters.generate_aws_access_token.js - * region_tag:gkemulticloud_v1_generated_AwsClusters_GenerateAwsAccessToken_async - * @deprecated GenerateAwsAccessToken is deprecated and may be removed in a future version. - */ + /** + * Generates a short-lived access token to authenticate to a given + * {@link protos.google.cloud.gkemulticloud.v1.AwsCluster|AwsCluster} resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.awsCluster + * Required. The name of the + * {@link protos.google.cloud.gkemulticloud.v1.AwsCluster|AwsCluster} resource to + * authenticate to. + * + * `AwsCluster` names are formatted as + * `projects//locations//awsClusters/`. + * + * See [Resource Names](https://cloud.google.com/apis/design/resource_names) + * for more details on Google Cloud resource names. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.gkemulticloud.v1.GenerateAwsAccessTokenResponse|GenerateAwsAccessTokenResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/aws_clusters.generate_aws_access_token.js + * region_tag:gkemulticloud_v1_generated_AwsClusters_GenerateAwsAccessToken_async + * @deprecated GenerateAwsAccessToken is deprecated and may be removed in a future version. + */ generateAwsAccessToken( - request?: protos.google.cloud.gkemulticloud.v1.IGenerateAwsAccessTokenRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gkemulticloud.v1.IGenerateAwsAccessTokenResponse, - protos.google.cloud.gkemulticloud.v1.IGenerateAwsAccessTokenRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkemulticloud.v1.IGenerateAwsAccessTokenRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gkemulticloud.v1.IGenerateAwsAccessTokenResponse, + ( + | protos.google.cloud.gkemulticloud.v1.IGenerateAwsAccessTokenRequest + | undefined + ), + {} | undefined, + ] + >; generateAwsAccessToken( - request: protos.google.cloud.gkemulticloud.v1.IGenerateAwsAccessTokenRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.gkemulticloud.v1.IGenerateAwsAccessTokenResponse, - protos.google.cloud.gkemulticloud.v1.IGenerateAwsAccessTokenRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IGenerateAwsAccessTokenRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.gkemulticloud.v1.IGenerateAwsAccessTokenResponse, + | protos.google.cloud.gkemulticloud.v1.IGenerateAwsAccessTokenRequest + | null + | undefined, + {} | null | undefined + >, + ): void; generateAwsAccessToken( - request: protos.google.cloud.gkemulticloud.v1.IGenerateAwsAccessTokenRequest, - callback: Callback< - protos.google.cloud.gkemulticloud.v1.IGenerateAwsAccessTokenResponse, - protos.google.cloud.gkemulticloud.v1.IGenerateAwsAccessTokenRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IGenerateAwsAccessTokenRequest, + callback: Callback< + protos.google.cloud.gkemulticloud.v1.IGenerateAwsAccessTokenResponse, + | protos.google.cloud.gkemulticloud.v1.IGenerateAwsAccessTokenRequest + | null + | undefined, + {} | null | undefined + >, + ): void; generateAwsAccessToken( - request?: protos.google.cloud.gkemulticloud.v1.IGenerateAwsAccessTokenRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.gkemulticloud.v1.IGenerateAwsAccessTokenResponse, - protos.google.cloud.gkemulticloud.v1.IGenerateAwsAccessTokenRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.gkemulticloud.v1.IGenerateAwsAccessTokenRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.gkemulticloud.v1.IGenerateAwsAccessTokenResponse, - protos.google.cloud.gkemulticloud.v1.IGenerateAwsAccessTokenRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.gkemulticloud.v1.IGenerateAwsAccessTokenResponse, - protos.google.cloud.gkemulticloud.v1.IGenerateAwsAccessTokenRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.gkemulticloud.v1.IGenerateAwsAccessTokenRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.gkemulticloud.v1.IGenerateAwsAccessTokenResponse, + | protos.google.cloud.gkemulticloud.v1.IGenerateAwsAccessTokenRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.gkemulticloud.v1.IGenerateAwsAccessTokenResponse, + ( + | protos.google.cloud.gkemulticloud.v1.IGenerateAwsAccessTokenRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'aws_cluster': request.awsCluster ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + aws_cluster: request.awsCluster ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - this.warn('DEP$AwsClusters-$GenerateAwsAccessToken','GenerateAwsAccessToken is deprecated and may be removed in a future version.', 'DeprecationWarning'); + this.warn( + 'DEP$AwsClusters-$GenerateAwsAccessToken', + 'GenerateAwsAccessToken is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); this._log.info('generateAwsAccessToken request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.gkemulticloud.v1.IGenerateAwsAccessTokenResponse, - protos.google.cloud.gkemulticloud.v1.IGenerateAwsAccessTokenRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.gkemulticloud.v1.IGenerateAwsAccessTokenResponse, + | protos.google.cloud.gkemulticloud.v1.IGenerateAwsAccessTokenRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('generateAwsAccessToken response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.generateAwsAccessToken(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.gkemulticloud.v1.IGenerateAwsAccessTokenResponse, - protos.google.cloud.gkemulticloud.v1.IGenerateAwsAccessTokenRequest|undefined, - {}|undefined - ]) => { - this._log.info('generateAwsAccessToken response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .generateAwsAccessToken(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.gkemulticloud.v1.IGenerateAwsAccessTokenResponse, + ( + | protos.google.cloud.gkemulticloud.v1.IGenerateAwsAccessTokenRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('generateAwsAccessToken response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Describes a specific - * {@link protos.google.cloud.gkemulticloud.v1.AwsNodePool|AwsNodePool} resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the - * {@link protos.google.cloud.gkemulticloud.v1.AwsNodePool|AwsNodePool} resource to - * describe. - * - * `AwsNodePool` names are formatted as - * `projects//locations//awsClusters//awsNodePools/`. - * - * See [Resource Names](https://cloud.google.com/apis/design/resource_names) - * for more details on Google Cloud resource names. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.gkemulticloud.v1.AwsNodePool|AwsNodePool}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/aws_clusters.get_aws_node_pool.js - * region_tag:gkemulticloud_v1_generated_AwsClusters_GetAwsNodePool_async - * @deprecated GetAwsNodePool is deprecated and may be removed in a future version. - */ + /** + * Describes a specific + * {@link protos.google.cloud.gkemulticloud.v1.AwsNodePool|AwsNodePool} resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the + * {@link protos.google.cloud.gkemulticloud.v1.AwsNodePool|AwsNodePool} resource to + * describe. + * + * `AwsNodePool` names are formatted as + * `projects//locations//awsClusters//awsNodePools/`. + * + * See [Resource Names](https://cloud.google.com/apis/design/resource_names) + * for more details on Google Cloud resource names. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.gkemulticloud.v1.AwsNodePool|AwsNodePool}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/aws_clusters.get_aws_node_pool.js + * region_tag:gkemulticloud_v1_generated_AwsClusters_GetAwsNodePool_async + * @deprecated GetAwsNodePool is deprecated and may be removed in a future version. + */ getAwsNodePool( - request?: protos.google.cloud.gkemulticloud.v1.IGetAwsNodePoolRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gkemulticloud.v1.IAwsNodePool, - protos.google.cloud.gkemulticloud.v1.IGetAwsNodePoolRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkemulticloud.v1.IGetAwsNodePoolRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gkemulticloud.v1.IAwsNodePool, + protos.google.cloud.gkemulticloud.v1.IGetAwsNodePoolRequest | undefined, + {} | undefined, + ] + >; getAwsNodePool( - request: protos.google.cloud.gkemulticloud.v1.IGetAwsNodePoolRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.gkemulticloud.v1.IAwsNodePool, - protos.google.cloud.gkemulticloud.v1.IGetAwsNodePoolRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IGetAwsNodePoolRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.gkemulticloud.v1.IAwsNodePool, + | protos.google.cloud.gkemulticloud.v1.IGetAwsNodePoolRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getAwsNodePool( - request: protos.google.cloud.gkemulticloud.v1.IGetAwsNodePoolRequest, - callback: Callback< - protos.google.cloud.gkemulticloud.v1.IAwsNodePool, - protos.google.cloud.gkemulticloud.v1.IGetAwsNodePoolRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IGetAwsNodePoolRequest, + callback: Callback< + protos.google.cloud.gkemulticloud.v1.IAwsNodePool, + | protos.google.cloud.gkemulticloud.v1.IGetAwsNodePoolRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getAwsNodePool( - request?: protos.google.cloud.gkemulticloud.v1.IGetAwsNodePoolRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.gkemulticloud.v1.IAwsNodePool, - protos.google.cloud.gkemulticloud.v1.IGetAwsNodePoolRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.gkemulticloud.v1.IGetAwsNodePoolRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.gkemulticloud.v1.IAwsNodePool, - protos.google.cloud.gkemulticloud.v1.IGetAwsNodePoolRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.gkemulticloud.v1.IAwsNodePool, - protos.google.cloud.gkemulticloud.v1.IGetAwsNodePoolRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.gkemulticloud.v1.IGetAwsNodePoolRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.gkemulticloud.v1.IAwsNodePool, + | protos.google.cloud.gkemulticloud.v1.IGetAwsNodePoolRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.gkemulticloud.v1.IAwsNodePool, + protos.google.cloud.gkemulticloud.v1.IGetAwsNodePoolRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - this.warn('DEP$AwsClusters-$GetAwsNodePool','GetAwsNodePool is deprecated and may be removed in a future version.', 'DeprecationWarning'); + this.warn( + 'DEP$AwsClusters-$GetAwsNodePool', + 'GetAwsNodePool is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); this._log.info('getAwsNodePool request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.gkemulticloud.v1.IAwsNodePool, - protos.google.cloud.gkemulticloud.v1.IGetAwsNodePoolRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.gkemulticloud.v1.IAwsNodePool, + | protos.google.cloud.gkemulticloud.v1.IGetAwsNodePoolRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getAwsNodePool response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getAwsNodePool(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.gkemulticloud.v1.IAwsNodePool, - protos.google.cloud.gkemulticloud.v1.IGetAwsNodePoolRequest|undefined, - {}|undefined - ]) => { - this._log.info('getAwsNodePool response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getAwsNodePool(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.gkemulticloud.v1.IAwsNodePool, + ( + | protos.google.cloud.gkemulticloud.v1.IGetAwsNodePoolRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getAwsNodePool response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 OIDC discovery document for the cluster. - * See the - * [OpenID Connect Discovery 1.0 - * specification](https://openid.net/specs/openid-connect-discovery-1_0.html) - * for details. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.awsCluster - * Required. The AwsCluster, which owns the OIDC discovery document. - * Format: - * projects/{project}/locations/{location}/awsClusters/{cluster} - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.gkemulticloud.v1.AwsOpenIdConfig|AwsOpenIdConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/aws_clusters.get_aws_open_id_config.js - * region_tag:gkemulticloud_v1_generated_AwsClusters_GetAwsOpenIdConfig_async - * @deprecated GetAwsOpenIdConfig is deprecated and may be removed in a future version. - */ + /** + * Gets the OIDC discovery document for the cluster. + * See the + * [OpenID Connect Discovery 1.0 + * specification](https://openid.net/specs/openid-connect-discovery-1_0.html) + * for details. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.awsCluster + * Required. The AwsCluster, which owns the OIDC discovery document. + * Format: + * projects/{project}/locations/{location}/awsClusters/{cluster} + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.gkemulticloud.v1.AwsOpenIdConfig|AwsOpenIdConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/aws_clusters.get_aws_open_id_config.js + * region_tag:gkemulticloud_v1_generated_AwsClusters_GetAwsOpenIdConfig_async + * @deprecated GetAwsOpenIdConfig is deprecated and may be removed in a future version. + */ getAwsOpenIdConfig( - request?: protos.google.cloud.gkemulticloud.v1.IGetAwsOpenIdConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gkemulticloud.v1.IAwsOpenIdConfig, - protos.google.cloud.gkemulticloud.v1.IGetAwsOpenIdConfigRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkemulticloud.v1.IGetAwsOpenIdConfigRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gkemulticloud.v1.IAwsOpenIdConfig, + ( + | protos.google.cloud.gkemulticloud.v1.IGetAwsOpenIdConfigRequest + | undefined + ), + {} | undefined, + ] + >; getAwsOpenIdConfig( - request: protos.google.cloud.gkemulticloud.v1.IGetAwsOpenIdConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.gkemulticloud.v1.IAwsOpenIdConfig, - protos.google.cloud.gkemulticloud.v1.IGetAwsOpenIdConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IGetAwsOpenIdConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.gkemulticloud.v1.IAwsOpenIdConfig, + | protos.google.cloud.gkemulticloud.v1.IGetAwsOpenIdConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getAwsOpenIdConfig( - request: protos.google.cloud.gkemulticloud.v1.IGetAwsOpenIdConfigRequest, - callback: Callback< - protos.google.cloud.gkemulticloud.v1.IAwsOpenIdConfig, - protos.google.cloud.gkemulticloud.v1.IGetAwsOpenIdConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IGetAwsOpenIdConfigRequest, + callback: Callback< + protos.google.cloud.gkemulticloud.v1.IAwsOpenIdConfig, + | protos.google.cloud.gkemulticloud.v1.IGetAwsOpenIdConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getAwsOpenIdConfig( - request?: protos.google.cloud.gkemulticloud.v1.IGetAwsOpenIdConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.gkemulticloud.v1.IAwsOpenIdConfig, - protos.google.cloud.gkemulticloud.v1.IGetAwsOpenIdConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.gkemulticloud.v1.IGetAwsOpenIdConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.gkemulticloud.v1.IAwsOpenIdConfig, - protos.google.cloud.gkemulticloud.v1.IGetAwsOpenIdConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.gkemulticloud.v1.IAwsOpenIdConfig, - protos.google.cloud.gkemulticloud.v1.IGetAwsOpenIdConfigRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.gkemulticloud.v1.IGetAwsOpenIdConfigRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.gkemulticloud.v1.IAwsOpenIdConfig, + | protos.google.cloud.gkemulticloud.v1.IGetAwsOpenIdConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.gkemulticloud.v1.IAwsOpenIdConfig, + ( + | protos.google.cloud.gkemulticloud.v1.IGetAwsOpenIdConfigRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'aws_cluster': request.awsCluster ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + aws_cluster: request.awsCluster ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - this.warn('DEP$AwsClusters-$GetAwsOpenIdConfig','GetAwsOpenIdConfig is deprecated and may be removed in a future version.', 'DeprecationWarning'); + this.warn( + 'DEP$AwsClusters-$GetAwsOpenIdConfig', + 'GetAwsOpenIdConfig is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); this._log.info('getAwsOpenIdConfig request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.gkemulticloud.v1.IAwsOpenIdConfig, - protos.google.cloud.gkemulticloud.v1.IGetAwsOpenIdConfigRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.gkemulticloud.v1.IAwsOpenIdConfig, + | protos.google.cloud.gkemulticloud.v1.IGetAwsOpenIdConfigRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getAwsOpenIdConfig response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getAwsOpenIdConfig(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.gkemulticloud.v1.IAwsOpenIdConfig, - protos.google.cloud.gkemulticloud.v1.IGetAwsOpenIdConfigRequest|undefined, - {}|undefined - ]) => { - this._log.info('getAwsOpenIdConfig response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getAwsOpenIdConfig(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.gkemulticloud.v1.IAwsOpenIdConfig, + ( + | protos.google.cloud.gkemulticloud.v1.IGetAwsOpenIdConfigRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getAwsOpenIdConfig response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 public component of the cluster signing keys in - * JSON Web Key format. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.awsCluster - * Required. The AwsCluster, which owns the JsonWebKeys. - * Format: - * projects/{project}/locations/{location}/awsClusters/{cluster} - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.gkemulticloud.v1.AwsJsonWebKeys|AwsJsonWebKeys}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/aws_clusters.get_aws_json_web_keys.js - * region_tag:gkemulticloud_v1_generated_AwsClusters_GetAwsJsonWebKeys_async - * @deprecated GetAwsJsonWebKeys is deprecated and may be removed in a future version. - */ + /** + * Gets the public component of the cluster signing keys in + * JSON Web Key format. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.awsCluster + * Required. The AwsCluster, which owns the JsonWebKeys. + * Format: + * projects/{project}/locations/{location}/awsClusters/{cluster} + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.gkemulticloud.v1.AwsJsonWebKeys|AwsJsonWebKeys}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/aws_clusters.get_aws_json_web_keys.js + * region_tag:gkemulticloud_v1_generated_AwsClusters_GetAwsJsonWebKeys_async + * @deprecated GetAwsJsonWebKeys is deprecated and may be removed in a future version. + */ getAwsJsonWebKeys( - request?: protos.google.cloud.gkemulticloud.v1.IGetAwsJsonWebKeysRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gkemulticloud.v1.IAwsJsonWebKeys, - protos.google.cloud.gkemulticloud.v1.IGetAwsJsonWebKeysRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkemulticloud.v1.IGetAwsJsonWebKeysRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gkemulticloud.v1.IAwsJsonWebKeys, + ( + | protos.google.cloud.gkemulticloud.v1.IGetAwsJsonWebKeysRequest + | undefined + ), + {} | undefined, + ] + >; getAwsJsonWebKeys( - request: protos.google.cloud.gkemulticloud.v1.IGetAwsJsonWebKeysRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.gkemulticloud.v1.IAwsJsonWebKeys, - protos.google.cloud.gkemulticloud.v1.IGetAwsJsonWebKeysRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IGetAwsJsonWebKeysRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.gkemulticloud.v1.IAwsJsonWebKeys, + | protos.google.cloud.gkemulticloud.v1.IGetAwsJsonWebKeysRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getAwsJsonWebKeys( - request: protos.google.cloud.gkemulticloud.v1.IGetAwsJsonWebKeysRequest, - callback: Callback< - protos.google.cloud.gkemulticloud.v1.IAwsJsonWebKeys, - protos.google.cloud.gkemulticloud.v1.IGetAwsJsonWebKeysRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IGetAwsJsonWebKeysRequest, + callback: Callback< + protos.google.cloud.gkemulticloud.v1.IAwsJsonWebKeys, + | protos.google.cloud.gkemulticloud.v1.IGetAwsJsonWebKeysRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getAwsJsonWebKeys( - request?: protos.google.cloud.gkemulticloud.v1.IGetAwsJsonWebKeysRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.gkemulticloud.v1.IAwsJsonWebKeys, - protos.google.cloud.gkemulticloud.v1.IGetAwsJsonWebKeysRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.gkemulticloud.v1.IGetAwsJsonWebKeysRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.gkemulticloud.v1.IAwsJsonWebKeys, - protos.google.cloud.gkemulticloud.v1.IGetAwsJsonWebKeysRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.gkemulticloud.v1.IAwsJsonWebKeys, - protos.google.cloud.gkemulticloud.v1.IGetAwsJsonWebKeysRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.gkemulticloud.v1.IGetAwsJsonWebKeysRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.gkemulticloud.v1.IAwsJsonWebKeys, + | protos.google.cloud.gkemulticloud.v1.IGetAwsJsonWebKeysRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.gkemulticloud.v1.IAwsJsonWebKeys, + ( + | protos.google.cloud.gkemulticloud.v1.IGetAwsJsonWebKeysRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'aws_cluster': request.awsCluster ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + aws_cluster: request.awsCluster ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - this.warn('DEP$AwsClusters-$GetAwsJsonWebKeys','GetAwsJsonWebKeys is deprecated and may be removed in a future version.', 'DeprecationWarning'); + this.warn( + 'DEP$AwsClusters-$GetAwsJsonWebKeys', + 'GetAwsJsonWebKeys is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); this._log.info('getAwsJsonWebKeys request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.gkemulticloud.v1.IAwsJsonWebKeys, - protos.google.cloud.gkemulticloud.v1.IGetAwsJsonWebKeysRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.gkemulticloud.v1.IAwsJsonWebKeys, + | protos.google.cloud.gkemulticloud.v1.IGetAwsJsonWebKeysRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getAwsJsonWebKeys response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getAwsJsonWebKeys(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.gkemulticloud.v1.IAwsJsonWebKeys, - protos.google.cloud.gkemulticloud.v1.IGetAwsJsonWebKeysRequest|undefined, - {}|undefined - ]) => { - this._log.info('getAwsJsonWebKeys response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getAwsJsonWebKeys(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.gkemulticloud.v1.IAwsJsonWebKeys, + ( + | protos.google.cloud.gkemulticloud.v1.IGetAwsJsonWebKeysRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getAwsJsonWebKeys response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 information, such as supported AWS regions and Kubernetes - * versions, on a given Google Cloud location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the - * {@link protos.google.cloud.gkemulticloud.v1.AwsServerConfig|AwsServerConfig} resource - * to describe. - * - * `AwsServerConfig` names are formatted as - * `projects//locations//awsServerConfig`. - * - * See [Resource Names](https://cloud.google.com/apis/design/resource_names) - * for more details on Google Cloud resource names. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.gkemulticloud.v1.AwsServerConfig|AwsServerConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/aws_clusters.get_aws_server_config.js - * region_tag:gkemulticloud_v1_generated_AwsClusters_GetAwsServerConfig_async - * @deprecated GetAwsServerConfig is deprecated and may be removed in a future version. - */ + /** + * Returns information, such as supported AWS regions and Kubernetes + * versions, on a given Google Cloud location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the + * {@link protos.google.cloud.gkemulticloud.v1.AwsServerConfig|AwsServerConfig} resource + * to describe. + * + * `AwsServerConfig` names are formatted as + * `projects//locations//awsServerConfig`. + * + * See [Resource Names](https://cloud.google.com/apis/design/resource_names) + * for more details on Google Cloud resource names. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.gkemulticloud.v1.AwsServerConfig|AwsServerConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/aws_clusters.get_aws_server_config.js + * region_tag:gkemulticloud_v1_generated_AwsClusters_GetAwsServerConfig_async + * @deprecated GetAwsServerConfig is deprecated and may be removed in a future version. + */ getAwsServerConfig( - request?: protos.google.cloud.gkemulticloud.v1.IGetAwsServerConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gkemulticloud.v1.IAwsServerConfig, - protos.google.cloud.gkemulticloud.v1.IGetAwsServerConfigRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkemulticloud.v1.IGetAwsServerConfigRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gkemulticloud.v1.IAwsServerConfig, + ( + | protos.google.cloud.gkemulticloud.v1.IGetAwsServerConfigRequest + | undefined + ), + {} | undefined, + ] + >; getAwsServerConfig( - request: protos.google.cloud.gkemulticloud.v1.IGetAwsServerConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.gkemulticloud.v1.IAwsServerConfig, - protos.google.cloud.gkemulticloud.v1.IGetAwsServerConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IGetAwsServerConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.gkemulticloud.v1.IAwsServerConfig, + | protos.google.cloud.gkemulticloud.v1.IGetAwsServerConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getAwsServerConfig( - request: protos.google.cloud.gkemulticloud.v1.IGetAwsServerConfigRequest, - callback: Callback< - protos.google.cloud.gkemulticloud.v1.IAwsServerConfig, - protos.google.cloud.gkemulticloud.v1.IGetAwsServerConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IGetAwsServerConfigRequest, + callback: Callback< + protos.google.cloud.gkemulticloud.v1.IAwsServerConfig, + | protos.google.cloud.gkemulticloud.v1.IGetAwsServerConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getAwsServerConfig( - request?: protos.google.cloud.gkemulticloud.v1.IGetAwsServerConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.gkemulticloud.v1.IAwsServerConfig, - protos.google.cloud.gkemulticloud.v1.IGetAwsServerConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.gkemulticloud.v1.IGetAwsServerConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.gkemulticloud.v1.IAwsServerConfig, - protos.google.cloud.gkemulticloud.v1.IGetAwsServerConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.gkemulticloud.v1.IAwsServerConfig, - protos.google.cloud.gkemulticloud.v1.IGetAwsServerConfigRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.gkemulticloud.v1.IGetAwsServerConfigRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.gkemulticloud.v1.IAwsServerConfig, + | protos.google.cloud.gkemulticloud.v1.IGetAwsServerConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.gkemulticloud.v1.IAwsServerConfig, + ( + | protos.google.cloud.gkemulticloud.v1.IGetAwsServerConfigRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - this.warn('DEP$AwsClusters-$GetAwsServerConfig','GetAwsServerConfig is deprecated and may be removed in a future version.', 'DeprecationWarning'); + this.warn( + 'DEP$AwsClusters-$GetAwsServerConfig', + 'GetAwsServerConfig is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); this._log.info('getAwsServerConfig request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.gkemulticloud.v1.IAwsServerConfig, - protos.google.cloud.gkemulticloud.v1.IGetAwsServerConfigRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.gkemulticloud.v1.IAwsServerConfig, + | protos.google.cloud.gkemulticloud.v1.IGetAwsServerConfigRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getAwsServerConfig response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getAwsServerConfig(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.gkemulticloud.v1.IAwsServerConfig, - protos.google.cloud.gkemulticloud.v1.IGetAwsServerConfigRequest|undefined, - {}|undefined - ]) => { - this._log.info('getAwsServerConfig response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getAwsServerConfig(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.gkemulticloud.v1.IAwsServerConfig, + ( + | protos.google.cloud.gkemulticloud.v1.IGetAwsServerConfigRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getAwsServerConfig response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 {@link protos.google.cloud.gkemulticloud.v1.AwsCluster|AwsCluster} - * resource on a given Google Cloud Platform project and region. - * - * If successful, the response contains a newly created - * {@link protos.google.longrunning.Operation|Operation} resource that can be - * described to track the status of the operation. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent location where this - * {@link protos.google.cloud.gkemulticloud.v1.AwsCluster|AwsCluster} resource will be - * created. - * - * Location names are formatted as `projects//locations/`. - * - * See [Resource Names](https://cloud.google.com/apis/design/resource_names) - * for more details on Google Cloud resource names. - * @param {google.cloud.gkemulticloud.v1.AwsCluster} request.awsCluster - * Required. The specification of the - * {@link protos.google.cloud.gkemulticloud.v1.AwsCluster|AwsCluster} to create. - * @param {string} request.awsClusterId - * Required. A client provided ID the resource. Must be unique within the - * parent resource. - * - * The provided ID will be part of the - * {@link protos.google.cloud.gkemulticloud.v1.AwsCluster|AwsCluster} resource name - * formatted as - * `projects//locations//awsClusters/`. - * - * Valid characters are `/{@link protos.0-9|a-z}-/`. Cannot be longer than 63 characters. - * @param {boolean} request.validateOnly - * If set, only validate the request, but do not actually create the cluster. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/aws_clusters.create_aws_cluster.js - * region_tag:gkemulticloud_v1_generated_AwsClusters_CreateAwsCluster_async - * @deprecated CreateAwsCluster is deprecated and may be removed in a future version. - */ - createAwsCluster( - request?: protos.google.cloud.gkemulticloud.v1.ICreateAwsClusterRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + /** + * Creates a new {@link protos.google.cloud.gkemulticloud.v1.AwsCluster|AwsCluster} + * resource on a given Google Cloud Platform project and region. + * + * If successful, the response contains a newly created + * {@link protos.google.longrunning.Operation|Operation} resource that can be + * described to track the status of the operation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent location where this + * {@link protos.google.cloud.gkemulticloud.v1.AwsCluster|AwsCluster} resource will be + * created. + * + * Location names are formatted as `projects//locations/`. + * + * See [Resource Names](https://cloud.google.com/apis/design/resource_names) + * for more details on Google Cloud resource names. + * @param {google.cloud.gkemulticloud.v1.AwsCluster} request.awsCluster + * Required. The specification of the + * {@link protos.google.cloud.gkemulticloud.v1.AwsCluster|AwsCluster} to create. + * @param {string} request.awsClusterId + * Required. A client provided ID the resource. Must be unique within the + * parent resource. + * + * The provided ID will be part of the + * {@link protos.google.cloud.gkemulticloud.v1.AwsCluster|AwsCluster} resource name + * formatted as + * `projects//locations//awsClusters/`. + * + * Valid characters are `/{@link protos.0-9|a-z}-/`. Cannot be longer than 63 characters. + * @param {boolean} request.validateOnly + * If set, only validate the request, but do not actually create the cluster. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/aws_clusters.create_aws_cluster.js + * region_tag:gkemulticloud_v1_generated_AwsClusters_CreateAwsCluster_async + * @deprecated CreateAwsCluster is deprecated and may be removed in a future version. + */ createAwsCluster( - request: protos.google.cloud.gkemulticloud.v1.ICreateAwsClusterRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request?: protos.google.cloud.gkemulticloud.v1.ICreateAwsClusterRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.gkemulticloud.v1.IAwsCluster, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createAwsCluster( - request: protos.google.cloud.gkemulticloud.v1.ICreateAwsClusterRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.ICreateAwsClusterRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAwsCluster, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createAwsCluster( - request?: protos.google.cloud.gkemulticloud.v1.ICreateAwsClusterRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request: protos.google.cloud.gkemulticloud.v1.ICreateAwsClusterRequest, + callback: Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAwsCluster, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; + createAwsCluster( + request?: protos.google.cloud.gkemulticloud.v1.ICreateAwsClusterRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAwsCluster, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAwsCluster, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.gkemulticloud.v1.IAwsCluster, + protos.google.cloud.gkemulticloud.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}); - this.warn('DEP$AwsClusters-$CreateAwsCluster','CreateAwsCluster is deprecated and may be removed in a future version.', 'DeprecationWarning'); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + this.warn( + 'DEP$AwsClusters-$CreateAwsCluster', + 'CreateAwsCluster is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAwsCluster, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createAwsCluster response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createAwsCluster request %j', request); - return this.innerApiCalls.createAwsCluster(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createAwsCluster response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createAwsCluster(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.gkemulticloud.v1.IAwsCluster, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createAwsCluster response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createAwsCluster()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/aws_clusters.create_aws_cluster.js - * region_tag:gkemulticloud_v1_generated_AwsClusters_CreateAwsCluster_async - * @deprecated CreateAwsCluster is deprecated and may be removed in a future version. - */ - async checkCreateAwsClusterProgress(name: string): Promise>{ - this.warn('DEP$AwsClusters-$checkCreateAwsClusterProgress','checkCreateAwsClusterProgress is deprecated and may be removed in a future version.', 'DeprecationWarning'); + /** + * Check the status of the long running operation returned by `createAwsCluster()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/aws_clusters.create_aws_cluster.js + * region_tag:gkemulticloud_v1_generated_AwsClusters_CreateAwsCluster_async + * @deprecated CreateAwsCluster is deprecated and may be removed in a future version. + */ + async checkCreateAwsClusterProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.gkemulticloud.v1.AwsCluster, + protos.google.cloud.gkemulticloud.v1.OperationMetadata + > + > { + this.warn( + 'DEP$AwsClusters-$checkCreateAwsClusterProgress', + 'checkCreateAwsClusterProgress is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); this._log.info('createAwsCluster long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createAwsCluster, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createAwsCluster, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.gkemulticloud.v1.AwsCluster, + protos.google.cloud.gkemulticloud.v1.OperationMetadata + >; } -/** - * Updates an {@link protos.google.cloud.gkemulticloud.v1.AwsCluster|AwsCluster}. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.gkemulticloud.v1.AwsCluster} request.awsCluster - * Required. The {@link protos.google.cloud.gkemulticloud.v1.AwsCluster|AwsCluster} - * resource to update. - * @param {boolean} request.validateOnly - * If set, only validate the request, but do not actually update the cluster. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. Mask of fields to update. At least one path must be supplied in - * this field. The elements of the repeated paths field can only include these - * fields from {@link protos.google.cloud.gkemulticloud.v1.AwsCluster|AwsCluster}: - * - * * `description`. - * * `annotations`. - * * `control_plane.version`. - * * `authorization.admin_users`. - * * `authorization.admin_groups`. - * * `binary_authorization.evaluation_mode`. - * * `control_plane.aws_services_authentication.role_arn`. - * * `control_plane.aws_services_authentication.role_session_name`. - * * `control_plane.config_encryption.kms_key_arn`. - * * `control_plane.instance_type`. - * * `control_plane.security_group_ids`. - * * `control_plane.proxy_config`. - * * `control_plane.proxy_config.secret_arn`. - * * `control_plane.proxy_config.secret_version`. - * * `control_plane.root_volume.size_gib`. - * * `control_plane.root_volume.volume_type`. - * * `control_plane.root_volume.iops`. - * * `control_plane.root_volume.throughput`. - * * `control_plane.root_volume.kms_key_arn`. - * * `control_plane.ssh_config`. - * * `control_plane.ssh_config.ec2_key_pair`. - * * `control_plane.instance_placement.tenancy`. - * * `control_plane.iam_instance_profile`. - * * `logging_config.component_config.enable_components`. - * * `control_plane.tags`. - * * `monitoring_config.managed_prometheus_config.enabled`. - * * `networking.per_node_pool_sg_rules_disabled`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/aws_clusters.update_aws_cluster.js - * region_tag:gkemulticloud_v1_generated_AwsClusters_UpdateAwsCluster_async - * @deprecated UpdateAwsCluster is deprecated and may be removed in a future version. - */ + /** + * Updates an {@link protos.google.cloud.gkemulticloud.v1.AwsCluster|AwsCluster}. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.gkemulticloud.v1.AwsCluster} request.awsCluster + * Required. The {@link protos.google.cloud.gkemulticloud.v1.AwsCluster|AwsCluster} + * resource to update. + * @param {boolean} request.validateOnly + * If set, only validate the request, but do not actually update the cluster. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. Mask of fields to update. At least one path must be supplied in + * this field. The elements of the repeated paths field can only include these + * fields from {@link protos.google.cloud.gkemulticloud.v1.AwsCluster|AwsCluster}: + * + * * `description`. + * * `annotations`. + * * `control_plane.version`. + * * `authorization.admin_users`. + * * `authorization.admin_groups`. + * * `binary_authorization.evaluation_mode`. + * * `control_plane.aws_services_authentication.role_arn`. + * * `control_plane.aws_services_authentication.role_session_name`. + * * `control_plane.config_encryption.kms_key_arn`. + * * `control_plane.instance_type`. + * * `control_plane.security_group_ids`. + * * `control_plane.proxy_config`. + * * `control_plane.proxy_config.secret_arn`. + * * `control_plane.proxy_config.secret_version`. + * * `control_plane.root_volume.size_gib`. + * * `control_plane.root_volume.volume_type`. + * * `control_plane.root_volume.iops`. + * * `control_plane.root_volume.throughput`. + * * `control_plane.root_volume.kms_key_arn`. + * * `control_plane.ssh_config`. + * * `control_plane.ssh_config.ec2_key_pair`. + * * `control_plane.instance_placement.tenancy`. + * * `control_plane.iam_instance_profile`. + * * `logging_config.component_config.enable_components`. + * * `control_plane.tags`. + * * `monitoring_config.managed_prometheus_config.enabled`. + * * `networking.per_node_pool_sg_rules_disabled`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/aws_clusters.update_aws_cluster.js + * region_tag:gkemulticloud_v1_generated_AwsClusters_UpdateAwsCluster_async + * @deprecated UpdateAwsCluster is deprecated and may be removed in a future version. + */ updateAwsCluster( - request?: protos.google.cloud.gkemulticloud.v1.IUpdateAwsClusterRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkemulticloud.v1.IUpdateAwsClusterRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.gkemulticloud.v1.IAwsCluster, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateAwsCluster( - request: protos.google.cloud.gkemulticloud.v1.IUpdateAwsClusterRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IUpdateAwsClusterRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAwsCluster, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateAwsCluster( - request: protos.google.cloud.gkemulticloud.v1.IUpdateAwsClusterRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IUpdateAwsClusterRequest, + callback: Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAwsCluster, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateAwsCluster( - request?: protos.google.cloud.gkemulticloud.v1.IUpdateAwsClusterRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.gkemulticloud.v1.IUpdateAwsClusterRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAwsCluster, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAwsCluster, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.gkemulticloud.v1.IAwsCluster, + protos.google.cloud.gkemulticloud.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({ - 'aws_cluster.name': request.awsCluster!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'aws_cluster.name': request.awsCluster!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - this.warn('DEP$AwsClusters-$UpdateAwsCluster','UpdateAwsCluster is deprecated and may be removed in a future version.', 'DeprecationWarning'); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + this.warn( + 'DEP$AwsClusters-$UpdateAwsCluster', + 'UpdateAwsCluster is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAwsCluster, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateAwsCluster response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateAwsCluster request %j', request); - return this.innerApiCalls.updateAwsCluster(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateAwsCluster response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateAwsCluster(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.gkemulticloud.v1.IAwsCluster, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateAwsCluster response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateAwsCluster()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/aws_clusters.update_aws_cluster.js - * region_tag:gkemulticloud_v1_generated_AwsClusters_UpdateAwsCluster_async - * @deprecated UpdateAwsCluster is deprecated and may be removed in a future version. - */ - async checkUpdateAwsClusterProgress(name: string): Promise>{ - this.warn('DEP$AwsClusters-$checkUpdateAwsClusterProgress','checkUpdateAwsClusterProgress is deprecated and may be removed in a future version.', 'DeprecationWarning'); + /** + * Check the status of the long running operation returned by `updateAwsCluster()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/aws_clusters.update_aws_cluster.js + * region_tag:gkemulticloud_v1_generated_AwsClusters_UpdateAwsCluster_async + * @deprecated UpdateAwsCluster is deprecated and may be removed in a future version. + */ + async checkUpdateAwsClusterProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.gkemulticloud.v1.AwsCluster, + protos.google.cloud.gkemulticloud.v1.OperationMetadata + > + > { + this.warn( + 'DEP$AwsClusters-$checkUpdateAwsClusterProgress', + 'checkUpdateAwsClusterProgress is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); this._log.info('updateAwsCluster long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.updateAwsCluster, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateAwsCluster, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.gkemulticloud.v1.AwsCluster, + protos.google.cloud.gkemulticloud.v1.OperationMetadata + >; } -/** - * Deletes a specific {@link protos.google.cloud.gkemulticloud.v1.AwsCluster|AwsCluster} - * resource. - * - * Fails if the cluster has one or more associated - * {@link protos.google.cloud.gkemulticloud.v1.AwsNodePool|AwsNodePool} resources. - * - * If successful, the response contains a newly created - * {@link protos.google.longrunning.Operation|Operation} resource that can be - * described to track the status of the operation. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name the - * {@link protos.google.cloud.gkemulticloud.v1.AwsCluster|AwsCluster} to delete. - * - * `AwsCluster` names are formatted as - * `projects//locations//awsClusters/`. - * - * See [Resource Names](https://cloud.google.com/apis/design/resource_names) - * for more details on Google Cloud Platform resource names. - * @param {boolean} request.validateOnly - * If set, only validate the request, but do not actually delete the resource. - * @param {boolean} request.allowMissing - * If set to true, and the - * {@link protos.google.cloud.gkemulticloud.v1.AwsCluster|AwsCluster} resource is not - * found, the request will succeed but no action will be taken on the server - * and a completed {@link protos.google.longrunning.Operation|Operation} will be returned. - * - * Useful for idempotent deletion. - * @param {boolean} [request.ignoreErrors] - * Optional. If set to true, the deletion of - * {@link protos.google.cloud.gkemulticloud.v1.AwsCluster|AwsCluster} resource will - * succeed even if errors occur during deleting in cluster resources. Using - * this parameter may result in orphaned resources in the cluster. - * @param {string} request.etag - * The current etag of the - * {@link protos.google.cloud.gkemulticloud.v1.AwsCluster|AwsCluster}. - * - * Allows clients to perform deletions through optimistic concurrency control. - * - * If the provided etag does not match the current etag of the cluster, - * the request will fail and an ABORTED 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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/aws_clusters.delete_aws_cluster.js - * region_tag:gkemulticloud_v1_generated_AwsClusters_DeleteAwsCluster_async - * @deprecated DeleteAwsCluster is deprecated and may be removed in a future version. - */ + /** + * Deletes a specific {@link protos.google.cloud.gkemulticloud.v1.AwsCluster|AwsCluster} + * resource. + * + * Fails if the cluster has one or more associated + * {@link protos.google.cloud.gkemulticloud.v1.AwsNodePool|AwsNodePool} resources. + * + * If successful, the response contains a newly created + * {@link protos.google.longrunning.Operation|Operation} resource that can be + * described to track the status of the operation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name the + * {@link protos.google.cloud.gkemulticloud.v1.AwsCluster|AwsCluster} to delete. + * + * `AwsCluster` names are formatted as + * `projects//locations//awsClusters/`. + * + * See [Resource Names](https://cloud.google.com/apis/design/resource_names) + * for more details on Google Cloud Platform resource names. + * @param {boolean} request.validateOnly + * If set, only validate the request, but do not actually delete the resource. + * @param {boolean} request.allowMissing + * If set to true, and the + * {@link protos.google.cloud.gkemulticloud.v1.AwsCluster|AwsCluster} resource is not + * found, the request will succeed but no action will be taken on the server + * and a completed {@link protos.google.longrunning.Operation|Operation} will be returned. + * + * Useful for idempotent deletion. + * @param {boolean} [request.ignoreErrors] + * Optional. If set to true, the deletion of + * {@link protos.google.cloud.gkemulticloud.v1.AwsCluster|AwsCluster} resource will + * succeed even if errors occur during deleting in cluster resources. Using + * this parameter may result in orphaned resources in the cluster. + * @param {string} request.etag + * The current etag of the + * {@link protos.google.cloud.gkemulticloud.v1.AwsCluster|AwsCluster}. + * + * Allows clients to perform deletions through optimistic concurrency control. + * + * If the provided etag does not match the current etag of the cluster, + * the request will fail and an ABORTED 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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/aws_clusters.delete_aws_cluster.js + * region_tag:gkemulticloud_v1_generated_AwsClusters_DeleteAwsCluster_async + * @deprecated DeleteAwsCluster is deprecated and may be removed in a future version. + */ deleteAwsCluster( - request?: protos.google.cloud.gkemulticloud.v1.IDeleteAwsClusterRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkemulticloud.v1.IDeleteAwsClusterRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteAwsCluster( - request: protos.google.cloud.gkemulticloud.v1.IDeleteAwsClusterRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IDeleteAwsClusterRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteAwsCluster( - request: protos.google.cloud.gkemulticloud.v1.IDeleteAwsClusterRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IDeleteAwsClusterRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteAwsCluster( - request?: protos.google.cloud.gkemulticloud.v1.IDeleteAwsClusterRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.gkemulticloud.v1.IDeleteAwsClusterRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkemulticloud.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}); - this.warn('DEP$AwsClusters-$DeleteAwsCluster','DeleteAwsCluster is deprecated and may be removed in a future version.', 'DeprecationWarning'); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + this.warn( + 'DEP$AwsClusters-$DeleteAwsCluster', + 'DeleteAwsCluster is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteAwsCluster response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteAwsCluster request %j', request); - return this.innerApiCalls.deleteAwsCluster(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteAwsCluster response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteAwsCluster(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteAwsCluster response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteAwsCluster()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/aws_clusters.delete_aws_cluster.js - * region_tag:gkemulticloud_v1_generated_AwsClusters_DeleteAwsCluster_async - * @deprecated DeleteAwsCluster is deprecated and may be removed in a future version. - */ - async checkDeleteAwsClusterProgress(name: string): Promise>{ - this.warn('DEP$AwsClusters-$checkDeleteAwsClusterProgress','checkDeleteAwsClusterProgress is deprecated and may be removed in a future version.', 'DeprecationWarning'); + /** + * Check the status of the long running operation returned by `deleteAwsCluster()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/aws_clusters.delete_aws_cluster.js + * region_tag:gkemulticloud_v1_generated_AwsClusters_DeleteAwsCluster_async + * @deprecated DeleteAwsCluster is deprecated and may be removed in a future version. + */ + async checkDeleteAwsClusterProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.gkemulticloud.v1.OperationMetadata + > + > { + this.warn( + 'DEP$AwsClusters-$checkDeleteAwsClusterProgress', + 'checkDeleteAwsClusterProgress is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); this._log.info('deleteAwsCluster long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteAwsCluster, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteAwsCluster, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.gkemulticloud.v1.OperationMetadata + >; } -/** - * Creates a new {@link protos.google.cloud.gkemulticloud.v1.AwsNodePool|AwsNodePool}, - * attached to a given {@link protos.google.cloud.gkemulticloud.v1.AwsCluster|AwsCluster}. - * - * If successful, the response contains a newly created - * {@link protos.google.longrunning.Operation|Operation} resource that can be - * described to track the status of the operation. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The {@link protos.google.cloud.gkemulticloud.v1.AwsCluster|AwsCluster} - * resource where this node pool will be created. - * - * `AwsCluster` names are formatted as - * `projects//locations//awsClusters/`. - * - * See [Resource Names](https://cloud.google.com/apis/design/resource_names) - * for more details on Google Cloud resource names. - * @param {google.cloud.gkemulticloud.v1.AwsNodePool} request.awsNodePool - * Required. The specification of the - * {@link protos.google.cloud.gkemulticloud.v1.AwsNodePool|AwsNodePool} to create. - * @param {string} request.awsNodePoolId - * Required. A client provided ID the resource. Must be unique within the - * parent resource. - * - * The provided ID will be part of the - * {@link protos.google.cloud.gkemulticloud.v1.AwsNodePool|AwsNodePool} resource name - * formatted as - * `projects//locations//awsClusters//awsNodePools/`. - * - * Valid characters are `/{@link protos.0-9|a-z}-/`. Cannot be longer than 63 characters. - * @param {boolean} request.validateOnly - * If set, only validate the request, but do not actually create the node - * pool. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/aws_clusters.create_aws_node_pool.js - * region_tag:gkemulticloud_v1_generated_AwsClusters_CreateAwsNodePool_async - * @deprecated CreateAwsNodePool is deprecated and may be removed in a future version. - */ + /** + * Creates a new {@link protos.google.cloud.gkemulticloud.v1.AwsNodePool|AwsNodePool}, + * attached to a given {@link protos.google.cloud.gkemulticloud.v1.AwsCluster|AwsCluster}. + * + * If successful, the response contains a newly created + * {@link protos.google.longrunning.Operation|Operation} resource that can be + * described to track the status of the operation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The {@link protos.google.cloud.gkemulticloud.v1.AwsCluster|AwsCluster} + * resource where this node pool will be created. + * + * `AwsCluster` names are formatted as + * `projects//locations//awsClusters/`. + * + * See [Resource Names](https://cloud.google.com/apis/design/resource_names) + * for more details on Google Cloud resource names. + * @param {google.cloud.gkemulticloud.v1.AwsNodePool} request.awsNodePool + * Required. The specification of the + * {@link protos.google.cloud.gkemulticloud.v1.AwsNodePool|AwsNodePool} to create. + * @param {string} request.awsNodePoolId + * Required. A client provided ID the resource. Must be unique within the + * parent resource. + * + * The provided ID will be part of the + * {@link protos.google.cloud.gkemulticloud.v1.AwsNodePool|AwsNodePool} resource name + * formatted as + * `projects//locations//awsClusters//awsNodePools/`. + * + * Valid characters are `/{@link protos.0-9|a-z}-/`. Cannot be longer than 63 characters. + * @param {boolean} request.validateOnly + * If set, only validate the request, but do not actually create the node + * pool. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/aws_clusters.create_aws_node_pool.js + * region_tag:gkemulticloud_v1_generated_AwsClusters_CreateAwsNodePool_async + * @deprecated CreateAwsNodePool is deprecated and may be removed in a future version. + */ createAwsNodePool( - request?: protos.google.cloud.gkemulticloud.v1.ICreateAwsNodePoolRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkemulticloud.v1.ICreateAwsNodePoolRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.gkemulticloud.v1.IAwsNodePool, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createAwsNodePool( - request: protos.google.cloud.gkemulticloud.v1.ICreateAwsNodePoolRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.ICreateAwsNodePoolRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAwsNodePool, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createAwsNodePool( - request: protos.google.cloud.gkemulticloud.v1.ICreateAwsNodePoolRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.ICreateAwsNodePoolRequest, + callback: Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAwsNodePool, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createAwsNodePool( - request?: protos.google.cloud.gkemulticloud.v1.ICreateAwsNodePoolRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.gkemulticloud.v1.ICreateAwsNodePoolRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAwsNodePool, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAwsNodePool, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.gkemulticloud.v1.IAwsNodePool, + protos.google.cloud.gkemulticloud.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}); - this.warn('DEP$AwsClusters-$CreateAwsNodePool','CreateAwsNodePool is deprecated and may be removed in a future version.', 'DeprecationWarning'); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + this.warn( + 'DEP$AwsClusters-$CreateAwsNodePool', + 'CreateAwsNodePool is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAwsNodePool, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createAwsNodePool response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createAwsNodePool request %j', request); - return this.innerApiCalls.createAwsNodePool(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createAwsNodePool response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createAwsNodePool(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.gkemulticloud.v1.IAwsNodePool, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createAwsNodePool response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createAwsNodePool()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/aws_clusters.create_aws_node_pool.js - * region_tag:gkemulticloud_v1_generated_AwsClusters_CreateAwsNodePool_async - * @deprecated CreateAwsNodePool is deprecated and may be removed in a future version. - */ - async checkCreateAwsNodePoolProgress(name: string): Promise>{ - this.warn('DEP$AwsClusters-$checkCreateAwsNodePoolProgress','checkCreateAwsNodePoolProgress is deprecated and may be removed in a future version.', 'DeprecationWarning'); + /** + * Check the status of the long running operation returned by `createAwsNodePool()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/aws_clusters.create_aws_node_pool.js + * region_tag:gkemulticloud_v1_generated_AwsClusters_CreateAwsNodePool_async + * @deprecated CreateAwsNodePool is deprecated and may be removed in a future version. + */ + async checkCreateAwsNodePoolProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.gkemulticloud.v1.AwsNodePool, + protos.google.cloud.gkemulticloud.v1.OperationMetadata + > + > { + this.warn( + 'DEP$AwsClusters-$checkCreateAwsNodePoolProgress', + 'checkCreateAwsNodePoolProgress is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); this._log.info('createAwsNodePool long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createAwsNodePool, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createAwsNodePool, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.gkemulticloud.v1.AwsNodePool, + protos.google.cloud.gkemulticloud.v1.OperationMetadata + >; } -/** - * Updates an {@link protos.google.cloud.gkemulticloud.v1.AwsNodePool|AwsNodePool}. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.gkemulticloud.v1.AwsNodePool} request.awsNodePool - * Required. The {@link protos.google.cloud.gkemulticloud.v1.AwsNodePool|AwsNodePool} - * resource to update. - * @param {boolean} request.validateOnly - * If set, only validate the request, but don't actually update the node pool. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. Mask of fields to update. At least one path must be supplied in - * this field. The elements of the repeated paths field can only include these - * fields from {@link protos.google.cloud.gkemulticloud.v1.AwsNodePool|AwsNodePool}: - * - * * `annotations`. - * * `version`. - * * `autoscaling.min_node_count`. - * * `autoscaling.max_node_count`. - * * `config.config_encryption.kms_key_arn`. - * * `config.security_group_ids`. - * * `config.root_volume.iops`. - * * `config.root_volume.throughput`. - * * `config.root_volume.kms_key_arn`. - * * `config.root_volume.volume_type`. - * * `config.root_volume.size_gib`. - * * `config.proxy_config`. - * * `config.proxy_config.secret_arn`. - * * `config.proxy_config.secret_version`. - * * `config.ssh_config`. - * * `config.ssh_config.ec2_key_pair`. - * * `config.instance_placement.tenancy`. - * * `config.iam_instance_profile`. - * * `config.labels`. - * * `config.tags`. - * * `config.autoscaling_metrics_collection`. - * * `config.autoscaling_metrics_collection.granularity`. - * * `config.autoscaling_metrics_collection.metrics`. - * * `config.instance_type`. - * * `management.auto_repair`. - * * `management`. - * * `update_settings`. - * * `update_settings.surge_settings`. - * * `update_settings.surge_settings.max_surge`. - * * `update_settings.surge_settings.max_unavailable`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/aws_clusters.update_aws_node_pool.js - * region_tag:gkemulticloud_v1_generated_AwsClusters_UpdateAwsNodePool_async - * @deprecated UpdateAwsNodePool is deprecated and may be removed in a future version. - */ + /** + * Updates an {@link protos.google.cloud.gkemulticloud.v1.AwsNodePool|AwsNodePool}. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.gkemulticloud.v1.AwsNodePool} request.awsNodePool + * Required. The {@link protos.google.cloud.gkemulticloud.v1.AwsNodePool|AwsNodePool} + * resource to update. + * @param {boolean} request.validateOnly + * If set, only validate the request, but don't actually update the node pool. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. Mask of fields to update. At least one path must be supplied in + * this field. The elements of the repeated paths field can only include these + * fields from {@link protos.google.cloud.gkemulticloud.v1.AwsNodePool|AwsNodePool}: + * + * * `annotations`. + * * `version`. + * * `autoscaling.min_node_count`. + * * `autoscaling.max_node_count`. + * * `config.config_encryption.kms_key_arn`. + * * `config.security_group_ids`. + * * `config.root_volume.iops`. + * * `config.root_volume.throughput`. + * * `config.root_volume.kms_key_arn`. + * * `config.root_volume.volume_type`. + * * `config.root_volume.size_gib`. + * * `config.proxy_config`. + * * `config.proxy_config.secret_arn`. + * * `config.proxy_config.secret_version`. + * * `config.ssh_config`. + * * `config.ssh_config.ec2_key_pair`. + * * `config.instance_placement.tenancy`. + * * `config.iam_instance_profile`. + * * `config.labels`. + * * `config.tags`. + * * `config.autoscaling_metrics_collection`. + * * `config.autoscaling_metrics_collection.granularity`. + * * `config.autoscaling_metrics_collection.metrics`. + * * `config.instance_type`. + * * `management.auto_repair`. + * * `management`. + * * `update_settings`. + * * `update_settings.surge_settings`. + * * `update_settings.surge_settings.max_surge`. + * * `update_settings.surge_settings.max_unavailable`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/aws_clusters.update_aws_node_pool.js + * region_tag:gkemulticloud_v1_generated_AwsClusters_UpdateAwsNodePool_async + * @deprecated UpdateAwsNodePool is deprecated and may be removed in a future version. + */ updateAwsNodePool( - request?: protos.google.cloud.gkemulticloud.v1.IUpdateAwsNodePoolRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkemulticloud.v1.IUpdateAwsNodePoolRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.gkemulticloud.v1.IAwsNodePool, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateAwsNodePool( - request: protos.google.cloud.gkemulticloud.v1.IUpdateAwsNodePoolRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IUpdateAwsNodePoolRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAwsNodePool, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateAwsNodePool( - request: protos.google.cloud.gkemulticloud.v1.IUpdateAwsNodePoolRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IUpdateAwsNodePoolRequest, + callback: Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAwsNodePool, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateAwsNodePool( - request?: protos.google.cloud.gkemulticloud.v1.IUpdateAwsNodePoolRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.gkemulticloud.v1.IUpdateAwsNodePoolRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAwsNodePool, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAwsNodePool, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.gkemulticloud.v1.IAwsNodePool, + protos.google.cloud.gkemulticloud.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({ - 'aws_node_pool.name': request.awsNodePool!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'aws_node_pool.name': request.awsNodePool!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - this.warn('DEP$AwsClusters-$UpdateAwsNodePool','UpdateAwsNodePool is deprecated and may be removed in a future version.', 'DeprecationWarning'); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + this.warn( + 'DEP$AwsClusters-$UpdateAwsNodePool', + 'UpdateAwsNodePool is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAwsNodePool, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateAwsNodePool response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateAwsNodePool request %j', request); - return this.innerApiCalls.updateAwsNodePool(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateAwsNodePool response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateAwsNodePool(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.gkemulticloud.v1.IAwsNodePool, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateAwsNodePool response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateAwsNodePool()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/aws_clusters.update_aws_node_pool.js - * region_tag:gkemulticloud_v1_generated_AwsClusters_UpdateAwsNodePool_async - * @deprecated UpdateAwsNodePool is deprecated and may be removed in a future version. - */ - async checkUpdateAwsNodePoolProgress(name: string): Promise>{ - this.warn('DEP$AwsClusters-$checkUpdateAwsNodePoolProgress','checkUpdateAwsNodePoolProgress is deprecated and may be removed in a future version.', 'DeprecationWarning'); + /** + * Check the status of the long running operation returned by `updateAwsNodePool()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/aws_clusters.update_aws_node_pool.js + * region_tag:gkemulticloud_v1_generated_AwsClusters_UpdateAwsNodePool_async + * @deprecated UpdateAwsNodePool is deprecated and may be removed in a future version. + */ + async checkUpdateAwsNodePoolProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.gkemulticloud.v1.AwsNodePool, + protos.google.cloud.gkemulticloud.v1.OperationMetadata + > + > { + this.warn( + 'DEP$AwsClusters-$checkUpdateAwsNodePoolProgress', + 'checkUpdateAwsNodePoolProgress is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); this._log.info('updateAwsNodePool long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.updateAwsNodePool, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateAwsNodePool, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.gkemulticloud.v1.AwsNodePool, + protos.google.cloud.gkemulticloud.v1.OperationMetadata + >; } -/** - * Rolls back a previously aborted or failed - * {@link protos.google.cloud.gkemulticloud.v1.AwsNodePool|AwsNodePool} update request. - * Makes no changes if the last update request successfully finished. - * If an update request is in progress, you cannot rollback the update. - * You must first cancel or let it finish unsuccessfully before you can - * rollback. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the - * {@link protos.google.cloud.gkemulticloud.v1.AwsNodePool|AwsNodePool} resource to - * rollback. - * - * `AwsNodePool` names are formatted as - * `projects//locations//awsClusters//awsNodePools/`. - * - * See [Resource Names](https://cloud.google.com/apis/design/resource_names) - * for more details on Google Cloud resource names. - * @param {boolean} [request.respectPdb] - * Optional. Option for rollback to ignore the PodDisruptionBudget when - * draining the node pool nodes. Default value is false. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/aws_clusters.rollback_aws_node_pool_update.js - * region_tag:gkemulticloud_v1_generated_AwsClusters_RollbackAwsNodePoolUpdate_async - * @deprecated RollbackAwsNodePoolUpdate is deprecated and may be removed in a future version. - */ + /** + * Rolls back a previously aborted or failed + * {@link protos.google.cloud.gkemulticloud.v1.AwsNodePool|AwsNodePool} update request. + * Makes no changes if the last update request successfully finished. + * If an update request is in progress, you cannot rollback the update. + * You must first cancel or let it finish unsuccessfully before you can + * rollback. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the + * {@link protos.google.cloud.gkemulticloud.v1.AwsNodePool|AwsNodePool} resource to + * rollback. + * + * `AwsNodePool` names are formatted as + * `projects//locations//awsClusters//awsNodePools/`. + * + * See [Resource Names](https://cloud.google.com/apis/design/resource_names) + * for more details on Google Cloud resource names. + * @param {boolean} [request.respectPdb] + * Optional. Option for rollback to ignore the PodDisruptionBudget when + * draining the node pool nodes. Default value is false. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/aws_clusters.rollback_aws_node_pool_update.js + * region_tag:gkemulticloud_v1_generated_AwsClusters_RollbackAwsNodePoolUpdate_async + * @deprecated RollbackAwsNodePoolUpdate is deprecated and may be removed in a future version. + */ rollbackAwsNodePoolUpdate( - request?: protos.google.cloud.gkemulticloud.v1.IRollbackAwsNodePoolUpdateRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkemulticloud.v1.IRollbackAwsNodePoolUpdateRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.gkemulticloud.v1.IAwsNodePool, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; rollbackAwsNodePoolUpdate( - request: protos.google.cloud.gkemulticloud.v1.IRollbackAwsNodePoolUpdateRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IRollbackAwsNodePoolUpdateRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAwsNodePool, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; rollbackAwsNodePoolUpdate( - request: protos.google.cloud.gkemulticloud.v1.IRollbackAwsNodePoolUpdateRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IRollbackAwsNodePoolUpdateRequest, + callback: Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAwsNodePool, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; rollbackAwsNodePoolUpdate( - request?: protos.google.cloud.gkemulticloud.v1.IRollbackAwsNodePoolUpdateRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.gkemulticloud.v1.IRollbackAwsNodePoolUpdateRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAwsNodePool, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAwsNodePool, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.gkemulticloud.v1.IAwsNodePool, + protos.google.cloud.gkemulticloud.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}); - this.warn('DEP$AwsClusters-$RollbackAwsNodePoolUpdate','RollbackAwsNodePoolUpdate is deprecated and may be removed in a future version.', 'DeprecationWarning'); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + this.warn( + 'DEP$AwsClusters-$RollbackAwsNodePoolUpdate', + 'RollbackAwsNodePoolUpdate is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAwsNodePool, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('rollbackAwsNodePoolUpdate response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('rollbackAwsNodePoolUpdate request %j', request); - return this.innerApiCalls.rollbackAwsNodePoolUpdate(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('rollbackAwsNodePoolUpdate response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .rollbackAwsNodePoolUpdate(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.gkemulticloud.v1.IAwsNodePool, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('rollbackAwsNodePoolUpdate response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `rollbackAwsNodePoolUpdate()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/aws_clusters.rollback_aws_node_pool_update.js - * region_tag:gkemulticloud_v1_generated_AwsClusters_RollbackAwsNodePoolUpdate_async - * @deprecated RollbackAwsNodePoolUpdate is deprecated and may be removed in a future version. - */ - async checkRollbackAwsNodePoolUpdateProgress(name: string): Promise>{ - this.warn('DEP$AwsClusters-$checkRollbackAwsNodePoolUpdateProgress','checkRollbackAwsNodePoolUpdateProgress is deprecated and may be removed in a future version.', 'DeprecationWarning'); + /** + * Check the status of the long running operation returned by `rollbackAwsNodePoolUpdate()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/aws_clusters.rollback_aws_node_pool_update.js + * region_tag:gkemulticloud_v1_generated_AwsClusters_RollbackAwsNodePoolUpdate_async + * @deprecated RollbackAwsNodePoolUpdate is deprecated and may be removed in a future version. + */ + async checkRollbackAwsNodePoolUpdateProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.gkemulticloud.v1.AwsNodePool, + protos.google.cloud.gkemulticloud.v1.OperationMetadata + > + > { + this.warn( + 'DEP$AwsClusters-$checkRollbackAwsNodePoolUpdateProgress', + 'checkRollbackAwsNodePoolUpdateProgress is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); this._log.info('rollbackAwsNodePoolUpdate long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.rollbackAwsNodePoolUpdate, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.rollbackAwsNodePoolUpdate, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.gkemulticloud.v1.AwsNodePool, + protos.google.cloud.gkemulticloud.v1.OperationMetadata + >; } -/** - * Deletes a specific {@link protos.google.cloud.gkemulticloud.v1.AwsNodePool|AwsNodePool} - * resource. - * - * If successful, the response contains a newly created - * {@link protos.google.longrunning.Operation|Operation} resource that can be - * described to track the status of the operation. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name the - * {@link protos.google.cloud.gkemulticloud.v1.AwsNodePool|AwsNodePool} to delete. - * - * `AwsNodePool` names are formatted as - * `projects//locations//awsClusters//awsNodePools/`. - * - * See [Resource Names](https://cloud.google.com/apis/design/resource_names) - * for more details on Google Cloud resource names. - * @param {boolean} request.validateOnly - * If set, only validate the request, but do not actually delete the node - * pool. - * @param {boolean} request.allowMissing - * If set to true, and the - * {@link protos.google.cloud.gkemulticloud.v1.AwsNodePool|AwsNodePool} resource is not - * found, the request will succeed but no action will be taken on the server - * and a completed {@link protos.google.longrunning.Operation|Operation} will be returned. - * - * Useful for idempotent deletion. - * @param {boolean} [request.ignoreErrors] - * Optional. If set to true, the deletion of - * {@link protos.google.cloud.gkemulticloud.v1.AwsNodePool|AwsNodePool} resource will - * succeed even if errors occur during deleting in node pool resources. Using - * this parameter may result in orphaned resources in the node pool. - * @param {string} request.etag - * The current ETag of the - * {@link protos.google.cloud.gkemulticloud.v1.AwsNodePool|AwsNodePool}. - * - * Allows clients to perform deletions through optimistic concurrency control. - * - * If the provided ETag does not match the current etag of the node pool, - * the request will fail and an ABORTED 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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/aws_clusters.delete_aws_node_pool.js - * region_tag:gkemulticloud_v1_generated_AwsClusters_DeleteAwsNodePool_async - * @deprecated DeleteAwsNodePool is deprecated and may be removed in a future version. - */ + /** + * Deletes a specific {@link protos.google.cloud.gkemulticloud.v1.AwsNodePool|AwsNodePool} + * resource. + * + * If successful, the response contains a newly created + * {@link protos.google.longrunning.Operation|Operation} resource that can be + * described to track the status of the operation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name the + * {@link protos.google.cloud.gkemulticloud.v1.AwsNodePool|AwsNodePool} to delete. + * + * `AwsNodePool` names are formatted as + * `projects//locations//awsClusters//awsNodePools/`. + * + * See [Resource Names](https://cloud.google.com/apis/design/resource_names) + * for more details on Google Cloud resource names. + * @param {boolean} request.validateOnly + * If set, only validate the request, but do not actually delete the node + * pool. + * @param {boolean} request.allowMissing + * If set to true, and the + * {@link protos.google.cloud.gkemulticloud.v1.AwsNodePool|AwsNodePool} resource is not + * found, the request will succeed but no action will be taken on the server + * and a completed {@link protos.google.longrunning.Operation|Operation} will be returned. + * + * Useful for idempotent deletion. + * @param {boolean} [request.ignoreErrors] + * Optional. If set to true, the deletion of + * {@link protos.google.cloud.gkemulticloud.v1.AwsNodePool|AwsNodePool} resource will + * succeed even if errors occur during deleting in node pool resources. Using + * this parameter may result in orphaned resources in the node pool. + * @param {string} request.etag + * The current ETag of the + * {@link protos.google.cloud.gkemulticloud.v1.AwsNodePool|AwsNodePool}. + * + * Allows clients to perform deletions through optimistic concurrency control. + * + * If the provided ETag does not match the current etag of the node pool, + * the request will fail and an ABORTED 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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/aws_clusters.delete_aws_node_pool.js + * region_tag:gkemulticloud_v1_generated_AwsClusters_DeleteAwsNodePool_async + * @deprecated DeleteAwsNodePool is deprecated and may be removed in a future version. + */ deleteAwsNodePool( - request?: protos.google.cloud.gkemulticloud.v1.IDeleteAwsNodePoolRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkemulticloud.v1.IDeleteAwsNodePoolRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteAwsNodePool( - request: protos.google.cloud.gkemulticloud.v1.IDeleteAwsNodePoolRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IDeleteAwsNodePoolRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteAwsNodePool( - request: protos.google.cloud.gkemulticloud.v1.IDeleteAwsNodePoolRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IDeleteAwsNodePoolRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteAwsNodePool( - request?: protos.google.cloud.gkemulticloud.v1.IDeleteAwsNodePoolRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.gkemulticloud.v1.IDeleteAwsNodePoolRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkemulticloud.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}); - this.warn('DEP$AwsClusters-$DeleteAwsNodePool','DeleteAwsNodePool is deprecated and may be removed in a future version.', 'DeprecationWarning'); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + this.warn( + 'DEP$AwsClusters-$DeleteAwsNodePool', + 'DeleteAwsNodePool is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteAwsNodePool response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteAwsNodePool request %j', request); - return this.innerApiCalls.deleteAwsNodePool(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteAwsNodePool response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteAwsNodePool(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteAwsNodePool response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteAwsNodePool()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/aws_clusters.delete_aws_node_pool.js - * region_tag:gkemulticloud_v1_generated_AwsClusters_DeleteAwsNodePool_async - * @deprecated DeleteAwsNodePool is deprecated and may be removed in a future version. - */ - async checkDeleteAwsNodePoolProgress(name: string): Promise>{ - this.warn('DEP$AwsClusters-$checkDeleteAwsNodePoolProgress','checkDeleteAwsNodePoolProgress is deprecated and may be removed in a future version.', 'DeprecationWarning'); + /** + * Check the status of the long running operation returned by `deleteAwsNodePool()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/aws_clusters.delete_aws_node_pool.js + * region_tag:gkemulticloud_v1_generated_AwsClusters_DeleteAwsNodePool_async + * @deprecated DeleteAwsNodePool is deprecated and may be removed in a future version. + */ + async checkDeleteAwsNodePoolProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.gkemulticloud.v1.OperationMetadata + > + > { + this.warn( + 'DEP$AwsClusters-$checkDeleteAwsNodePoolProgress', + 'checkDeleteAwsNodePoolProgress is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); this._log.info('deleteAwsNodePool long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteAwsNodePool, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists all {@link protos.google.cloud.gkemulticloud.v1.AwsCluster|AwsCluster} resources - * on a given Google Cloud project and region. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent location which owns this collection of - * {@link protos.google.cloud.gkemulticloud.v1.AwsCluster|AwsCluster} resources. - * - * Location names are formatted as `projects//locations/`. - * - * See [Resource Names](https://cloud.google.com/apis/design/resource_names) - * for more details on Google Cloud Platform resource names. - * @param {number} request.pageSize - * The maximum number of items to return. - * - * If not specified, a default value of 50 will be used by the service. - * Regardless of the pageSize value, the response can include a partial list - * and a caller should only rely on response's - * {@link protos.google.cloud.gkemulticloud.v1.ListAwsClustersResponse.next_page_token|nextPageToken} - * to determine if there are more instances left to be queried. - * @param {string} request.pageToken - * The `nextPageToken` value returned from a previous - * {@link protos.google.cloud.gkemulticloud.v1.AwsClusters.ListAwsClusters|awsClusters.list} - * request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link protos.google.cloud.gkemulticloud.v1.AwsCluster|AwsCluster}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listAwsClustersAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @deprecated ListAwsClusters is deprecated and may be removed in a future version. - */ + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteAwsNodePool, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.gkemulticloud.v1.OperationMetadata + >; + } + /** + * Lists all {@link protos.google.cloud.gkemulticloud.v1.AwsCluster|AwsCluster} resources + * on a given Google Cloud project and region. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent location which owns this collection of + * {@link protos.google.cloud.gkemulticloud.v1.AwsCluster|AwsCluster} resources. + * + * Location names are formatted as `projects//locations/`. + * + * See [Resource Names](https://cloud.google.com/apis/design/resource_names) + * for more details on Google Cloud Platform resource names. + * @param {number} request.pageSize + * The maximum number of items to return. + * + * If not specified, a default value of 50 will be used by the service. + * Regardless of the pageSize value, the response can include a partial list + * and a caller should only rely on response's + * {@link protos.google.cloud.gkemulticloud.v1.ListAwsClustersResponse.next_page_token|nextPageToken} + * to determine if there are more instances left to be queried. + * @param {string} request.pageToken + * The `nextPageToken` value returned from a previous + * {@link protos.google.cloud.gkemulticloud.v1.AwsClusters.ListAwsClusters|awsClusters.list} + * request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.gkemulticloud.v1.AwsCluster|AwsCluster}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listAwsClustersAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @deprecated ListAwsClusters is deprecated and may be removed in a future version. + */ listAwsClusters( - request?: protos.google.cloud.gkemulticloud.v1.IListAwsClustersRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gkemulticloud.v1.IAwsCluster[], - protos.google.cloud.gkemulticloud.v1.IListAwsClustersRequest|null, - protos.google.cloud.gkemulticloud.v1.IListAwsClustersResponse - ]>; + request?: protos.google.cloud.gkemulticloud.v1.IListAwsClustersRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gkemulticloud.v1.IAwsCluster[], + protos.google.cloud.gkemulticloud.v1.IListAwsClustersRequest | null, + protos.google.cloud.gkemulticloud.v1.IListAwsClustersResponse, + ] + >; listAwsClusters( - request: protos.google.cloud.gkemulticloud.v1.IListAwsClustersRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.gkemulticloud.v1.IListAwsClustersRequest, - protos.google.cloud.gkemulticloud.v1.IListAwsClustersResponse|null|undefined, - protos.google.cloud.gkemulticloud.v1.IAwsCluster>): void; + request: protos.google.cloud.gkemulticloud.v1.IListAwsClustersRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.gkemulticloud.v1.IListAwsClustersRequest, + | protos.google.cloud.gkemulticloud.v1.IListAwsClustersResponse + | null + | undefined, + protos.google.cloud.gkemulticloud.v1.IAwsCluster + >, + ): void; listAwsClusters( - request: protos.google.cloud.gkemulticloud.v1.IListAwsClustersRequest, - callback: PaginationCallback< - protos.google.cloud.gkemulticloud.v1.IListAwsClustersRequest, - protos.google.cloud.gkemulticloud.v1.IListAwsClustersResponse|null|undefined, - protos.google.cloud.gkemulticloud.v1.IAwsCluster>): void; + request: protos.google.cloud.gkemulticloud.v1.IListAwsClustersRequest, + callback: PaginationCallback< + protos.google.cloud.gkemulticloud.v1.IListAwsClustersRequest, + | protos.google.cloud.gkemulticloud.v1.IListAwsClustersResponse + | null + | undefined, + protos.google.cloud.gkemulticloud.v1.IAwsCluster + >, + ): void; listAwsClusters( - request?: protos.google.cloud.gkemulticloud.v1.IListAwsClustersRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.gkemulticloud.v1.IListAwsClustersRequest, - protos.google.cloud.gkemulticloud.v1.IListAwsClustersResponse|null|undefined, - protos.google.cloud.gkemulticloud.v1.IAwsCluster>, - callback?: PaginationCallback< + request?: protos.google.cloud.gkemulticloud.v1.IListAwsClustersRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.gkemulticloud.v1.IListAwsClustersRequest, - protos.google.cloud.gkemulticloud.v1.IListAwsClustersResponse|null|undefined, - protos.google.cloud.gkemulticloud.v1.IAwsCluster>): - Promise<[ - protos.google.cloud.gkemulticloud.v1.IAwsCluster[], - protos.google.cloud.gkemulticloud.v1.IListAwsClustersRequest|null, - protos.google.cloud.gkemulticloud.v1.IListAwsClustersResponse - ]>|void { + | protos.google.cloud.gkemulticloud.v1.IListAwsClustersResponse + | null + | undefined, + protos.google.cloud.gkemulticloud.v1.IAwsCluster + >, + callback?: PaginationCallback< + protos.google.cloud.gkemulticloud.v1.IListAwsClustersRequest, + | protos.google.cloud.gkemulticloud.v1.IListAwsClustersResponse + | null + | undefined, + protos.google.cloud.gkemulticloud.v1.IAwsCluster + >, + ): Promise< + [ + protos.google.cloud.gkemulticloud.v1.IAwsCluster[], + protos.google.cloud.gkemulticloud.v1.IListAwsClustersRequest | null, + protos.google.cloud.gkemulticloud.v1.IListAwsClustersResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.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.warn('DEP$AwsClusters-$ListAwsClusters','ListAwsClusters is deprecated and may be removed in a future version.', 'DeprecationWarning'); - const wrappedCallback: PaginationCallback< - protos.google.cloud.gkemulticloud.v1.IListAwsClustersRequest, - protos.google.cloud.gkemulticloud.v1.IListAwsClustersResponse|null|undefined, - protos.google.cloud.gkemulticloud.v1.IAwsCluster>|undefined = callback + this.warn( + 'DEP$AwsClusters-$ListAwsClusters', + 'ListAwsClusters is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.gkemulticloud.v1.IListAwsClustersRequest, + | protos.google.cloud.gkemulticloud.v1.IListAwsClustersResponse + | null + | undefined, + protos.google.cloud.gkemulticloud.v1.IAwsCluster + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listAwsClusters values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -2279,240 +3279,281 @@ export class AwsClustersClient { this._log.info('listAwsClusters request %j', request); return this.innerApiCalls .listAwsClusters(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.gkemulticloud.v1.IAwsCluster[], - protos.google.cloud.gkemulticloud.v1.IListAwsClustersRequest|null, - protos.google.cloud.gkemulticloud.v1.IListAwsClustersResponse - ]) => { - this._log.info('listAwsClusters values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.gkemulticloud.v1.IAwsCluster[], + protos.google.cloud.gkemulticloud.v1.IListAwsClustersRequest | null, + protos.google.cloud.gkemulticloud.v1.IListAwsClustersResponse, + ]) => { + this._log.info('listAwsClusters values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listAwsClusters`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent location which owns this collection of - * {@link protos.google.cloud.gkemulticloud.v1.AwsCluster|AwsCluster} resources. - * - * Location names are formatted as `projects//locations/`. - * - * See [Resource Names](https://cloud.google.com/apis/design/resource_names) - * for more details on Google Cloud Platform resource names. - * @param {number} request.pageSize - * The maximum number of items to return. - * - * If not specified, a default value of 50 will be used by the service. - * Regardless of the pageSize value, the response can include a partial list - * and a caller should only rely on response's - * {@link protos.google.cloud.gkemulticloud.v1.ListAwsClustersResponse.next_page_token|nextPageToken} - * to determine if there are more instances left to be queried. - * @param {string} request.pageToken - * The `nextPageToken` value returned from a previous - * {@link protos.google.cloud.gkemulticloud.v1.AwsClusters.ListAwsClusters|awsClusters.list} - * request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.gkemulticloud.v1.AwsCluster|AwsCluster} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listAwsClustersAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @deprecated ListAwsClusters is deprecated and may be removed in a future version. - */ + /** + * Equivalent to `listAwsClusters`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent location which owns this collection of + * {@link protos.google.cloud.gkemulticloud.v1.AwsCluster|AwsCluster} resources. + * + * Location names are formatted as `projects//locations/`. + * + * See [Resource Names](https://cloud.google.com/apis/design/resource_names) + * for more details on Google Cloud Platform resource names. + * @param {number} request.pageSize + * The maximum number of items to return. + * + * If not specified, a default value of 50 will be used by the service. + * Regardless of the pageSize value, the response can include a partial list + * and a caller should only rely on response's + * {@link protos.google.cloud.gkemulticloud.v1.ListAwsClustersResponse.next_page_token|nextPageToken} + * to determine if there are more instances left to be queried. + * @param {string} request.pageToken + * The `nextPageToken` value returned from a previous + * {@link protos.google.cloud.gkemulticloud.v1.AwsClusters.ListAwsClusters|awsClusters.list} + * request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.gkemulticloud.v1.AwsCluster|AwsCluster} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listAwsClustersAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @deprecated ListAwsClusters is deprecated and may be removed in a future version. + */ listAwsClustersStream( - request?: protos.google.cloud.gkemulticloud.v1.IListAwsClustersRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.gkemulticloud.v1.IListAwsClustersRequest, + 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['listAwsClusters']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); - this.warn('DEP$AwsClusters-$ListAwsClusters','ListAwsClusters is deprecated and may be removed in a future version.', 'DeprecationWarning'); + this.initialize().catch((err) => { + throw err; + }); + this.warn( + 'DEP$AwsClusters-$ListAwsClusters', + 'ListAwsClusters is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); this._log.info('listAwsClusters stream %j', request); return this.descriptors.page.listAwsClusters.createStream( this.innerApiCalls.listAwsClusters as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listAwsClusters`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used 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 location which owns this collection of - * {@link protos.google.cloud.gkemulticloud.v1.AwsCluster|AwsCluster} resources. - * - * Location names are formatted as `projects//locations/`. - * - * See [Resource Names](https://cloud.google.com/apis/design/resource_names) - * for more details on Google Cloud Platform resource names. - * @param {number} request.pageSize - * The maximum number of items to return. - * - * If not specified, a default value of 50 will be used by the service. - * Regardless of the pageSize value, the response can include a partial list - * and a caller should only rely on response's - * {@link protos.google.cloud.gkemulticloud.v1.ListAwsClustersResponse.next_page_token|nextPageToken} - * to determine if there are more instances left to be queried. - * @param {string} request.pageToken - * The `nextPageToken` value returned from a previous - * {@link protos.google.cloud.gkemulticloud.v1.AwsClusters.ListAwsClusters|awsClusters.list} - * request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.gkemulticloud.v1.AwsCluster|AwsCluster}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@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/aws_clusters.list_aws_clusters.js - * region_tag:gkemulticloud_v1_generated_AwsClusters_ListAwsClusters_async - * @deprecated ListAwsClusters is deprecated and may be removed in a future version. - */ + /** + * Equivalent to `listAwsClusters`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used 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 location which owns this collection of + * {@link protos.google.cloud.gkemulticloud.v1.AwsCluster|AwsCluster} resources. + * + * Location names are formatted as `projects//locations/`. + * + * See [Resource Names](https://cloud.google.com/apis/design/resource_names) + * for more details on Google Cloud Platform resource names. + * @param {number} request.pageSize + * The maximum number of items to return. + * + * If not specified, a default value of 50 will be used by the service. + * Regardless of the pageSize value, the response can include a partial list + * and a caller should only rely on response's + * {@link protos.google.cloud.gkemulticloud.v1.ListAwsClustersResponse.next_page_token|nextPageToken} + * to determine if there are more instances left to be queried. + * @param {string} request.pageToken + * The `nextPageToken` value returned from a previous + * {@link protos.google.cloud.gkemulticloud.v1.AwsClusters.ListAwsClusters|awsClusters.list} + * request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.gkemulticloud.v1.AwsCluster|AwsCluster}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@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/aws_clusters.list_aws_clusters.js + * region_tag:gkemulticloud_v1_generated_AwsClusters_ListAwsClusters_async + * @deprecated ListAwsClusters is deprecated and may be removed in a future version. + */ listAwsClustersAsync( - request?: protos.google.cloud.gkemulticloud.v1.IListAwsClustersRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.gkemulticloud.v1.IListAwsClustersRequest, + 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['listAwsClusters']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); - this.warn('DEP$AwsClusters-$ListAwsClusters','ListAwsClusters is deprecated and may be removed in a future version.', 'DeprecationWarning'); + this.initialize().catch((err) => { + throw err; + }); + this.warn( + 'DEP$AwsClusters-$ListAwsClusters', + 'ListAwsClusters is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); this._log.info('listAwsClusters iterate %j', request); return this.descriptors.page.listAwsClusters.asyncIterate( this.innerApiCalls['listAwsClusters'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists all {@link protos.google.cloud.gkemulticloud.v1.AwsNodePool|AwsNodePool} - * resources on a given - * {@link protos.google.cloud.gkemulticloud.v1.AwsCluster|AwsCluster}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent `AwsCluster` which owns this collection of - * {@link protos.google.cloud.gkemulticloud.v1.AwsNodePool|AwsNodePool} resources. - * - * `AwsCluster` names are formatted as - * `projects//locations//awsClusters/`. - * - * See [Resource Names](https://cloud.google.com/apis/design/resource_names) - * for more details on Google Cloud resource names. - * @param {number} request.pageSize - * The maximum number of items to return. - * - * If not specified, a default value of 50 will be used by the service. - * Regardless of the pageSize value, the response can include a partial list - * and a caller should only rely on response's - * {@link protos.google.cloud.gkemulticloud.v1.ListAwsNodePoolsResponse.next_page_token|nextPageToken} - * to determine if there are more instances left to be queried. - * @param {string} request.pageToken - * The `nextPageToken` value returned from a previous - * {@link protos.google.cloud.gkemulticloud.v1.AwsClusters.ListAwsNodePools|awsNodePools.list} - * request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link protos.google.cloud.gkemulticloud.v1.AwsNodePool|AwsNodePool}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listAwsNodePoolsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @deprecated ListAwsNodePools is deprecated and may be removed in a future version. - */ + /** + * Lists all {@link protos.google.cloud.gkemulticloud.v1.AwsNodePool|AwsNodePool} + * resources on a given + * {@link protos.google.cloud.gkemulticloud.v1.AwsCluster|AwsCluster}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent `AwsCluster` which owns this collection of + * {@link protos.google.cloud.gkemulticloud.v1.AwsNodePool|AwsNodePool} resources. + * + * `AwsCluster` names are formatted as + * `projects//locations//awsClusters/`. + * + * See [Resource Names](https://cloud.google.com/apis/design/resource_names) + * for more details on Google Cloud resource names. + * @param {number} request.pageSize + * The maximum number of items to return. + * + * If not specified, a default value of 50 will be used by the service. + * Regardless of the pageSize value, the response can include a partial list + * and a caller should only rely on response's + * {@link protos.google.cloud.gkemulticloud.v1.ListAwsNodePoolsResponse.next_page_token|nextPageToken} + * to determine if there are more instances left to be queried. + * @param {string} request.pageToken + * The `nextPageToken` value returned from a previous + * {@link protos.google.cloud.gkemulticloud.v1.AwsClusters.ListAwsNodePools|awsNodePools.list} + * request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.gkemulticloud.v1.AwsNodePool|AwsNodePool}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listAwsNodePoolsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @deprecated ListAwsNodePools is deprecated and may be removed in a future version. + */ listAwsNodePools( - request?: protos.google.cloud.gkemulticloud.v1.IListAwsNodePoolsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gkemulticloud.v1.IAwsNodePool[], - protos.google.cloud.gkemulticloud.v1.IListAwsNodePoolsRequest|null, - protos.google.cloud.gkemulticloud.v1.IListAwsNodePoolsResponse - ]>; + request?: protos.google.cloud.gkemulticloud.v1.IListAwsNodePoolsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gkemulticloud.v1.IAwsNodePool[], + protos.google.cloud.gkemulticloud.v1.IListAwsNodePoolsRequest | null, + protos.google.cloud.gkemulticloud.v1.IListAwsNodePoolsResponse, + ] + >; listAwsNodePools( - request: protos.google.cloud.gkemulticloud.v1.IListAwsNodePoolsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.gkemulticloud.v1.IListAwsNodePoolsRequest, - protos.google.cloud.gkemulticloud.v1.IListAwsNodePoolsResponse|null|undefined, - protos.google.cloud.gkemulticloud.v1.IAwsNodePool>): void; + request: protos.google.cloud.gkemulticloud.v1.IListAwsNodePoolsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.gkemulticloud.v1.IListAwsNodePoolsRequest, + | protos.google.cloud.gkemulticloud.v1.IListAwsNodePoolsResponse + | null + | undefined, + protos.google.cloud.gkemulticloud.v1.IAwsNodePool + >, + ): void; listAwsNodePools( - request: protos.google.cloud.gkemulticloud.v1.IListAwsNodePoolsRequest, - callback: PaginationCallback< - protos.google.cloud.gkemulticloud.v1.IListAwsNodePoolsRequest, - protos.google.cloud.gkemulticloud.v1.IListAwsNodePoolsResponse|null|undefined, - protos.google.cloud.gkemulticloud.v1.IAwsNodePool>): void; + request: protos.google.cloud.gkemulticloud.v1.IListAwsNodePoolsRequest, + callback: PaginationCallback< + protos.google.cloud.gkemulticloud.v1.IListAwsNodePoolsRequest, + | protos.google.cloud.gkemulticloud.v1.IListAwsNodePoolsResponse + | null + | undefined, + protos.google.cloud.gkemulticloud.v1.IAwsNodePool + >, + ): void; listAwsNodePools( - request?: protos.google.cloud.gkemulticloud.v1.IListAwsNodePoolsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.gkemulticloud.v1.IListAwsNodePoolsRequest, - protos.google.cloud.gkemulticloud.v1.IListAwsNodePoolsResponse|null|undefined, - protos.google.cloud.gkemulticloud.v1.IAwsNodePool>, - callback?: PaginationCallback< + request?: protos.google.cloud.gkemulticloud.v1.IListAwsNodePoolsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.gkemulticloud.v1.IListAwsNodePoolsRequest, - protos.google.cloud.gkemulticloud.v1.IListAwsNodePoolsResponse|null|undefined, - protos.google.cloud.gkemulticloud.v1.IAwsNodePool>): - Promise<[ - protos.google.cloud.gkemulticloud.v1.IAwsNodePool[], - protos.google.cloud.gkemulticloud.v1.IListAwsNodePoolsRequest|null, - protos.google.cloud.gkemulticloud.v1.IListAwsNodePoolsResponse - ]>|void { + | protos.google.cloud.gkemulticloud.v1.IListAwsNodePoolsResponse + | null + | undefined, + protos.google.cloud.gkemulticloud.v1.IAwsNodePool + >, + callback?: PaginationCallback< + protos.google.cloud.gkemulticloud.v1.IListAwsNodePoolsRequest, + | protos.google.cloud.gkemulticloud.v1.IListAwsNodePoolsResponse + | null + | undefined, + protos.google.cloud.gkemulticloud.v1.IAwsNodePool + >, + ): Promise< + [ + protos.google.cloud.gkemulticloud.v1.IAwsNodePool[], + protos.google.cloud.gkemulticloud.v1.IListAwsNodePoolsRequest | null, + protos.google.cloud.gkemulticloud.v1.IListAwsNodePoolsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.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.warn('DEP$AwsClusters-$ListAwsNodePools','ListAwsNodePools is deprecated and may be removed in a future version.', 'DeprecationWarning'); - const wrappedCallback: PaginationCallback< - protos.google.cloud.gkemulticloud.v1.IListAwsNodePoolsRequest, - protos.google.cloud.gkemulticloud.v1.IListAwsNodePoolsResponse|null|undefined, - protos.google.cloud.gkemulticloud.v1.IAwsNodePool>|undefined = callback + this.warn( + 'DEP$AwsClusters-$ListAwsNodePools', + 'ListAwsNodePools is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.gkemulticloud.v1.IListAwsNodePoolsRequest, + | protos.google.cloud.gkemulticloud.v1.IListAwsNodePoolsResponse + | null + | undefined, + protos.google.cloud.gkemulticloud.v1.IAwsNodePool + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listAwsNodePools values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -2521,143 +3562,155 @@ export class AwsClustersClient { this._log.info('listAwsNodePools request %j', request); return this.innerApiCalls .listAwsNodePools(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.gkemulticloud.v1.IAwsNodePool[], - protos.google.cloud.gkemulticloud.v1.IListAwsNodePoolsRequest|null, - protos.google.cloud.gkemulticloud.v1.IListAwsNodePoolsResponse - ]) => { - this._log.info('listAwsNodePools values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.gkemulticloud.v1.IAwsNodePool[], + protos.google.cloud.gkemulticloud.v1.IListAwsNodePoolsRequest | null, + protos.google.cloud.gkemulticloud.v1.IListAwsNodePoolsResponse, + ]) => { + this._log.info('listAwsNodePools values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listAwsNodePools`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent `AwsCluster` which owns this collection of - * {@link protos.google.cloud.gkemulticloud.v1.AwsNodePool|AwsNodePool} resources. - * - * `AwsCluster` names are formatted as - * `projects//locations//awsClusters/`. - * - * See [Resource Names](https://cloud.google.com/apis/design/resource_names) - * for more details on Google Cloud resource names. - * @param {number} request.pageSize - * The maximum number of items to return. - * - * If not specified, a default value of 50 will be used by the service. - * Regardless of the pageSize value, the response can include a partial list - * and a caller should only rely on response's - * {@link protos.google.cloud.gkemulticloud.v1.ListAwsNodePoolsResponse.next_page_token|nextPageToken} - * to determine if there are more instances left to be queried. - * @param {string} request.pageToken - * The `nextPageToken` value returned from a previous - * {@link protos.google.cloud.gkemulticloud.v1.AwsClusters.ListAwsNodePools|awsNodePools.list} - * request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.gkemulticloud.v1.AwsNodePool|AwsNodePool} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listAwsNodePoolsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @deprecated ListAwsNodePools is deprecated and may be removed in a future version. - */ + /** + * Equivalent to `listAwsNodePools`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent `AwsCluster` which owns this collection of + * {@link protos.google.cloud.gkemulticloud.v1.AwsNodePool|AwsNodePool} resources. + * + * `AwsCluster` names are formatted as + * `projects//locations//awsClusters/`. + * + * See [Resource Names](https://cloud.google.com/apis/design/resource_names) + * for more details on Google Cloud resource names. + * @param {number} request.pageSize + * The maximum number of items to return. + * + * If not specified, a default value of 50 will be used by the service. + * Regardless of the pageSize value, the response can include a partial list + * and a caller should only rely on response's + * {@link protos.google.cloud.gkemulticloud.v1.ListAwsNodePoolsResponse.next_page_token|nextPageToken} + * to determine if there are more instances left to be queried. + * @param {string} request.pageToken + * The `nextPageToken` value returned from a previous + * {@link protos.google.cloud.gkemulticloud.v1.AwsClusters.ListAwsNodePools|awsNodePools.list} + * request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.gkemulticloud.v1.AwsNodePool|AwsNodePool} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listAwsNodePoolsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @deprecated ListAwsNodePools is deprecated and may be removed in a future version. + */ listAwsNodePoolsStream( - request?: protos.google.cloud.gkemulticloud.v1.IListAwsNodePoolsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.gkemulticloud.v1.IListAwsNodePoolsRequest, + 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['listAwsNodePools']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); - this.warn('DEP$AwsClusters-$ListAwsNodePools','ListAwsNodePools is deprecated and may be removed in a future version.', 'DeprecationWarning'); + this.initialize().catch((err) => { + throw err; + }); + this.warn( + 'DEP$AwsClusters-$ListAwsNodePools', + 'ListAwsNodePools is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); this._log.info('listAwsNodePools stream %j', request); return this.descriptors.page.listAwsNodePools.createStream( this.innerApiCalls.listAwsNodePools as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listAwsNodePools`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used 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 `AwsCluster` which owns this collection of - * {@link protos.google.cloud.gkemulticloud.v1.AwsNodePool|AwsNodePool} resources. - * - * `AwsCluster` names are formatted as - * `projects//locations//awsClusters/`. - * - * See [Resource Names](https://cloud.google.com/apis/design/resource_names) - * for more details on Google Cloud resource names. - * @param {number} request.pageSize - * The maximum number of items to return. - * - * If not specified, a default value of 50 will be used by the service. - * Regardless of the pageSize value, the response can include a partial list - * and a caller should only rely on response's - * {@link protos.google.cloud.gkemulticloud.v1.ListAwsNodePoolsResponse.next_page_token|nextPageToken} - * to determine if there are more instances left to be queried. - * @param {string} request.pageToken - * The `nextPageToken` value returned from a previous - * {@link protos.google.cloud.gkemulticloud.v1.AwsClusters.ListAwsNodePools|awsNodePools.list} - * request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.gkemulticloud.v1.AwsNodePool|AwsNodePool}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@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/aws_clusters.list_aws_node_pools.js - * region_tag:gkemulticloud_v1_generated_AwsClusters_ListAwsNodePools_async - * @deprecated ListAwsNodePools is deprecated and may be removed in a future version. - */ + /** + * Equivalent to `listAwsNodePools`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used 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 `AwsCluster` which owns this collection of + * {@link protos.google.cloud.gkemulticloud.v1.AwsNodePool|AwsNodePool} resources. + * + * `AwsCluster` names are formatted as + * `projects//locations//awsClusters/`. + * + * See [Resource Names](https://cloud.google.com/apis/design/resource_names) + * for more details on Google Cloud resource names. + * @param {number} request.pageSize + * The maximum number of items to return. + * + * If not specified, a default value of 50 will be used by the service. + * Regardless of the pageSize value, the response can include a partial list + * and a caller should only rely on response's + * {@link protos.google.cloud.gkemulticloud.v1.ListAwsNodePoolsResponse.next_page_token|nextPageToken} + * to determine if there are more instances left to be queried. + * @param {string} request.pageToken + * The `nextPageToken` value returned from a previous + * {@link protos.google.cloud.gkemulticloud.v1.AwsClusters.ListAwsNodePools|awsNodePools.list} + * request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.gkemulticloud.v1.AwsNodePool|AwsNodePool}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@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/aws_clusters.list_aws_node_pools.js + * region_tag:gkemulticloud_v1_generated_AwsClusters_ListAwsNodePools_async + * @deprecated ListAwsNodePools is deprecated and may be removed in a future version. + */ listAwsNodePoolsAsync( - request?: protos.google.cloud.gkemulticloud.v1.IListAwsNodePoolsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.gkemulticloud.v1.IListAwsNodePoolsRequest, + 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['listAwsNodePools']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); - this.warn('DEP$AwsClusters-$ListAwsNodePools','ListAwsNodePools is deprecated and may be removed in a future version.', 'DeprecationWarning'); + this.initialize().catch((err) => { + throw err; + }); + this.warn( + 'DEP$AwsClusters-$ListAwsNodePools', + 'ListAwsNodePools is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); this._log.info('listAwsNodePools iterate %j', request); return this.descriptors.page.listAwsNodePools.asyncIterate( this.innerApiCalls['listAwsNodePools'] 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. @@ -2700,22 +3753,22 @@ export class AwsClustersClient { 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); } /** @@ -2750,15 +3803,15 @@ export class AwsClustersClient { */ 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); } /** @@ -2792,7 +3845,7 @@ export class AwsClustersClient { * await client.cancelOperation({name: ''}); * ``` */ - cancelOperation( + cancelOperation( request: protos.google.longrunning.CancelOperationRequest, optionsOrCallback?: | gax.CallOptions @@ -2805,25 +3858,24 @@ export class AwsClustersClient { 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 @@ -2862,22 +3914,22 @@ export class AwsClustersClient { 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); } @@ -2893,7 +3945,11 @@ export class AwsClustersClient { * @param {string} attached_cluster * @returns {string} Resource name string. */ - attachedClusterPath(project:string,location:string,attachedCluster:string) { + attachedClusterPath( + project: string, + location: string, + attachedCluster: string, + ) { return this.pathTemplates.attachedClusterPathTemplate.render({ project: project, location: location, @@ -2909,7 +3965,9 @@ export class AwsClustersClient { * @returns {string} A string representing the project. */ matchProjectFromAttachedClusterName(attachedClusterName: string) { - return this.pathTemplates.attachedClusterPathTemplate.match(attachedClusterName).project; + return this.pathTemplates.attachedClusterPathTemplate.match( + attachedClusterName, + ).project; } /** @@ -2920,7 +3978,9 @@ export class AwsClustersClient { * @returns {string} A string representing the location. */ matchLocationFromAttachedClusterName(attachedClusterName: string) { - return this.pathTemplates.attachedClusterPathTemplate.match(attachedClusterName).location; + return this.pathTemplates.attachedClusterPathTemplate.match( + attachedClusterName, + ).location; } /** @@ -2931,7 +3991,9 @@ export class AwsClustersClient { * @returns {string} A string representing the attached_cluster. */ matchAttachedClusterFromAttachedClusterName(attachedClusterName: string) { - return this.pathTemplates.attachedClusterPathTemplate.match(attachedClusterName).attached_cluster; + return this.pathTemplates.attachedClusterPathTemplate.match( + attachedClusterName, + ).attached_cluster; } /** @@ -2941,7 +4003,7 @@ export class AwsClustersClient { * @param {string} location * @returns {string} Resource name string. */ - attachedServerConfigPath(project:string,location:string) { + attachedServerConfigPath(project: string, location: string) { return this.pathTemplates.attachedServerConfigPathTemplate.render({ project: project, location: location, @@ -2956,7 +4018,9 @@ export class AwsClustersClient { * @returns {string} A string representing the project. */ matchProjectFromAttachedServerConfigName(attachedServerConfigName: string) { - return this.pathTemplates.attachedServerConfigPathTemplate.match(attachedServerConfigName).project; + return this.pathTemplates.attachedServerConfigPathTemplate.match( + attachedServerConfigName, + ).project; } /** @@ -2967,7 +4031,9 @@ export class AwsClustersClient { * @returns {string} A string representing the location. */ matchLocationFromAttachedServerConfigName(attachedServerConfigName: string) { - return this.pathTemplates.attachedServerConfigPathTemplate.match(attachedServerConfigName).location; + return this.pathTemplates.attachedServerConfigPathTemplate.match( + attachedServerConfigName, + ).location; } /** @@ -2978,7 +4044,7 @@ export class AwsClustersClient { * @param {string} aws_cluster * @returns {string} Resource name string. */ - awsClusterPath(project:string,location:string,awsCluster:string) { + awsClusterPath(project: string, location: string, awsCluster: string) { return this.pathTemplates.awsClusterPathTemplate.render({ project: project, location: location, @@ -2994,7 +4060,8 @@ export class AwsClustersClient { * @returns {string} A string representing the project. */ matchProjectFromAwsClusterName(awsClusterName: string) { - return this.pathTemplates.awsClusterPathTemplate.match(awsClusterName).project; + return this.pathTemplates.awsClusterPathTemplate.match(awsClusterName) + .project; } /** @@ -3005,7 +4072,8 @@ export class AwsClustersClient { * @returns {string} A string representing the location. */ matchLocationFromAwsClusterName(awsClusterName: string) { - return this.pathTemplates.awsClusterPathTemplate.match(awsClusterName).location; + return this.pathTemplates.awsClusterPathTemplate.match(awsClusterName) + .location; } /** @@ -3016,7 +4084,8 @@ export class AwsClustersClient { * @returns {string} A string representing the aws_cluster. */ matchAwsClusterFromAwsClusterName(awsClusterName: string) { - return this.pathTemplates.awsClusterPathTemplate.match(awsClusterName).aws_cluster; + return this.pathTemplates.awsClusterPathTemplate.match(awsClusterName) + .aws_cluster; } /** @@ -3028,7 +4097,12 @@ export class AwsClustersClient { * @param {string} aws_node_pool * @returns {string} Resource name string. */ - awsNodePoolPath(project:string,location:string,awsCluster:string,awsNodePool:string) { + awsNodePoolPath( + project: string, + location: string, + awsCluster: string, + awsNodePool: string, + ) { return this.pathTemplates.awsNodePoolPathTemplate.render({ project: project, location: location, @@ -3045,7 +4119,8 @@ export class AwsClustersClient { * @returns {string} A string representing the project. */ matchProjectFromAwsNodePoolName(awsNodePoolName: string) { - return this.pathTemplates.awsNodePoolPathTemplate.match(awsNodePoolName).project; + return this.pathTemplates.awsNodePoolPathTemplate.match(awsNodePoolName) + .project; } /** @@ -3056,7 +4131,8 @@ export class AwsClustersClient { * @returns {string} A string representing the location. */ matchLocationFromAwsNodePoolName(awsNodePoolName: string) { - return this.pathTemplates.awsNodePoolPathTemplate.match(awsNodePoolName).location; + return this.pathTemplates.awsNodePoolPathTemplate.match(awsNodePoolName) + .location; } /** @@ -3067,7 +4143,8 @@ export class AwsClustersClient { * @returns {string} A string representing the aws_cluster. */ matchAwsClusterFromAwsNodePoolName(awsNodePoolName: string) { - return this.pathTemplates.awsNodePoolPathTemplate.match(awsNodePoolName).aws_cluster; + return this.pathTemplates.awsNodePoolPathTemplate.match(awsNodePoolName) + .aws_cluster; } /** @@ -3078,7 +4155,8 @@ export class AwsClustersClient { * @returns {string} A string representing the aws_node_pool. */ matchAwsNodePoolFromAwsNodePoolName(awsNodePoolName: string) { - return this.pathTemplates.awsNodePoolPathTemplate.match(awsNodePoolName).aws_node_pool; + return this.pathTemplates.awsNodePoolPathTemplate.match(awsNodePoolName) + .aws_node_pool; } /** @@ -3088,7 +4166,7 @@ export class AwsClustersClient { * @param {string} location * @returns {string} Resource name string. */ - awsServerConfigPath(project:string,location:string) { + awsServerConfigPath(project: string, location: string) { return this.pathTemplates.awsServerConfigPathTemplate.render({ project: project, location: location, @@ -3103,7 +4181,9 @@ export class AwsClustersClient { * @returns {string} A string representing the project. */ matchProjectFromAwsServerConfigName(awsServerConfigName: string) { - return this.pathTemplates.awsServerConfigPathTemplate.match(awsServerConfigName).project; + return this.pathTemplates.awsServerConfigPathTemplate.match( + awsServerConfigName, + ).project; } /** @@ -3114,7 +4194,9 @@ export class AwsClustersClient { * @returns {string} A string representing the location. */ matchLocationFromAwsServerConfigName(awsServerConfigName: string) { - return this.pathTemplates.awsServerConfigPathTemplate.match(awsServerConfigName).location; + return this.pathTemplates.awsServerConfigPathTemplate.match( + awsServerConfigName, + ).location; } /** @@ -3125,7 +4207,7 @@ export class AwsClustersClient { * @param {string} azure_client * @returns {string} Resource name string. */ - azureClientPath(project:string,location:string,azureClient:string) { + azureClientPath(project: string, location: string, azureClient: string) { return this.pathTemplates.azureClientPathTemplate.render({ project: project, location: location, @@ -3141,7 +4223,8 @@ export class AwsClustersClient { * @returns {string} A string representing the project. */ matchProjectFromAzureClientName(azureClientName: string) { - return this.pathTemplates.azureClientPathTemplate.match(azureClientName).project; + return this.pathTemplates.azureClientPathTemplate.match(azureClientName) + .project; } /** @@ -3152,7 +4235,8 @@ export class AwsClustersClient { * @returns {string} A string representing the location. */ matchLocationFromAzureClientName(azureClientName: string) { - return this.pathTemplates.azureClientPathTemplate.match(azureClientName).location; + return this.pathTemplates.azureClientPathTemplate.match(azureClientName) + .location; } /** @@ -3163,7 +4247,8 @@ export class AwsClustersClient { * @returns {string} A string representing the azure_client. */ matchAzureClientFromAzureClientName(azureClientName: string) { - return this.pathTemplates.azureClientPathTemplate.match(azureClientName).azure_client; + return this.pathTemplates.azureClientPathTemplate.match(azureClientName) + .azure_client; } /** @@ -3174,7 +4259,7 @@ export class AwsClustersClient { * @param {string} azure_cluster * @returns {string} Resource name string. */ - azureClusterPath(project:string,location:string,azureCluster:string) { + azureClusterPath(project: string, location: string, azureCluster: string) { return this.pathTemplates.azureClusterPathTemplate.render({ project: project, location: location, @@ -3190,7 +4275,8 @@ export class AwsClustersClient { * @returns {string} A string representing the project. */ matchProjectFromAzureClusterName(azureClusterName: string) { - return this.pathTemplates.azureClusterPathTemplate.match(azureClusterName).project; + return this.pathTemplates.azureClusterPathTemplate.match(azureClusterName) + .project; } /** @@ -3201,7 +4287,8 @@ export class AwsClustersClient { * @returns {string} A string representing the location. */ matchLocationFromAzureClusterName(azureClusterName: string) { - return this.pathTemplates.azureClusterPathTemplate.match(azureClusterName).location; + return this.pathTemplates.azureClusterPathTemplate.match(azureClusterName) + .location; } /** @@ -3212,7 +4299,8 @@ export class AwsClustersClient { * @returns {string} A string representing the azure_cluster. */ matchAzureClusterFromAzureClusterName(azureClusterName: string) { - return this.pathTemplates.azureClusterPathTemplate.match(azureClusterName).azure_cluster; + return this.pathTemplates.azureClusterPathTemplate.match(azureClusterName) + .azure_cluster; } /** @@ -3224,7 +4312,12 @@ export class AwsClustersClient { * @param {string} azure_node_pool * @returns {string} Resource name string. */ - azureNodePoolPath(project:string,location:string,azureCluster:string,azureNodePool:string) { + azureNodePoolPath( + project: string, + location: string, + azureCluster: string, + azureNodePool: string, + ) { return this.pathTemplates.azureNodePoolPathTemplate.render({ project: project, location: location, @@ -3241,7 +4334,8 @@ export class AwsClustersClient { * @returns {string} A string representing the project. */ matchProjectFromAzureNodePoolName(azureNodePoolName: string) { - return this.pathTemplates.azureNodePoolPathTemplate.match(azureNodePoolName).project; + return this.pathTemplates.azureNodePoolPathTemplate.match(azureNodePoolName) + .project; } /** @@ -3252,7 +4346,8 @@ export class AwsClustersClient { * @returns {string} A string representing the location. */ matchLocationFromAzureNodePoolName(azureNodePoolName: string) { - return this.pathTemplates.azureNodePoolPathTemplate.match(azureNodePoolName).location; + return this.pathTemplates.azureNodePoolPathTemplate.match(azureNodePoolName) + .location; } /** @@ -3263,7 +4358,8 @@ export class AwsClustersClient { * @returns {string} A string representing the azure_cluster. */ matchAzureClusterFromAzureNodePoolName(azureNodePoolName: string) { - return this.pathTemplates.azureNodePoolPathTemplate.match(azureNodePoolName).azure_cluster; + return this.pathTemplates.azureNodePoolPathTemplate.match(azureNodePoolName) + .azure_cluster; } /** @@ -3274,7 +4370,8 @@ export class AwsClustersClient { * @returns {string} A string representing the azure_node_pool. */ matchAzureNodePoolFromAzureNodePoolName(azureNodePoolName: string) { - return this.pathTemplates.azureNodePoolPathTemplate.match(azureNodePoolName).azure_node_pool; + return this.pathTemplates.azureNodePoolPathTemplate.match(azureNodePoolName) + .azure_node_pool; } /** @@ -3284,7 +4381,7 @@ export class AwsClustersClient { * @param {string} location * @returns {string} Resource name string. */ - azureServerConfigPath(project:string,location:string) { + azureServerConfigPath(project: string, location: string) { return this.pathTemplates.azureServerConfigPathTemplate.render({ project: project, location: location, @@ -3299,7 +4396,9 @@ export class AwsClustersClient { * @returns {string} A string representing the project. */ matchProjectFromAzureServerConfigName(azureServerConfigName: string) { - return this.pathTemplates.azureServerConfigPathTemplate.match(azureServerConfigName).project; + return this.pathTemplates.azureServerConfigPathTemplate.match( + azureServerConfigName, + ).project; } /** @@ -3310,7 +4409,9 @@ export class AwsClustersClient { * @returns {string} A string representing the location. */ matchLocationFromAzureServerConfigName(azureServerConfigName: string) { - return this.pathTemplates.azureServerConfigPathTemplate.match(azureServerConfigName).location; + return this.pathTemplates.azureServerConfigPathTemplate.match( + azureServerConfigName, + ).location; } /** @@ -3320,7 +4421,7 @@ export class AwsClustersClient { * @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, @@ -3355,7 +4456,7 @@ export class AwsClustersClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -3380,7 +4481,7 @@ export class AwsClustersClient { */ close(): Promise { if (this.awsClustersStub && !this._terminated) { - return this.awsClustersStub.then(stub => { + return this.awsClustersStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); @@ -3389,4 +4490,4 @@ export class AwsClustersClient { } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-gkemulticloud/src/v1/azure_clusters_client.ts b/packages/google-cloud-gkemulticloud/src/v1/azure_clusters_client.ts index ce0a5cc68aef..b7fb0191ef8b 100644 --- a/packages/google-cloud-gkemulticloud/src/v1/azure_clusters_client.ts +++ b/packages/google-cloud-gkemulticloud/src/v1/azure_clusters_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 @@ -46,7 +55,7 @@ export class AzureClustersClient { 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('gkemulticloud'); @@ -59,10 +68,10 @@ export class AzureClustersClient { 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; - azureClustersStub?: Promise<{[name: string]: Function}>; + azureClustersStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of AzureClustersClient. @@ -103,21 +112,42 @@ export class AzureClustersClient { * const client = new AzureClustersClient({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 AzureClustersClient; - 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 = 'gkemulticloud.' + 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); // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. if (servicePath !== this._servicePath && !('scopes' in opts)) { @@ -139,7 +169,7 @@ export class AzureClustersClient { 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 +183,7 @@ export class AzureClustersClient { } // 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,37 +205,37 @@ export class AzureClustersClient { // Create useful helper objects for these. this.pathTemplates = { attachedClusterPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/attachedClusters/{attached_cluster}' + 'projects/{project}/locations/{location}/attachedClusters/{attached_cluster}', ), attachedServerConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/attachedServerConfig' + 'projects/{project}/locations/{location}/attachedServerConfig', ), awsClusterPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/awsClusters/{aws_cluster}' + 'projects/{project}/locations/{location}/awsClusters/{aws_cluster}', ), awsNodePoolPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/awsClusters/{aws_cluster}/awsNodePools/{aws_node_pool}' + 'projects/{project}/locations/{location}/awsClusters/{aws_cluster}/awsNodePools/{aws_node_pool}', ), awsServerConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/awsServerConfig' + 'projects/{project}/locations/{location}/awsServerConfig', ), azureClientPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/azureClients/{azure_client}' + 'projects/{project}/locations/{location}/azureClients/{azure_client}', ), azureClusterPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/azureClusters/{azure_cluster}' + 'projects/{project}/locations/{location}/azureClusters/{azure_cluster}', ), azureNodePoolPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/azureClusters/{azure_cluster}/azureNodePools/{azure_node_pool}' + 'projects/{project}/locations/{location}/azureClusters/{azure_cluster}/azureNodePools/{azure_node_pool}', ), azureServerConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/azureServerConfig' + 'projects/{project}/locations/{location}/azureServerConfig', ), locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' + 'projects/{project}/locations/{location}', ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' + 'projects/{project}', ), }; @@ -216,12 +243,21 @@ export class AzureClustersClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listAzureClients: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'azureClients'), - listAzureClusters: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'azureClusters'), - listAzureNodePools: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'azureNodePools') + listAzureClients: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'azureClients', + ), + listAzureClusters: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'azureClusters', + ), + listAzureNodePools: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'azureNodePools', + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -230,85 +266,132 @@ export class AzureClustersClient { // 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.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.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 createAzureClientResponse = protoFilesRoot.lookup( - '.google.cloud.gkemulticloud.v1.AzureClient') as gax.protobuf.Type; + '.google.cloud.gkemulticloud.v1.AzureClient', + ) as gax.protobuf.Type; const createAzureClientMetadata = protoFilesRoot.lookup( - '.google.cloud.gkemulticloud.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.gkemulticloud.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteAzureClientResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteAzureClientMetadata = protoFilesRoot.lookup( - '.google.cloud.gkemulticloud.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.gkemulticloud.v1.OperationMetadata', + ) as gax.protobuf.Type; const createAzureClusterResponse = protoFilesRoot.lookup( - '.google.cloud.gkemulticloud.v1.AzureCluster') as gax.protobuf.Type; + '.google.cloud.gkemulticloud.v1.AzureCluster', + ) as gax.protobuf.Type; const createAzureClusterMetadata = protoFilesRoot.lookup( - '.google.cloud.gkemulticloud.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.gkemulticloud.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateAzureClusterResponse = protoFilesRoot.lookup( - '.google.cloud.gkemulticloud.v1.AzureCluster') as gax.protobuf.Type; + '.google.cloud.gkemulticloud.v1.AzureCluster', + ) as gax.protobuf.Type; const updateAzureClusterMetadata = protoFilesRoot.lookup( - '.google.cloud.gkemulticloud.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.gkemulticloud.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteAzureClusterResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteAzureClusterMetadata = protoFilesRoot.lookup( - '.google.cloud.gkemulticloud.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.gkemulticloud.v1.OperationMetadata', + ) as gax.protobuf.Type; const createAzureNodePoolResponse = protoFilesRoot.lookup( - '.google.cloud.gkemulticloud.v1.AzureNodePool') as gax.protobuf.Type; + '.google.cloud.gkemulticloud.v1.AzureNodePool', + ) as gax.protobuf.Type; const createAzureNodePoolMetadata = protoFilesRoot.lookup( - '.google.cloud.gkemulticloud.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.gkemulticloud.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateAzureNodePoolResponse = protoFilesRoot.lookup( - '.google.cloud.gkemulticloud.v1.AzureNodePool') as gax.protobuf.Type; + '.google.cloud.gkemulticloud.v1.AzureNodePool', + ) as gax.protobuf.Type; const updateAzureNodePoolMetadata = protoFilesRoot.lookup( - '.google.cloud.gkemulticloud.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.gkemulticloud.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteAzureNodePoolResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteAzureNodePoolMetadata = protoFilesRoot.lookup( - '.google.cloud.gkemulticloud.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.gkemulticloud.v1.OperationMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { createAzureClient: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createAzureClientResponse.decode.bind(createAzureClientResponse), - createAzureClientMetadata.decode.bind(createAzureClientMetadata)), + createAzureClientMetadata.decode.bind(createAzureClientMetadata), + ), deleteAzureClient: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteAzureClientResponse.decode.bind(deleteAzureClientResponse), - deleteAzureClientMetadata.decode.bind(deleteAzureClientMetadata)), + deleteAzureClientMetadata.decode.bind(deleteAzureClientMetadata), + ), createAzureCluster: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createAzureClusterResponse.decode.bind(createAzureClusterResponse), - createAzureClusterMetadata.decode.bind(createAzureClusterMetadata)), + createAzureClusterMetadata.decode.bind(createAzureClusterMetadata), + ), updateAzureCluster: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateAzureClusterResponse.decode.bind(updateAzureClusterResponse), - updateAzureClusterMetadata.decode.bind(updateAzureClusterMetadata)), + updateAzureClusterMetadata.decode.bind(updateAzureClusterMetadata), + ), deleteAzureCluster: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteAzureClusterResponse.decode.bind(deleteAzureClusterResponse), - deleteAzureClusterMetadata.decode.bind(deleteAzureClusterMetadata)), + deleteAzureClusterMetadata.decode.bind(deleteAzureClusterMetadata), + ), createAzureNodePool: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createAzureNodePoolResponse.decode.bind(createAzureNodePoolResponse), - createAzureNodePoolMetadata.decode.bind(createAzureNodePoolMetadata)), + createAzureNodePoolMetadata.decode.bind(createAzureNodePoolMetadata), + ), updateAzureNodePool: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateAzureNodePoolResponse.decode.bind(updateAzureNodePoolResponse), - updateAzureNodePoolMetadata.decode.bind(updateAzureNodePoolMetadata)), + updateAzureNodePoolMetadata.decode.bind(updateAzureNodePoolMetadata), + ), deleteAzureNodePool: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteAzureNodePoolResponse.decode.bind(deleteAzureNodePoolResponse), - deleteAzureNodePoolMetadata.decode.bind(deleteAzureNodePoolMetadata)) + deleteAzureNodePoolMetadata.decode.bind(deleteAzureNodePoolMetadata), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.gkemulticloud.v1.AzureClusters', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.gkemulticloud.v1.AzureClusters', + 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 @@ -333,35 +416,64 @@ export class AzureClustersClient { initialize() { // If the client stub promise is already initialized, return immediately. if (this.azureClustersStub) { - this.warn('DEP$AzureClusters', 'AzureClusters is deprecated and may be removed in a future version.', 'DeprecationWarning'); + this.warn( + 'DEP$AzureClusters', + 'AzureClusters is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); return this.azureClustersStub; } // Put together the "service stub" for // google.cloud.gkemulticloud.v1.AzureClusters. this.azureClustersStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.gkemulticloud.v1.AzureClusters') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.gkemulticloud.v1.AzureClusters', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.gkemulticloud.v1.AzureClusters, - 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 azureClustersStubMethods = - ['createAzureClient', 'getAzureClient', 'listAzureClients', 'deleteAzureClient', 'createAzureCluster', 'updateAzureCluster', 'getAzureCluster', 'listAzureClusters', 'deleteAzureCluster', 'generateAzureClusterAgentToken', 'generateAzureAccessToken', 'createAzureNodePool', 'updateAzureNodePool', 'getAzureNodePool', 'listAzureNodePools', 'deleteAzureNodePool', 'getAzureOpenIdConfig', 'getAzureJsonWebKeys', 'getAzureServerConfig']; + const azureClustersStubMethods = [ + 'createAzureClient', + 'getAzureClient', + 'listAzureClients', + 'deleteAzureClient', + 'createAzureCluster', + 'updateAzureCluster', + 'getAzureCluster', + 'listAzureClusters', + 'deleteAzureCluster', + 'generateAzureClusterAgentToken', + 'generateAzureAccessToken', + 'createAzureNodePool', + 'updateAzureNodePool', + 'getAzureNodePool', + 'listAzureNodePools', + 'deleteAzureNodePool', + 'getAzureOpenIdConfig', + 'getAzureJsonWebKeys', + 'getAzureServerConfig', + ]; for (const methodName of azureClustersStubMethods) { const callPromise = this.azureClustersStub.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] || @@ -371,12 +483,16 @@ export class AzureClustersClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; } - this.warn('DEP$AzureClusters', 'AzureClusters is deprecated and may be removed in a future version.', 'DeprecationWarning'); + this.warn( + 'DEP$AzureClusters', + 'AzureClusters is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); return this.azureClustersStub; } @@ -387,8 +503,14 @@ export class AzureClustersClient { * @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 'gkemulticloud.googleapis.com'; } @@ -399,8 +521,14 @@ export class AzureClustersClient { * @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 'gkemulticloud.googleapis.com'; } @@ -431,9 +559,7 @@ export class AzureClustersClient { * @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; @@ -442,8 +568,9 @@ export class AzureClustersClient { * 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; @@ -454,2059 +581,3060 @@ export class AzureClustersClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Describes a specific - * {@link protos.google.cloud.gkemulticloud.v1.AzureClient|AzureClient} resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the - * {@link protos.google.cloud.gkemulticloud.v1.AzureClient|AzureClient} resource to - * describe. - * - * {@link protos.google.cloud.gkemulticloud.v1.AzureClient|AzureClient} names are - * formatted as - * `projects//locations//azureClients/`. - * - * See [Resource Names](https://cloud.google.com/apis/design/resource_names) - * for more details on Google Cloud resource names. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.gkemulticloud.v1.AzureClient|AzureClient}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/azure_clusters.get_azure_client.js - * region_tag:gkemulticloud_v1_generated_AzureClusters_GetAzureClient_async - * @deprecated GetAzureClient is deprecated and may be removed in a future version. - */ + /** + * Describes a specific + * {@link protos.google.cloud.gkemulticloud.v1.AzureClient|AzureClient} resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the + * {@link protos.google.cloud.gkemulticloud.v1.AzureClient|AzureClient} resource to + * describe. + * + * {@link protos.google.cloud.gkemulticloud.v1.AzureClient|AzureClient} names are + * formatted as + * `projects//locations//azureClients/`. + * + * See [Resource Names](https://cloud.google.com/apis/design/resource_names) + * for more details on Google Cloud resource names. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.gkemulticloud.v1.AzureClient|AzureClient}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/azure_clusters.get_azure_client.js + * region_tag:gkemulticloud_v1_generated_AzureClusters_GetAzureClient_async + * @deprecated GetAzureClient is deprecated and may be removed in a future version. + */ getAzureClient( - request?: protos.google.cloud.gkemulticloud.v1.IGetAzureClientRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gkemulticloud.v1.IAzureClient, - protos.google.cloud.gkemulticloud.v1.IGetAzureClientRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkemulticloud.v1.IGetAzureClientRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gkemulticloud.v1.IAzureClient, + protos.google.cloud.gkemulticloud.v1.IGetAzureClientRequest | undefined, + {} | undefined, + ] + >; getAzureClient( - request: protos.google.cloud.gkemulticloud.v1.IGetAzureClientRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.gkemulticloud.v1.IAzureClient, - protos.google.cloud.gkemulticloud.v1.IGetAzureClientRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IGetAzureClientRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.gkemulticloud.v1.IAzureClient, + | protos.google.cloud.gkemulticloud.v1.IGetAzureClientRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getAzureClient( - request: protos.google.cloud.gkemulticloud.v1.IGetAzureClientRequest, - callback: Callback< - protos.google.cloud.gkemulticloud.v1.IAzureClient, - protos.google.cloud.gkemulticloud.v1.IGetAzureClientRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IGetAzureClientRequest, + callback: Callback< + protos.google.cloud.gkemulticloud.v1.IAzureClient, + | protos.google.cloud.gkemulticloud.v1.IGetAzureClientRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getAzureClient( - request?: protos.google.cloud.gkemulticloud.v1.IGetAzureClientRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.gkemulticloud.v1.IAzureClient, - protos.google.cloud.gkemulticloud.v1.IGetAzureClientRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.gkemulticloud.v1.IGetAzureClientRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.gkemulticloud.v1.IAzureClient, - protos.google.cloud.gkemulticloud.v1.IGetAzureClientRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.gkemulticloud.v1.IAzureClient, - protos.google.cloud.gkemulticloud.v1.IGetAzureClientRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.gkemulticloud.v1.IGetAzureClientRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.gkemulticloud.v1.IAzureClient, + | protos.google.cloud.gkemulticloud.v1.IGetAzureClientRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.gkemulticloud.v1.IAzureClient, + protos.google.cloud.gkemulticloud.v1.IGetAzureClientRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - this.warn('DEP$AzureClusters-$GetAzureClient','GetAzureClient is deprecated and may be removed in a future version.', 'DeprecationWarning'); + this.warn( + 'DEP$AzureClusters-$GetAzureClient', + 'GetAzureClient is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); this._log.info('getAzureClient request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.gkemulticloud.v1.IAzureClient, - protos.google.cloud.gkemulticloud.v1.IGetAzureClientRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.gkemulticloud.v1.IAzureClient, + | protos.google.cloud.gkemulticloud.v1.IGetAzureClientRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getAzureClient response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getAzureClient(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.gkemulticloud.v1.IAzureClient, - protos.google.cloud.gkemulticloud.v1.IGetAzureClientRequest|undefined, - {}|undefined - ]) => { - this._log.info('getAzureClient response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getAzureClient(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.gkemulticloud.v1.IAzureClient, + ( + | protos.google.cloud.gkemulticloud.v1.IGetAzureClientRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getAzureClient response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Describes a specific - * {@link protos.google.cloud.gkemulticloud.v1.AzureCluster|AzureCluster} resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the - * {@link protos.google.cloud.gkemulticloud.v1.AzureCluster|AzureCluster} resource to - * describe. - * - * `AzureCluster` names are formatted as - * `projects//locations//azureClusters/`. - * - * See [Resource Names](https://cloud.google.com/apis/design/resource_names) - * for more details on Google Cloud Platform resource names. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.gkemulticloud.v1.AzureCluster|AzureCluster}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/azure_clusters.get_azure_cluster.js - * region_tag:gkemulticloud_v1_generated_AzureClusters_GetAzureCluster_async - * @deprecated GetAzureCluster is deprecated and may be removed in a future version. - */ + /** + * Describes a specific + * {@link protos.google.cloud.gkemulticloud.v1.AzureCluster|AzureCluster} resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the + * {@link protos.google.cloud.gkemulticloud.v1.AzureCluster|AzureCluster} resource to + * describe. + * + * `AzureCluster` names are formatted as + * `projects//locations//azureClusters/`. + * + * See [Resource Names](https://cloud.google.com/apis/design/resource_names) + * for more details on Google Cloud Platform resource names. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.gkemulticloud.v1.AzureCluster|AzureCluster}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/azure_clusters.get_azure_cluster.js + * region_tag:gkemulticloud_v1_generated_AzureClusters_GetAzureCluster_async + * @deprecated GetAzureCluster is deprecated and may be removed in a future version. + */ getAzureCluster( - request?: protos.google.cloud.gkemulticloud.v1.IGetAzureClusterRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gkemulticloud.v1.IAzureCluster, - protos.google.cloud.gkemulticloud.v1.IGetAzureClusterRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkemulticloud.v1.IGetAzureClusterRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gkemulticloud.v1.IAzureCluster, + protos.google.cloud.gkemulticloud.v1.IGetAzureClusterRequest | undefined, + {} | undefined, + ] + >; getAzureCluster( - request: protos.google.cloud.gkemulticloud.v1.IGetAzureClusterRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.gkemulticloud.v1.IAzureCluster, - protos.google.cloud.gkemulticloud.v1.IGetAzureClusterRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IGetAzureClusterRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.gkemulticloud.v1.IAzureCluster, + | protos.google.cloud.gkemulticloud.v1.IGetAzureClusterRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getAzureCluster( - request: protos.google.cloud.gkemulticloud.v1.IGetAzureClusterRequest, - callback: Callback< - protos.google.cloud.gkemulticloud.v1.IAzureCluster, - protos.google.cloud.gkemulticloud.v1.IGetAzureClusterRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IGetAzureClusterRequest, + callback: Callback< + protos.google.cloud.gkemulticloud.v1.IAzureCluster, + | protos.google.cloud.gkemulticloud.v1.IGetAzureClusterRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getAzureCluster( - request?: protos.google.cloud.gkemulticloud.v1.IGetAzureClusterRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.gkemulticloud.v1.IAzureCluster, - protos.google.cloud.gkemulticloud.v1.IGetAzureClusterRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.gkemulticloud.v1.IGetAzureClusterRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.gkemulticloud.v1.IAzureCluster, - protos.google.cloud.gkemulticloud.v1.IGetAzureClusterRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.gkemulticloud.v1.IAzureCluster, - protos.google.cloud.gkemulticloud.v1.IGetAzureClusterRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.gkemulticloud.v1.IGetAzureClusterRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.gkemulticloud.v1.IAzureCluster, + | protos.google.cloud.gkemulticloud.v1.IGetAzureClusterRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.gkemulticloud.v1.IAzureCluster, + protos.google.cloud.gkemulticloud.v1.IGetAzureClusterRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - this.warn('DEP$AzureClusters-$GetAzureCluster','GetAzureCluster is deprecated and may be removed in a future version.', 'DeprecationWarning'); + this.warn( + 'DEP$AzureClusters-$GetAzureCluster', + 'GetAzureCluster is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); this._log.info('getAzureCluster request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.gkemulticloud.v1.IAzureCluster, - protos.google.cloud.gkemulticloud.v1.IGetAzureClusterRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.gkemulticloud.v1.IAzureCluster, + | protos.google.cloud.gkemulticloud.v1.IGetAzureClusterRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getAzureCluster response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getAzureCluster(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.gkemulticloud.v1.IAzureCluster, - protos.google.cloud.gkemulticloud.v1.IGetAzureClusterRequest|undefined, - {}|undefined - ]) => { - this._log.info('getAzureCluster response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getAzureCluster(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.gkemulticloud.v1.IAzureCluster, + ( + | protos.google.cloud.gkemulticloud.v1.IGetAzureClusterRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getAzureCluster response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 an access token for a cluster agent. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.azureCluster - * Required. - * @param {string} request.subjectToken - * Required. - * @param {string} request.subjectTokenType - * Required. - * @param {string} request.version - * Required. - * @param {string} [request.nodePoolId] - * Optional. - * @param {string} [request.grantType] - * Optional. - * @param {string} [request.audience] - * Optional. - * @param {string} [request.scope] - * Optional. - * @param {string} [request.requestedTokenType] - * Optional. - * @param {string} [request.options] - * Optional. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.gkemulticloud.v1.GenerateAzureClusterAgentTokenResponse|GenerateAzureClusterAgentTokenResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/azure_clusters.generate_azure_cluster_agent_token.js - * region_tag:gkemulticloud_v1_generated_AzureClusters_GenerateAzureClusterAgentToken_async - * @deprecated GenerateAzureClusterAgentToken is deprecated and may be removed in a future version. - */ + /** + * Generates an access token for a cluster agent. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.azureCluster + * Required. + * @param {string} request.subjectToken + * Required. + * @param {string} request.subjectTokenType + * Required. + * @param {string} request.version + * Required. + * @param {string} [request.nodePoolId] + * Optional. + * @param {string} [request.grantType] + * Optional. + * @param {string} [request.audience] + * Optional. + * @param {string} [request.scope] + * Optional. + * @param {string} [request.requestedTokenType] + * Optional. + * @param {string} [request.options] + * Optional. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.gkemulticloud.v1.GenerateAzureClusterAgentTokenResponse|GenerateAzureClusterAgentTokenResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/azure_clusters.generate_azure_cluster_agent_token.js + * region_tag:gkemulticloud_v1_generated_AzureClusters_GenerateAzureClusterAgentToken_async + * @deprecated GenerateAzureClusterAgentToken is deprecated and may be removed in a future version. + */ generateAzureClusterAgentToken( - request?: protos.google.cloud.gkemulticloud.v1.IGenerateAzureClusterAgentTokenRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gkemulticloud.v1.IGenerateAzureClusterAgentTokenResponse, - protos.google.cloud.gkemulticloud.v1.IGenerateAzureClusterAgentTokenRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkemulticloud.v1.IGenerateAzureClusterAgentTokenRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gkemulticloud.v1.IGenerateAzureClusterAgentTokenResponse, + ( + | protos.google.cloud.gkemulticloud.v1.IGenerateAzureClusterAgentTokenRequest + | undefined + ), + {} | undefined, + ] + >; generateAzureClusterAgentToken( - request: protos.google.cloud.gkemulticloud.v1.IGenerateAzureClusterAgentTokenRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.gkemulticloud.v1.IGenerateAzureClusterAgentTokenResponse, - protos.google.cloud.gkemulticloud.v1.IGenerateAzureClusterAgentTokenRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IGenerateAzureClusterAgentTokenRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.gkemulticloud.v1.IGenerateAzureClusterAgentTokenResponse, + | protos.google.cloud.gkemulticloud.v1.IGenerateAzureClusterAgentTokenRequest + | null + | undefined, + {} | null | undefined + >, + ): void; generateAzureClusterAgentToken( - request: protos.google.cloud.gkemulticloud.v1.IGenerateAzureClusterAgentTokenRequest, - callback: Callback< - protos.google.cloud.gkemulticloud.v1.IGenerateAzureClusterAgentTokenResponse, - protos.google.cloud.gkemulticloud.v1.IGenerateAzureClusterAgentTokenRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IGenerateAzureClusterAgentTokenRequest, + callback: Callback< + protos.google.cloud.gkemulticloud.v1.IGenerateAzureClusterAgentTokenResponse, + | protos.google.cloud.gkemulticloud.v1.IGenerateAzureClusterAgentTokenRequest + | null + | undefined, + {} | null | undefined + >, + ): void; generateAzureClusterAgentToken( - request?: protos.google.cloud.gkemulticloud.v1.IGenerateAzureClusterAgentTokenRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.gkemulticloud.v1.IGenerateAzureClusterAgentTokenResponse, - protos.google.cloud.gkemulticloud.v1.IGenerateAzureClusterAgentTokenRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.gkemulticloud.v1.IGenerateAzureClusterAgentTokenRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.gkemulticloud.v1.IGenerateAzureClusterAgentTokenResponse, - protos.google.cloud.gkemulticloud.v1.IGenerateAzureClusterAgentTokenRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.gkemulticloud.v1.IGenerateAzureClusterAgentTokenResponse, - protos.google.cloud.gkemulticloud.v1.IGenerateAzureClusterAgentTokenRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.gkemulticloud.v1.IGenerateAzureClusterAgentTokenRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.gkemulticloud.v1.IGenerateAzureClusterAgentTokenResponse, + | protos.google.cloud.gkemulticloud.v1.IGenerateAzureClusterAgentTokenRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.gkemulticloud.v1.IGenerateAzureClusterAgentTokenResponse, + ( + | protos.google.cloud.gkemulticloud.v1.IGenerateAzureClusterAgentTokenRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'azure_cluster': request.azureCluster ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + azure_cluster: request.azureCluster ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - this.warn('DEP$AzureClusters-$GenerateAzureClusterAgentToken','GenerateAzureClusterAgentToken is deprecated and may be removed in a future version.', 'DeprecationWarning'); + this.warn( + 'DEP$AzureClusters-$GenerateAzureClusterAgentToken', + 'GenerateAzureClusterAgentToken is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); this._log.info('generateAzureClusterAgentToken request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.gkemulticloud.v1.IGenerateAzureClusterAgentTokenResponse, - protos.google.cloud.gkemulticloud.v1.IGenerateAzureClusterAgentTokenRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.gkemulticloud.v1.IGenerateAzureClusterAgentTokenResponse, + | protos.google.cloud.gkemulticloud.v1.IGenerateAzureClusterAgentTokenRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { - this._log.info('generateAzureClusterAgentToken response %j', response); + this._log.info( + 'generateAzureClusterAgentToken response %j', + response, + ); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.generateAzureClusterAgentToken(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.gkemulticloud.v1.IGenerateAzureClusterAgentTokenResponse, - protos.google.cloud.gkemulticloud.v1.IGenerateAzureClusterAgentTokenRequest|undefined, - {}|undefined - ]) => { - this._log.info('generateAzureClusterAgentToken response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .generateAzureClusterAgentToken(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.gkemulticloud.v1.IGenerateAzureClusterAgentTokenResponse, + ( + | protos.google.cloud.gkemulticloud.v1.IGenerateAzureClusterAgentTokenRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info( + 'generateAzureClusterAgentToken response %j', + response, + ); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 access token to authenticate to a given - * {@link protos.google.cloud.gkemulticloud.v1.AzureCluster|AzureCluster} resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.azureCluster - * Required. The name of the - * {@link protos.google.cloud.gkemulticloud.v1.AzureCluster|AzureCluster} resource to - * authenticate to. - * - * `AzureCluster` names are formatted as - * `projects//locations//azureClusters/`. - * - * See [Resource Names](https://cloud.google.com/apis/design/resource_names) - * for more details on Google Cloud resource names. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.gkemulticloud.v1.GenerateAzureAccessTokenResponse|GenerateAzureAccessTokenResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/azure_clusters.generate_azure_access_token.js - * region_tag:gkemulticloud_v1_generated_AzureClusters_GenerateAzureAccessToken_async - * @deprecated GenerateAzureAccessToken is deprecated and may be removed in a future version. - */ + /** + * Generates a short-lived access token to authenticate to a given + * {@link protos.google.cloud.gkemulticloud.v1.AzureCluster|AzureCluster} resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.azureCluster + * Required. The name of the + * {@link protos.google.cloud.gkemulticloud.v1.AzureCluster|AzureCluster} resource to + * authenticate to. + * + * `AzureCluster` names are formatted as + * `projects//locations//azureClusters/`. + * + * See [Resource Names](https://cloud.google.com/apis/design/resource_names) + * for more details on Google Cloud resource names. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.gkemulticloud.v1.GenerateAzureAccessTokenResponse|GenerateAzureAccessTokenResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/azure_clusters.generate_azure_access_token.js + * region_tag:gkemulticloud_v1_generated_AzureClusters_GenerateAzureAccessToken_async + * @deprecated GenerateAzureAccessToken is deprecated and may be removed in a future version. + */ generateAzureAccessToken( - request?: protos.google.cloud.gkemulticloud.v1.IGenerateAzureAccessTokenRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gkemulticloud.v1.IGenerateAzureAccessTokenResponse, - protos.google.cloud.gkemulticloud.v1.IGenerateAzureAccessTokenRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkemulticloud.v1.IGenerateAzureAccessTokenRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gkemulticloud.v1.IGenerateAzureAccessTokenResponse, + ( + | protos.google.cloud.gkemulticloud.v1.IGenerateAzureAccessTokenRequest + | undefined + ), + {} | undefined, + ] + >; generateAzureAccessToken( - request: protos.google.cloud.gkemulticloud.v1.IGenerateAzureAccessTokenRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.gkemulticloud.v1.IGenerateAzureAccessTokenResponse, - protos.google.cloud.gkemulticloud.v1.IGenerateAzureAccessTokenRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IGenerateAzureAccessTokenRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.gkemulticloud.v1.IGenerateAzureAccessTokenResponse, + | protos.google.cloud.gkemulticloud.v1.IGenerateAzureAccessTokenRequest + | null + | undefined, + {} | null | undefined + >, + ): void; generateAzureAccessToken( - request: protos.google.cloud.gkemulticloud.v1.IGenerateAzureAccessTokenRequest, - callback: Callback< - protos.google.cloud.gkemulticloud.v1.IGenerateAzureAccessTokenResponse, - protos.google.cloud.gkemulticloud.v1.IGenerateAzureAccessTokenRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IGenerateAzureAccessTokenRequest, + callback: Callback< + protos.google.cloud.gkemulticloud.v1.IGenerateAzureAccessTokenResponse, + | protos.google.cloud.gkemulticloud.v1.IGenerateAzureAccessTokenRequest + | null + | undefined, + {} | null | undefined + >, + ): void; generateAzureAccessToken( - request?: protos.google.cloud.gkemulticloud.v1.IGenerateAzureAccessTokenRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.gkemulticloud.v1.IGenerateAzureAccessTokenResponse, - protos.google.cloud.gkemulticloud.v1.IGenerateAzureAccessTokenRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.gkemulticloud.v1.IGenerateAzureAccessTokenRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.gkemulticloud.v1.IGenerateAzureAccessTokenResponse, - protos.google.cloud.gkemulticloud.v1.IGenerateAzureAccessTokenRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.gkemulticloud.v1.IGenerateAzureAccessTokenResponse, - protos.google.cloud.gkemulticloud.v1.IGenerateAzureAccessTokenRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.gkemulticloud.v1.IGenerateAzureAccessTokenRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.gkemulticloud.v1.IGenerateAzureAccessTokenResponse, + | protos.google.cloud.gkemulticloud.v1.IGenerateAzureAccessTokenRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.gkemulticloud.v1.IGenerateAzureAccessTokenResponse, + ( + | protos.google.cloud.gkemulticloud.v1.IGenerateAzureAccessTokenRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'azure_cluster': request.azureCluster ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + azure_cluster: request.azureCluster ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - this.warn('DEP$AzureClusters-$GenerateAzureAccessToken','GenerateAzureAccessToken is deprecated and may be removed in a future version.', 'DeprecationWarning'); + this.warn( + 'DEP$AzureClusters-$GenerateAzureAccessToken', + 'GenerateAzureAccessToken is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); this._log.info('generateAzureAccessToken request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.gkemulticloud.v1.IGenerateAzureAccessTokenResponse, - protos.google.cloud.gkemulticloud.v1.IGenerateAzureAccessTokenRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.gkemulticloud.v1.IGenerateAzureAccessTokenResponse, + | protos.google.cloud.gkemulticloud.v1.IGenerateAzureAccessTokenRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('generateAzureAccessToken response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.generateAzureAccessToken(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.gkemulticloud.v1.IGenerateAzureAccessTokenResponse, - protos.google.cloud.gkemulticloud.v1.IGenerateAzureAccessTokenRequest|undefined, - {}|undefined - ]) => { - this._log.info('generateAzureAccessToken response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .generateAzureAccessToken(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.gkemulticloud.v1.IGenerateAzureAccessTokenResponse, + ( + | protos.google.cloud.gkemulticloud.v1.IGenerateAzureAccessTokenRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('generateAzureAccessToken response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Describes a specific - * {@link protos.google.cloud.gkemulticloud.v1.AzureNodePool|AzureNodePool} resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the - * {@link protos.google.cloud.gkemulticloud.v1.AzureNodePool|AzureNodePool} resource to - * describe. - * - * `AzureNodePool` names are formatted as - * `projects//locations//azureClusters//azureNodePools/`. - * - * See [Resource Names](https://cloud.google.com/apis/design/resource_names) - * for more details on Google Cloud resource names. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.gkemulticloud.v1.AzureNodePool|AzureNodePool}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/azure_clusters.get_azure_node_pool.js - * region_tag:gkemulticloud_v1_generated_AzureClusters_GetAzureNodePool_async - * @deprecated GetAzureNodePool is deprecated and may be removed in a future version. - */ + /** + * Describes a specific + * {@link protos.google.cloud.gkemulticloud.v1.AzureNodePool|AzureNodePool} resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the + * {@link protos.google.cloud.gkemulticloud.v1.AzureNodePool|AzureNodePool} resource to + * describe. + * + * `AzureNodePool` names are formatted as + * `projects//locations//azureClusters//azureNodePools/`. + * + * See [Resource Names](https://cloud.google.com/apis/design/resource_names) + * for more details on Google Cloud resource names. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.gkemulticloud.v1.AzureNodePool|AzureNodePool}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/azure_clusters.get_azure_node_pool.js + * region_tag:gkemulticloud_v1_generated_AzureClusters_GetAzureNodePool_async + * @deprecated GetAzureNodePool is deprecated and may be removed in a future version. + */ getAzureNodePool( - request?: protos.google.cloud.gkemulticloud.v1.IGetAzureNodePoolRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gkemulticloud.v1.IAzureNodePool, - protos.google.cloud.gkemulticloud.v1.IGetAzureNodePoolRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkemulticloud.v1.IGetAzureNodePoolRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gkemulticloud.v1.IAzureNodePool, + protos.google.cloud.gkemulticloud.v1.IGetAzureNodePoolRequest | undefined, + {} | undefined, + ] + >; getAzureNodePool( - request: protos.google.cloud.gkemulticloud.v1.IGetAzureNodePoolRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.gkemulticloud.v1.IAzureNodePool, - protos.google.cloud.gkemulticloud.v1.IGetAzureNodePoolRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IGetAzureNodePoolRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.gkemulticloud.v1.IAzureNodePool, + | protos.google.cloud.gkemulticloud.v1.IGetAzureNodePoolRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getAzureNodePool( - request: protos.google.cloud.gkemulticloud.v1.IGetAzureNodePoolRequest, - callback: Callback< - protos.google.cloud.gkemulticloud.v1.IAzureNodePool, - protos.google.cloud.gkemulticloud.v1.IGetAzureNodePoolRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IGetAzureNodePoolRequest, + callback: Callback< + protos.google.cloud.gkemulticloud.v1.IAzureNodePool, + | protos.google.cloud.gkemulticloud.v1.IGetAzureNodePoolRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getAzureNodePool( - request?: protos.google.cloud.gkemulticloud.v1.IGetAzureNodePoolRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.gkemulticloud.v1.IAzureNodePool, - protos.google.cloud.gkemulticloud.v1.IGetAzureNodePoolRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.gkemulticloud.v1.IGetAzureNodePoolRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.gkemulticloud.v1.IAzureNodePool, - protos.google.cloud.gkemulticloud.v1.IGetAzureNodePoolRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.gkemulticloud.v1.IAzureNodePool, - protos.google.cloud.gkemulticloud.v1.IGetAzureNodePoolRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.gkemulticloud.v1.IGetAzureNodePoolRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.gkemulticloud.v1.IAzureNodePool, + | protos.google.cloud.gkemulticloud.v1.IGetAzureNodePoolRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.gkemulticloud.v1.IAzureNodePool, + protos.google.cloud.gkemulticloud.v1.IGetAzureNodePoolRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - this.warn('DEP$AzureClusters-$GetAzureNodePool','GetAzureNodePool is deprecated and may be removed in a future version.', 'DeprecationWarning'); + this.warn( + 'DEP$AzureClusters-$GetAzureNodePool', + 'GetAzureNodePool is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); this._log.info('getAzureNodePool request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.gkemulticloud.v1.IAzureNodePool, - protos.google.cloud.gkemulticloud.v1.IGetAzureNodePoolRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.gkemulticloud.v1.IAzureNodePool, + | protos.google.cloud.gkemulticloud.v1.IGetAzureNodePoolRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getAzureNodePool response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getAzureNodePool(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.gkemulticloud.v1.IAzureNodePool, - protos.google.cloud.gkemulticloud.v1.IGetAzureNodePoolRequest|undefined, - {}|undefined - ]) => { - this._log.info('getAzureNodePool response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getAzureNodePool(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.gkemulticloud.v1.IAzureNodePool, + ( + | protos.google.cloud.gkemulticloud.v1.IGetAzureNodePoolRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getAzureNodePool response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 OIDC discovery document for the cluster. - * See the - * [OpenID Connect Discovery 1.0 - * specification](https://openid.net/specs/openid-connect-discovery-1_0.html) - * for details. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.azureCluster - * Required. The AzureCluster, which owns the OIDC discovery document. - * Format: - * projects//locations//azureClusters/ - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.gkemulticloud.v1.AzureOpenIdConfig|AzureOpenIdConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/azure_clusters.get_azure_open_id_config.js - * region_tag:gkemulticloud_v1_generated_AzureClusters_GetAzureOpenIdConfig_async - * @deprecated GetAzureOpenIdConfig is deprecated and may be removed in a future version. - */ + /** + * Gets the OIDC discovery document for the cluster. + * See the + * [OpenID Connect Discovery 1.0 + * specification](https://openid.net/specs/openid-connect-discovery-1_0.html) + * for details. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.azureCluster + * Required. The AzureCluster, which owns the OIDC discovery document. + * Format: + * projects//locations//azureClusters/ + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.gkemulticloud.v1.AzureOpenIdConfig|AzureOpenIdConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/azure_clusters.get_azure_open_id_config.js + * region_tag:gkemulticloud_v1_generated_AzureClusters_GetAzureOpenIdConfig_async + * @deprecated GetAzureOpenIdConfig is deprecated and may be removed in a future version. + */ getAzureOpenIdConfig( - request?: protos.google.cloud.gkemulticloud.v1.IGetAzureOpenIdConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gkemulticloud.v1.IAzureOpenIdConfig, - protos.google.cloud.gkemulticloud.v1.IGetAzureOpenIdConfigRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkemulticloud.v1.IGetAzureOpenIdConfigRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gkemulticloud.v1.IAzureOpenIdConfig, + ( + | protos.google.cloud.gkemulticloud.v1.IGetAzureOpenIdConfigRequest + | undefined + ), + {} | undefined, + ] + >; getAzureOpenIdConfig( - request: protos.google.cloud.gkemulticloud.v1.IGetAzureOpenIdConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.gkemulticloud.v1.IAzureOpenIdConfig, - protos.google.cloud.gkemulticloud.v1.IGetAzureOpenIdConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IGetAzureOpenIdConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.gkemulticloud.v1.IAzureOpenIdConfig, + | protos.google.cloud.gkemulticloud.v1.IGetAzureOpenIdConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getAzureOpenIdConfig( - request: protos.google.cloud.gkemulticloud.v1.IGetAzureOpenIdConfigRequest, - callback: Callback< - protos.google.cloud.gkemulticloud.v1.IAzureOpenIdConfig, - protos.google.cloud.gkemulticloud.v1.IGetAzureOpenIdConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IGetAzureOpenIdConfigRequest, + callback: Callback< + protos.google.cloud.gkemulticloud.v1.IAzureOpenIdConfig, + | protos.google.cloud.gkemulticloud.v1.IGetAzureOpenIdConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getAzureOpenIdConfig( - request?: protos.google.cloud.gkemulticloud.v1.IGetAzureOpenIdConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.gkemulticloud.v1.IAzureOpenIdConfig, - protos.google.cloud.gkemulticloud.v1.IGetAzureOpenIdConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.gkemulticloud.v1.IGetAzureOpenIdConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.gkemulticloud.v1.IAzureOpenIdConfig, - protos.google.cloud.gkemulticloud.v1.IGetAzureOpenIdConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.gkemulticloud.v1.IAzureOpenIdConfig, - protos.google.cloud.gkemulticloud.v1.IGetAzureOpenIdConfigRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.gkemulticloud.v1.IGetAzureOpenIdConfigRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.gkemulticloud.v1.IAzureOpenIdConfig, + | protos.google.cloud.gkemulticloud.v1.IGetAzureOpenIdConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.gkemulticloud.v1.IAzureOpenIdConfig, + ( + | protos.google.cloud.gkemulticloud.v1.IGetAzureOpenIdConfigRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'azure_cluster': request.azureCluster ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + azure_cluster: request.azureCluster ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - this.warn('DEP$AzureClusters-$GetAzureOpenIdConfig','GetAzureOpenIdConfig is deprecated and may be removed in a future version.', 'DeprecationWarning'); + this.warn( + 'DEP$AzureClusters-$GetAzureOpenIdConfig', + 'GetAzureOpenIdConfig is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); this._log.info('getAzureOpenIdConfig request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.gkemulticloud.v1.IAzureOpenIdConfig, - protos.google.cloud.gkemulticloud.v1.IGetAzureOpenIdConfigRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.gkemulticloud.v1.IAzureOpenIdConfig, + | protos.google.cloud.gkemulticloud.v1.IGetAzureOpenIdConfigRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getAzureOpenIdConfig response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getAzureOpenIdConfig(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.gkemulticloud.v1.IAzureOpenIdConfig, - protos.google.cloud.gkemulticloud.v1.IGetAzureOpenIdConfigRequest|undefined, - {}|undefined - ]) => { - this._log.info('getAzureOpenIdConfig response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getAzureOpenIdConfig(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.gkemulticloud.v1.IAzureOpenIdConfig, + ( + | protos.google.cloud.gkemulticloud.v1.IGetAzureOpenIdConfigRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getAzureOpenIdConfig response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 public component of the cluster signing keys in - * JSON Web Key format. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.azureCluster - * Required. The AzureCluster, which owns the JsonWebKeys. - * Format: - * `projects//locations//azureClusters/` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.gkemulticloud.v1.AzureJsonWebKeys|AzureJsonWebKeys}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/azure_clusters.get_azure_json_web_keys.js - * region_tag:gkemulticloud_v1_generated_AzureClusters_GetAzureJsonWebKeys_async - * @deprecated GetAzureJsonWebKeys is deprecated and may be removed in a future version. - */ + /** + * Gets the public component of the cluster signing keys in + * JSON Web Key format. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.azureCluster + * Required. The AzureCluster, which owns the JsonWebKeys. + * Format: + * `projects//locations//azureClusters/` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.gkemulticloud.v1.AzureJsonWebKeys|AzureJsonWebKeys}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/azure_clusters.get_azure_json_web_keys.js + * region_tag:gkemulticloud_v1_generated_AzureClusters_GetAzureJsonWebKeys_async + * @deprecated GetAzureJsonWebKeys is deprecated and may be removed in a future version. + */ getAzureJsonWebKeys( - request?: protos.google.cloud.gkemulticloud.v1.IGetAzureJsonWebKeysRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gkemulticloud.v1.IAzureJsonWebKeys, - protos.google.cloud.gkemulticloud.v1.IGetAzureJsonWebKeysRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkemulticloud.v1.IGetAzureJsonWebKeysRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gkemulticloud.v1.IAzureJsonWebKeys, + ( + | protos.google.cloud.gkemulticloud.v1.IGetAzureJsonWebKeysRequest + | undefined + ), + {} | undefined, + ] + >; getAzureJsonWebKeys( - request: protos.google.cloud.gkemulticloud.v1.IGetAzureJsonWebKeysRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.gkemulticloud.v1.IAzureJsonWebKeys, - protos.google.cloud.gkemulticloud.v1.IGetAzureJsonWebKeysRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IGetAzureJsonWebKeysRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.gkemulticloud.v1.IAzureJsonWebKeys, + | protos.google.cloud.gkemulticloud.v1.IGetAzureJsonWebKeysRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getAzureJsonWebKeys( - request: protos.google.cloud.gkemulticloud.v1.IGetAzureJsonWebKeysRequest, - callback: Callback< - protos.google.cloud.gkemulticloud.v1.IAzureJsonWebKeys, - protos.google.cloud.gkemulticloud.v1.IGetAzureJsonWebKeysRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IGetAzureJsonWebKeysRequest, + callback: Callback< + protos.google.cloud.gkemulticloud.v1.IAzureJsonWebKeys, + | protos.google.cloud.gkemulticloud.v1.IGetAzureJsonWebKeysRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getAzureJsonWebKeys( - request?: protos.google.cloud.gkemulticloud.v1.IGetAzureJsonWebKeysRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.gkemulticloud.v1.IAzureJsonWebKeys, - protos.google.cloud.gkemulticloud.v1.IGetAzureJsonWebKeysRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.gkemulticloud.v1.IGetAzureJsonWebKeysRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.gkemulticloud.v1.IAzureJsonWebKeys, - protos.google.cloud.gkemulticloud.v1.IGetAzureJsonWebKeysRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.gkemulticloud.v1.IAzureJsonWebKeys, - protos.google.cloud.gkemulticloud.v1.IGetAzureJsonWebKeysRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.gkemulticloud.v1.IGetAzureJsonWebKeysRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.gkemulticloud.v1.IAzureJsonWebKeys, + | protos.google.cloud.gkemulticloud.v1.IGetAzureJsonWebKeysRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.gkemulticloud.v1.IAzureJsonWebKeys, + ( + | protos.google.cloud.gkemulticloud.v1.IGetAzureJsonWebKeysRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'azure_cluster': request.azureCluster ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + azure_cluster: request.azureCluster ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - this.warn('DEP$AzureClusters-$GetAzureJsonWebKeys','GetAzureJsonWebKeys is deprecated and may be removed in a future version.', 'DeprecationWarning'); + this.warn( + 'DEP$AzureClusters-$GetAzureJsonWebKeys', + 'GetAzureJsonWebKeys is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); this._log.info('getAzureJsonWebKeys request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.gkemulticloud.v1.IAzureJsonWebKeys, - protos.google.cloud.gkemulticloud.v1.IGetAzureJsonWebKeysRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.gkemulticloud.v1.IAzureJsonWebKeys, + | protos.google.cloud.gkemulticloud.v1.IGetAzureJsonWebKeysRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getAzureJsonWebKeys response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getAzureJsonWebKeys(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.gkemulticloud.v1.IAzureJsonWebKeys, - protos.google.cloud.gkemulticloud.v1.IGetAzureJsonWebKeysRequest|undefined, - {}|undefined - ]) => { - this._log.info('getAzureJsonWebKeys response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getAzureJsonWebKeys(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.gkemulticloud.v1.IAzureJsonWebKeys, + ( + | protos.google.cloud.gkemulticloud.v1.IGetAzureJsonWebKeysRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getAzureJsonWebKeys response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 information, such as supported Azure regions and Kubernetes - * versions, on a given Google Cloud location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the - * {@link protos.google.cloud.gkemulticloud.v1.AzureServerConfig|AzureServerConfig} - * resource to describe. - * - * `AzureServerConfig` names are formatted as - * `projects//locations//azureServerConfig`. - * - * See [Resource Names](https://cloud.google.com/apis/design/resource_names) - * for more details on Google Cloud resource names. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.gkemulticloud.v1.AzureServerConfig|AzureServerConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/azure_clusters.get_azure_server_config.js - * region_tag:gkemulticloud_v1_generated_AzureClusters_GetAzureServerConfig_async - * @deprecated GetAzureServerConfig is deprecated and may be removed in a future version. - */ + /** + * Returns information, such as supported Azure regions and Kubernetes + * versions, on a given Google Cloud location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the + * {@link protos.google.cloud.gkemulticloud.v1.AzureServerConfig|AzureServerConfig} + * resource to describe. + * + * `AzureServerConfig` names are formatted as + * `projects//locations//azureServerConfig`. + * + * See [Resource Names](https://cloud.google.com/apis/design/resource_names) + * for more details on Google Cloud resource names. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.gkemulticloud.v1.AzureServerConfig|AzureServerConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/azure_clusters.get_azure_server_config.js + * region_tag:gkemulticloud_v1_generated_AzureClusters_GetAzureServerConfig_async + * @deprecated GetAzureServerConfig is deprecated and may be removed in a future version. + */ getAzureServerConfig( - request?: protos.google.cloud.gkemulticloud.v1.IGetAzureServerConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gkemulticloud.v1.IAzureServerConfig, - protos.google.cloud.gkemulticloud.v1.IGetAzureServerConfigRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkemulticloud.v1.IGetAzureServerConfigRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gkemulticloud.v1.IAzureServerConfig, + ( + | protos.google.cloud.gkemulticloud.v1.IGetAzureServerConfigRequest + | undefined + ), + {} | undefined, + ] + >; getAzureServerConfig( - request: protos.google.cloud.gkemulticloud.v1.IGetAzureServerConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.gkemulticloud.v1.IAzureServerConfig, - protos.google.cloud.gkemulticloud.v1.IGetAzureServerConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IGetAzureServerConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.gkemulticloud.v1.IAzureServerConfig, + | protos.google.cloud.gkemulticloud.v1.IGetAzureServerConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getAzureServerConfig( - request: protos.google.cloud.gkemulticloud.v1.IGetAzureServerConfigRequest, - callback: Callback< - protos.google.cloud.gkemulticloud.v1.IAzureServerConfig, - protos.google.cloud.gkemulticloud.v1.IGetAzureServerConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IGetAzureServerConfigRequest, + callback: Callback< + protos.google.cloud.gkemulticloud.v1.IAzureServerConfig, + | protos.google.cloud.gkemulticloud.v1.IGetAzureServerConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getAzureServerConfig( - request?: protos.google.cloud.gkemulticloud.v1.IGetAzureServerConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.gkemulticloud.v1.IAzureServerConfig, - protos.google.cloud.gkemulticloud.v1.IGetAzureServerConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.gkemulticloud.v1.IGetAzureServerConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.gkemulticloud.v1.IAzureServerConfig, - protos.google.cloud.gkemulticloud.v1.IGetAzureServerConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.gkemulticloud.v1.IAzureServerConfig, - protos.google.cloud.gkemulticloud.v1.IGetAzureServerConfigRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.gkemulticloud.v1.IGetAzureServerConfigRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.gkemulticloud.v1.IAzureServerConfig, + | protos.google.cloud.gkemulticloud.v1.IGetAzureServerConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.gkemulticloud.v1.IAzureServerConfig, + ( + | protos.google.cloud.gkemulticloud.v1.IGetAzureServerConfigRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - this.warn('DEP$AzureClusters-$GetAzureServerConfig','GetAzureServerConfig is deprecated and may be removed in a future version.', 'DeprecationWarning'); + this.warn( + 'DEP$AzureClusters-$GetAzureServerConfig', + 'GetAzureServerConfig is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); this._log.info('getAzureServerConfig request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.gkemulticloud.v1.IAzureServerConfig, - protos.google.cloud.gkemulticloud.v1.IGetAzureServerConfigRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.gkemulticloud.v1.IAzureServerConfig, + | protos.google.cloud.gkemulticloud.v1.IGetAzureServerConfigRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getAzureServerConfig response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getAzureServerConfig(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.gkemulticloud.v1.IAzureServerConfig, - protos.google.cloud.gkemulticloud.v1.IGetAzureServerConfigRequest|undefined, - {}|undefined - ]) => { - this._log.info('getAzureServerConfig response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getAzureServerConfig(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.gkemulticloud.v1.IAzureServerConfig, + ( + | protos.google.cloud.gkemulticloud.v1.IGetAzureServerConfigRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getAzureServerConfig response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 {@link protos.google.cloud.gkemulticloud.v1.AzureClient|AzureClient} - * resource on a given Google Cloud project and region. - * - * `AzureClient` resources hold client authentication - * information needed by the Anthos Multicloud API to manage Azure resources - * on your Azure subscription on your behalf. - * - * If successful, the response contains a newly created - * {@link protos.google.longrunning.Operation|Operation} resource that can be - * described to track the status of the operation. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent location where this - * {@link protos.google.cloud.gkemulticloud.v1.AzureClient|AzureClient} resource will be - * created. - * - * Location names are formatted as `projects//locations/`. - * - * See [Resource Names](https://cloud.google.com/apis/design/resource_names) - * for more details on Google Cloud resource names. - * @param {google.cloud.gkemulticloud.v1.AzureClient} request.azureClient - * Required. The specification of the - * {@link protos.google.cloud.gkemulticloud.v1.AzureClient|AzureClient} to create. - * @param {string} request.azureClientId - * Required. A client provided ID the resource. Must be unique within the - * parent resource. - * - * The provided ID will be part of the - * {@link protos.google.cloud.gkemulticloud.v1.AzureClient|AzureClient} resource name - * formatted as - * `projects//locations//azureClients/`. - * - * Valid characters are `/{@link protos.0-9|a-z}-/`. Cannot be longer than 63 characters. - * @param {boolean} request.validateOnly - * If set, only validate the request, but do not actually create the client. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/azure_clusters.create_azure_client.js - * region_tag:gkemulticloud_v1_generated_AzureClusters_CreateAzureClient_async - * @deprecated CreateAzureClient is deprecated and may be removed in a future version. - */ + /** + * Creates a new {@link protos.google.cloud.gkemulticloud.v1.AzureClient|AzureClient} + * resource on a given Google Cloud project and region. + * + * `AzureClient` resources hold client authentication + * information needed by the Anthos Multicloud API to manage Azure resources + * on your Azure subscription on your behalf. + * + * If successful, the response contains a newly created + * {@link protos.google.longrunning.Operation|Operation} resource that can be + * described to track the status of the operation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent location where this + * {@link protos.google.cloud.gkemulticloud.v1.AzureClient|AzureClient} resource will be + * created. + * + * Location names are formatted as `projects//locations/`. + * + * See [Resource Names](https://cloud.google.com/apis/design/resource_names) + * for more details on Google Cloud resource names. + * @param {google.cloud.gkemulticloud.v1.AzureClient} request.azureClient + * Required. The specification of the + * {@link protos.google.cloud.gkemulticloud.v1.AzureClient|AzureClient} to create. + * @param {string} request.azureClientId + * Required. A client provided ID the resource. Must be unique within the + * parent resource. + * + * The provided ID will be part of the + * {@link protos.google.cloud.gkemulticloud.v1.AzureClient|AzureClient} resource name + * formatted as + * `projects//locations//azureClients/`. + * + * Valid characters are `/{@link protos.0-9|a-z}-/`. Cannot be longer than 63 characters. + * @param {boolean} request.validateOnly + * If set, only validate the request, but do not actually create the client. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/azure_clusters.create_azure_client.js + * region_tag:gkemulticloud_v1_generated_AzureClusters_CreateAzureClient_async + * @deprecated CreateAzureClient is deprecated and may be removed in a future version. + */ createAzureClient( - request?: protos.google.cloud.gkemulticloud.v1.ICreateAzureClientRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkemulticloud.v1.ICreateAzureClientRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.gkemulticloud.v1.IAzureClient, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createAzureClient( - request: protos.google.cloud.gkemulticloud.v1.ICreateAzureClientRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.ICreateAzureClientRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAzureClient, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createAzureClient( - request: protos.google.cloud.gkemulticloud.v1.ICreateAzureClientRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.ICreateAzureClientRequest, + callback: Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAzureClient, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createAzureClient( - request?: protos.google.cloud.gkemulticloud.v1.ICreateAzureClientRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.gkemulticloud.v1.ICreateAzureClientRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAzureClient, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAzureClient, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.gkemulticloud.v1.IAzureClient, + protos.google.cloud.gkemulticloud.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}); - this.warn('DEP$AzureClusters-$CreateAzureClient','CreateAzureClient is deprecated and may be removed in a future version.', 'DeprecationWarning'); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + this.warn( + 'DEP$AzureClusters-$CreateAzureClient', + 'CreateAzureClient is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAzureClient, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createAzureClient response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createAzureClient request %j', request); - return this.innerApiCalls.createAzureClient(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createAzureClient response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createAzureClient(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.gkemulticloud.v1.IAzureClient, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createAzureClient response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createAzureClient()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/azure_clusters.create_azure_client.js - * region_tag:gkemulticloud_v1_generated_AzureClusters_CreateAzureClient_async - * @deprecated CreateAzureClient is deprecated and may be removed in a future version. - */ - async checkCreateAzureClientProgress(name: string): Promise>{ - this.warn('DEP$AzureClusters-$checkCreateAzureClientProgress','checkCreateAzureClientProgress is deprecated and may be removed in a future version.', 'DeprecationWarning'); + /** + * Check the status of the long running operation returned by `createAzureClient()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/azure_clusters.create_azure_client.js + * region_tag:gkemulticloud_v1_generated_AzureClusters_CreateAzureClient_async + * @deprecated CreateAzureClient is deprecated and may be removed in a future version. + */ + async checkCreateAzureClientProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.gkemulticloud.v1.AzureClient, + protos.google.cloud.gkemulticloud.v1.OperationMetadata + > + > { + this.warn( + 'DEP$AzureClusters-$checkCreateAzureClientProgress', + 'checkCreateAzureClientProgress is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); this._log.info('createAzureClient long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createAzureClient, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createAzureClient, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.gkemulticloud.v1.AzureClient, + protos.google.cloud.gkemulticloud.v1.OperationMetadata + >; } -/** - * Deletes a specific {@link protos.google.cloud.gkemulticloud.v1.AzureClient|AzureClient} - * resource. - * - * If the client is used by one or more clusters, deletion will - * fail and a `FAILED_PRECONDITION` error will be returned. - * - * If successful, the response contains a newly created - * {@link protos.google.longrunning.Operation|Operation} resource that can be - * described to track the status of the operation. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name the - * {@link protos.google.cloud.gkemulticloud.v1.AzureClient|AzureClient} to delete. - * - * {@link protos.google.cloud.gkemulticloud.v1.AzureClient|AzureClient} names are - * formatted as - * `projects//locations//azureClients/`. - * - * See [Resource Names](https://cloud.google.com/apis/design/resource_names) - * for more details on Google Cloud resource names. - * @param {boolean} request.allowMissing - * If set to true, and the - * {@link protos.google.cloud.gkemulticloud.v1.AzureClient|AzureClient} resource is not - * found, the request will succeed but no action will be taken on the server - * and a completed {@link protos.google.longrunning.Operation|Operation} will be returned. - * - * Useful for idempotent deletion. - * @param {boolean} request.validateOnly - * If set, only validate the request, but do not actually delete 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/azure_clusters.delete_azure_client.js - * region_tag:gkemulticloud_v1_generated_AzureClusters_DeleteAzureClient_async - * @deprecated DeleteAzureClient is deprecated and may be removed in a future version. - */ + /** + * Deletes a specific {@link protos.google.cloud.gkemulticloud.v1.AzureClient|AzureClient} + * resource. + * + * If the client is used by one or more clusters, deletion will + * fail and a `FAILED_PRECONDITION` error will be returned. + * + * If successful, the response contains a newly created + * {@link protos.google.longrunning.Operation|Operation} resource that can be + * described to track the status of the operation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name the + * {@link protos.google.cloud.gkemulticloud.v1.AzureClient|AzureClient} to delete. + * + * {@link protos.google.cloud.gkemulticloud.v1.AzureClient|AzureClient} names are + * formatted as + * `projects//locations//azureClients/`. + * + * See [Resource Names](https://cloud.google.com/apis/design/resource_names) + * for more details on Google Cloud resource names. + * @param {boolean} request.allowMissing + * If set to true, and the + * {@link protos.google.cloud.gkemulticloud.v1.AzureClient|AzureClient} resource is not + * found, the request will succeed but no action will be taken on the server + * and a completed {@link protos.google.longrunning.Operation|Operation} will be returned. + * + * Useful for idempotent deletion. + * @param {boolean} request.validateOnly + * If set, only validate the request, but do not actually delete 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/azure_clusters.delete_azure_client.js + * region_tag:gkemulticloud_v1_generated_AzureClusters_DeleteAzureClient_async + * @deprecated DeleteAzureClient is deprecated and may be removed in a future version. + */ deleteAzureClient( - request?: protos.google.cloud.gkemulticloud.v1.IDeleteAzureClientRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkemulticloud.v1.IDeleteAzureClientRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteAzureClient( - request: protos.google.cloud.gkemulticloud.v1.IDeleteAzureClientRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IDeleteAzureClientRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteAzureClient( - request: protos.google.cloud.gkemulticloud.v1.IDeleteAzureClientRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IDeleteAzureClientRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteAzureClient( - request?: protos.google.cloud.gkemulticloud.v1.IDeleteAzureClientRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.gkemulticloud.v1.IDeleteAzureClientRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkemulticloud.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}); - this.warn('DEP$AzureClusters-$DeleteAzureClient','DeleteAzureClient is deprecated and may be removed in a future version.', 'DeprecationWarning'); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + this.warn( + 'DEP$AzureClusters-$DeleteAzureClient', + 'DeleteAzureClient is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteAzureClient response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteAzureClient request %j', request); - return this.innerApiCalls.deleteAzureClient(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteAzureClient response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteAzureClient(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteAzureClient response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteAzureClient()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/azure_clusters.delete_azure_client.js - * region_tag:gkemulticloud_v1_generated_AzureClusters_DeleteAzureClient_async - * @deprecated DeleteAzureClient is deprecated and may be removed in a future version. - */ - async checkDeleteAzureClientProgress(name: string): Promise>{ - this.warn('DEP$AzureClusters-$checkDeleteAzureClientProgress','checkDeleteAzureClientProgress is deprecated and may be removed in a future version.', 'DeprecationWarning'); + /** + * Check the status of the long running operation returned by `deleteAzureClient()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/azure_clusters.delete_azure_client.js + * region_tag:gkemulticloud_v1_generated_AzureClusters_DeleteAzureClient_async + * @deprecated DeleteAzureClient is deprecated and may be removed in a future version. + */ + async checkDeleteAzureClientProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.gkemulticloud.v1.OperationMetadata + > + > { + this.warn( + 'DEP$AzureClusters-$checkDeleteAzureClientProgress', + 'checkDeleteAzureClientProgress is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); this._log.info('deleteAzureClient long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteAzureClient, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteAzureClient, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.gkemulticloud.v1.OperationMetadata + >; } -/** - * Creates a new {@link protos.google.cloud.gkemulticloud.v1.AzureCluster|AzureCluster} - * resource on a given Google Cloud Platform project and region. - * - * If successful, the response contains a newly created - * {@link protos.google.longrunning.Operation|Operation} resource that can be - * described to track the status of the operation. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent location where this - * {@link protos.google.cloud.gkemulticloud.v1.AzureCluster|AzureCluster} resource will be - * created. - * - * Location names are formatted as `projects//locations/`. - * - * See [Resource Names](https://cloud.google.com/apis/design/resource_names) - * for more details on Google Cloud resource names. - * @param {google.cloud.gkemulticloud.v1.AzureCluster} request.azureCluster - * Required. The specification of the - * {@link protos.google.cloud.gkemulticloud.v1.AzureCluster|AzureCluster} to create. - * @param {string} request.azureClusterId - * Required. A client provided ID the resource. Must be unique within the - * parent resource. - * - * The provided ID will be part of the - * {@link protos.google.cloud.gkemulticloud.v1.AzureCluster|AzureCluster} resource name - * formatted as - * `projects//locations//azureClusters/`. - * - * Valid characters are `/{@link protos.0-9|a-z}-/`. Cannot be longer than 63 characters. - * @param {boolean} request.validateOnly - * If set, only validate the request, but do not actually create the cluster. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/azure_clusters.create_azure_cluster.js - * region_tag:gkemulticloud_v1_generated_AzureClusters_CreateAzureCluster_async - * @deprecated CreateAzureCluster is deprecated and may be removed in a future version. - */ + /** + * Creates a new {@link protos.google.cloud.gkemulticloud.v1.AzureCluster|AzureCluster} + * resource on a given Google Cloud Platform project and region. + * + * If successful, the response contains a newly created + * {@link protos.google.longrunning.Operation|Operation} resource that can be + * described to track the status of the operation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent location where this + * {@link protos.google.cloud.gkemulticloud.v1.AzureCluster|AzureCluster} resource will be + * created. + * + * Location names are formatted as `projects//locations/`. + * + * See [Resource Names](https://cloud.google.com/apis/design/resource_names) + * for more details on Google Cloud resource names. + * @param {google.cloud.gkemulticloud.v1.AzureCluster} request.azureCluster + * Required. The specification of the + * {@link protos.google.cloud.gkemulticloud.v1.AzureCluster|AzureCluster} to create. + * @param {string} request.azureClusterId + * Required. A client provided ID the resource. Must be unique within the + * parent resource. + * + * The provided ID will be part of the + * {@link protos.google.cloud.gkemulticloud.v1.AzureCluster|AzureCluster} resource name + * formatted as + * `projects//locations//azureClusters/`. + * + * Valid characters are `/{@link protos.0-9|a-z}-/`. Cannot be longer than 63 characters. + * @param {boolean} request.validateOnly + * If set, only validate the request, but do not actually create the cluster. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/azure_clusters.create_azure_cluster.js + * region_tag:gkemulticloud_v1_generated_AzureClusters_CreateAzureCluster_async + * @deprecated CreateAzureCluster is deprecated and may be removed in a future version. + */ createAzureCluster( - request?: protos.google.cloud.gkemulticloud.v1.ICreateAzureClusterRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkemulticloud.v1.ICreateAzureClusterRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.gkemulticloud.v1.IAzureCluster, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createAzureCluster( - request: protos.google.cloud.gkemulticloud.v1.ICreateAzureClusterRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.ICreateAzureClusterRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAzureCluster, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createAzureCluster( - request: protos.google.cloud.gkemulticloud.v1.ICreateAzureClusterRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.ICreateAzureClusterRequest, + callback: Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAzureCluster, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createAzureCluster( - request?: protos.google.cloud.gkemulticloud.v1.ICreateAzureClusterRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.gkemulticloud.v1.ICreateAzureClusterRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAzureCluster, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAzureCluster, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.gkemulticloud.v1.IAzureCluster, + protos.google.cloud.gkemulticloud.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}); - this.warn('DEP$AzureClusters-$CreateAzureCluster','CreateAzureCluster is deprecated and may be removed in a future version.', 'DeprecationWarning'); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + this.warn( + 'DEP$AzureClusters-$CreateAzureCluster', + 'CreateAzureCluster is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAzureCluster, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createAzureCluster response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createAzureCluster request %j', request); - return this.innerApiCalls.createAzureCluster(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createAzureCluster response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createAzureCluster(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.gkemulticloud.v1.IAzureCluster, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createAzureCluster response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createAzureCluster()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/azure_clusters.create_azure_cluster.js - * region_tag:gkemulticloud_v1_generated_AzureClusters_CreateAzureCluster_async - * @deprecated CreateAzureCluster is deprecated and may be removed in a future version. - */ - async checkCreateAzureClusterProgress(name: string): Promise>{ - this.warn('DEP$AzureClusters-$checkCreateAzureClusterProgress','checkCreateAzureClusterProgress is deprecated and may be removed in a future version.', 'DeprecationWarning'); + /** + * Check the status of the long running operation returned by `createAzureCluster()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/azure_clusters.create_azure_cluster.js + * region_tag:gkemulticloud_v1_generated_AzureClusters_CreateAzureCluster_async + * @deprecated CreateAzureCluster is deprecated and may be removed in a future version. + */ + async checkCreateAzureClusterProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.gkemulticloud.v1.AzureCluster, + protos.google.cloud.gkemulticloud.v1.OperationMetadata + > + > { + this.warn( + 'DEP$AzureClusters-$checkCreateAzureClusterProgress', + 'checkCreateAzureClusterProgress is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); this._log.info('createAzureCluster long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createAzureCluster, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createAzureCluster, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.gkemulticloud.v1.AzureCluster, + protos.google.cloud.gkemulticloud.v1.OperationMetadata + >; } -/** - * Updates an {@link protos.google.cloud.gkemulticloud.v1.AzureCluster|AzureCluster}. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.gkemulticloud.v1.AzureCluster} request.azureCluster - * Required. The {@link protos.google.cloud.gkemulticloud.v1.AzureCluster|AzureCluster} - * resource to update. - * @param {boolean} request.validateOnly - * If set, only validate the request, but do not actually update the cluster. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. Mask of fields to update. At least one path must be supplied in - * this field. The elements of the repeated paths field can only include these - * fields from {@link protos.google.cloud.gkemulticloud.v1.AzureCluster|AzureCluster}: - * - * * `description`. - * * `azureClient`. - * * `control_plane.version`. - * * `control_plane.vm_size`. - * * `annotations`. - * * `authorization.admin_users`. - * * `authorization.admin_groups`. - * * `control_plane.root_volume.size_gib`. - * * `azure_services_authentication`. - * * `azure_services_authentication.tenant_id`. - * * `azure_services_authentication.application_id`. - * * `control_plane.proxy_config`. - * * `control_plane.proxy_config.resource_group_id`. - * * `control_plane.proxy_config.secret_id`. - * * `control_plane.ssh_config.authorized_key`. - * * `logging_config.component_config.enable_components` - * * `monitoring_config.managed_prometheus_config.enabled`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/azure_clusters.update_azure_cluster.js - * region_tag:gkemulticloud_v1_generated_AzureClusters_UpdateAzureCluster_async - * @deprecated UpdateAzureCluster is deprecated and may be removed in a future version. - */ + /** + * Updates an {@link protos.google.cloud.gkemulticloud.v1.AzureCluster|AzureCluster}. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.gkemulticloud.v1.AzureCluster} request.azureCluster + * Required. The {@link protos.google.cloud.gkemulticloud.v1.AzureCluster|AzureCluster} + * resource to update. + * @param {boolean} request.validateOnly + * If set, only validate the request, but do not actually update the cluster. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. Mask of fields to update. At least one path must be supplied in + * this field. The elements of the repeated paths field can only include these + * fields from {@link protos.google.cloud.gkemulticloud.v1.AzureCluster|AzureCluster}: + * + * * `description`. + * * `azureClient`. + * * `control_plane.version`. + * * `control_plane.vm_size`. + * * `annotations`. + * * `authorization.admin_users`. + * * `authorization.admin_groups`. + * * `control_plane.root_volume.size_gib`. + * * `azure_services_authentication`. + * * `azure_services_authentication.tenant_id`. + * * `azure_services_authentication.application_id`. + * * `control_plane.proxy_config`. + * * `control_plane.proxy_config.resource_group_id`. + * * `control_plane.proxy_config.secret_id`. + * * `control_plane.ssh_config.authorized_key`. + * * `logging_config.component_config.enable_components` + * * `monitoring_config.managed_prometheus_config.enabled`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/azure_clusters.update_azure_cluster.js + * region_tag:gkemulticloud_v1_generated_AzureClusters_UpdateAzureCluster_async + * @deprecated UpdateAzureCluster is deprecated and may be removed in a future version. + */ updateAzureCluster( - request?: protos.google.cloud.gkemulticloud.v1.IUpdateAzureClusterRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkemulticloud.v1.IUpdateAzureClusterRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.gkemulticloud.v1.IAzureCluster, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateAzureCluster( - request: protos.google.cloud.gkemulticloud.v1.IUpdateAzureClusterRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IUpdateAzureClusterRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAzureCluster, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateAzureCluster( - request: protos.google.cloud.gkemulticloud.v1.IUpdateAzureClusterRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IUpdateAzureClusterRequest, + callback: Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAzureCluster, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateAzureCluster( - request?: protos.google.cloud.gkemulticloud.v1.IUpdateAzureClusterRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.gkemulticloud.v1.IUpdateAzureClusterRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAzureCluster, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAzureCluster, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.gkemulticloud.v1.IAzureCluster, + protos.google.cloud.gkemulticloud.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({ - 'azure_cluster.name': request.azureCluster!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'azure_cluster.name': request.azureCluster!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - this.warn('DEP$AzureClusters-$UpdateAzureCluster','UpdateAzureCluster is deprecated and may be removed in a future version.', 'DeprecationWarning'); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + this.warn( + 'DEP$AzureClusters-$UpdateAzureCluster', + 'UpdateAzureCluster is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAzureCluster, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateAzureCluster response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateAzureCluster request %j', request); - return this.innerApiCalls.updateAzureCluster(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateAzureCluster response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateAzureCluster(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.gkemulticloud.v1.IAzureCluster, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateAzureCluster response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateAzureCluster()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/azure_clusters.update_azure_cluster.js - * region_tag:gkemulticloud_v1_generated_AzureClusters_UpdateAzureCluster_async - * @deprecated UpdateAzureCluster is deprecated and may be removed in a future version. - */ - async checkUpdateAzureClusterProgress(name: string): Promise>{ - this.warn('DEP$AzureClusters-$checkUpdateAzureClusterProgress','checkUpdateAzureClusterProgress is deprecated and may be removed in a future version.', 'DeprecationWarning'); + /** + * Check the status of the long running operation returned by `updateAzureCluster()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/azure_clusters.update_azure_cluster.js + * region_tag:gkemulticloud_v1_generated_AzureClusters_UpdateAzureCluster_async + * @deprecated UpdateAzureCluster is deprecated and may be removed in a future version. + */ + async checkUpdateAzureClusterProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.gkemulticloud.v1.AzureCluster, + protos.google.cloud.gkemulticloud.v1.OperationMetadata + > + > { + this.warn( + 'DEP$AzureClusters-$checkUpdateAzureClusterProgress', + 'checkUpdateAzureClusterProgress is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); this._log.info('updateAzureCluster long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.updateAzureCluster, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateAzureCluster, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.gkemulticloud.v1.AzureCluster, + protos.google.cloud.gkemulticloud.v1.OperationMetadata + >; } -/** - * Deletes a specific - * {@link protos.google.cloud.gkemulticloud.v1.AzureCluster|AzureCluster} resource. - * - * Fails if the cluster has one or more associated - * {@link protos.google.cloud.gkemulticloud.v1.AzureNodePool|AzureNodePool} resources. - * - * If successful, the response contains a newly created - * {@link protos.google.longrunning.Operation|Operation} resource that can be - * described to track the status of the operation. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name the - * {@link protos.google.cloud.gkemulticloud.v1.AzureCluster|AzureCluster} to delete. - * - * `AzureCluster` names are formatted as - * `projects//locations//azureClusters/`. - * - * See [Resource Names](https://cloud.google.com/apis/design/resource_names) - * for more details on Google Cloud Platform resource names. - * @param {boolean} request.allowMissing - * If set to true, and the - * {@link protos.google.cloud.gkemulticloud.v1.AzureCluster|AzureCluster} resource is not - * found, the request will succeed but no action will be taken on the server - * and a completed {@link protos.google.longrunning.Operation|Operation} will be returned. - * - * Useful for idempotent deletion. - * @param {boolean} request.validateOnly - * If set, only validate the request, but do not actually delete the resource. - * @param {string} request.etag - * The current etag of the - * {@link protos.google.cloud.gkemulticloud.v1.AzureCluster|AzureCluster}. - * - * Allows clients to perform deletions through optimistic concurrency control. - * - * If the provided etag does not match the current etag of the cluster, - * the request will fail and an ABORTED error will be returned. - * @param {boolean} [request.ignoreErrors] - * Optional. If set to true, the deletion of - * {@link protos.google.cloud.gkemulticloud.v1.AzureCluster|AzureCluster} resource will - * succeed even if errors occur during deleting in cluster resources. Using - * this parameter may result in orphaned resources in the cluster. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/azure_clusters.delete_azure_cluster.js - * region_tag:gkemulticloud_v1_generated_AzureClusters_DeleteAzureCluster_async - * @deprecated DeleteAzureCluster is deprecated and may be removed in a future version. - */ + /** + * Deletes a specific + * {@link protos.google.cloud.gkemulticloud.v1.AzureCluster|AzureCluster} resource. + * + * Fails if the cluster has one or more associated + * {@link protos.google.cloud.gkemulticloud.v1.AzureNodePool|AzureNodePool} resources. + * + * If successful, the response contains a newly created + * {@link protos.google.longrunning.Operation|Operation} resource that can be + * described to track the status of the operation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name the + * {@link protos.google.cloud.gkemulticloud.v1.AzureCluster|AzureCluster} to delete. + * + * `AzureCluster` names are formatted as + * `projects//locations//azureClusters/`. + * + * See [Resource Names](https://cloud.google.com/apis/design/resource_names) + * for more details on Google Cloud Platform resource names. + * @param {boolean} request.allowMissing + * If set to true, and the + * {@link protos.google.cloud.gkemulticloud.v1.AzureCluster|AzureCluster} resource is not + * found, the request will succeed but no action will be taken on the server + * and a completed {@link protos.google.longrunning.Operation|Operation} will be returned. + * + * Useful for idempotent deletion. + * @param {boolean} request.validateOnly + * If set, only validate the request, but do not actually delete the resource. + * @param {string} request.etag + * The current etag of the + * {@link protos.google.cloud.gkemulticloud.v1.AzureCluster|AzureCluster}. + * + * Allows clients to perform deletions through optimistic concurrency control. + * + * If the provided etag does not match the current etag of the cluster, + * the request will fail and an ABORTED error will be returned. + * @param {boolean} [request.ignoreErrors] + * Optional. If set to true, the deletion of + * {@link protos.google.cloud.gkemulticloud.v1.AzureCluster|AzureCluster} resource will + * succeed even if errors occur during deleting in cluster resources. Using + * this parameter may result in orphaned resources in the cluster. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/azure_clusters.delete_azure_cluster.js + * region_tag:gkemulticloud_v1_generated_AzureClusters_DeleteAzureCluster_async + * @deprecated DeleteAzureCluster is deprecated and may be removed in a future version. + */ deleteAzureCluster( - request?: protos.google.cloud.gkemulticloud.v1.IDeleteAzureClusterRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkemulticloud.v1.IDeleteAzureClusterRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteAzureCluster( - request: protos.google.cloud.gkemulticloud.v1.IDeleteAzureClusterRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IDeleteAzureClusterRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteAzureCluster( - request: protos.google.cloud.gkemulticloud.v1.IDeleteAzureClusterRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IDeleteAzureClusterRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteAzureCluster( - request?: protos.google.cloud.gkemulticloud.v1.IDeleteAzureClusterRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.gkemulticloud.v1.IDeleteAzureClusterRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkemulticloud.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}); - this.warn('DEP$AzureClusters-$DeleteAzureCluster','DeleteAzureCluster is deprecated and may be removed in a future version.', 'DeprecationWarning'); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + this.warn( + 'DEP$AzureClusters-$DeleteAzureCluster', + 'DeleteAzureCluster is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteAzureCluster response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteAzureCluster request %j', request); - return this.innerApiCalls.deleteAzureCluster(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteAzureCluster response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteAzureCluster(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteAzureCluster response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteAzureCluster()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/azure_clusters.delete_azure_cluster.js - * region_tag:gkemulticloud_v1_generated_AzureClusters_DeleteAzureCluster_async - * @deprecated DeleteAzureCluster is deprecated and may be removed in a future version. - */ - async checkDeleteAzureClusterProgress(name: string): Promise>{ - this.warn('DEP$AzureClusters-$checkDeleteAzureClusterProgress','checkDeleteAzureClusterProgress is deprecated and may be removed in a future version.', 'DeprecationWarning'); + /** + * Check the status of the long running operation returned by `deleteAzureCluster()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/azure_clusters.delete_azure_cluster.js + * region_tag:gkemulticloud_v1_generated_AzureClusters_DeleteAzureCluster_async + * @deprecated DeleteAzureCluster is deprecated and may be removed in a future version. + */ + async checkDeleteAzureClusterProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.gkemulticloud.v1.OperationMetadata + > + > { + this.warn( + 'DEP$AzureClusters-$checkDeleteAzureClusterProgress', + 'checkDeleteAzureClusterProgress is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); this._log.info('deleteAzureCluster long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteAzureCluster, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteAzureCluster, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.gkemulticloud.v1.OperationMetadata + >; } -/** - * Creates a new {@link protos.google.cloud.gkemulticloud.v1.AzureNodePool|AzureNodePool}, - * attached to a given - * {@link protos.google.cloud.gkemulticloud.v1.AzureCluster|AzureCluster}. - * - * If successful, the response contains a newly created - * {@link protos.google.longrunning.Operation|Operation} resource that can be - * described to track the status of the operation. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The {@link protos.google.cloud.gkemulticloud.v1.AzureCluster|AzureCluster} - * resource where this node pool will be created. - * - * `AzureCluster` names are formatted as - * `projects//locations//azureClusters/`. - * - * See [Resource Names](https://cloud.google.com/apis/design/resource_names) - * for more details on Google Cloud resource names. - * @param {google.cloud.gkemulticloud.v1.AzureNodePool} request.azureNodePool - * Required. The specification of the - * {@link protos.google.cloud.gkemulticloud.v1.AzureNodePool|AzureNodePool} to create. - * @param {string} request.azureNodePoolId - * Required. A client provided ID the resource. Must be unique within the - * parent resource. - * - * The provided ID will be part of the - * {@link protos.google.cloud.gkemulticloud.v1.AzureNodePool|AzureNodePool} resource name - * formatted as - * `projects//locations//azureClusters//azureNodePools/`. - * - * Valid characters are `/{@link protos.0-9|a-z}-/`. Cannot be longer than 63 characters. - * @param {boolean} request.validateOnly - * If set, only validate the request, but do not actually create the node - * pool. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/azure_clusters.create_azure_node_pool.js - * region_tag:gkemulticloud_v1_generated_AzureClusters_CreateAzureNodePool_async - * @deprecated CreateAzureNodePool is deprecated and may be removed in a future version. - */ + /** + * Creates a new {@link protos.google.cloud.gkemulticloud.v1.AzureNodePool|AzureNodePool}, + * attached to a given + * {@link protos.google.cloud.gkemulticloud.v1.AzureCluster|AzureCluster}. + * + * If successful, the response contains a newly created + * {@link protos.google.longrunning.Operation|Operation} resource that can be + * described to track the status of the operation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The {@link protos.google.cloud.gkemulticloud.v1.AzureCluster|AzureCluster} + * resource where this node pool will be created. + * + * `AzureCluster` names are formatted as + * `projects//locations//azureClusters/`. + * + * See [Resource Names](https://cloud.google.com/apis/design/resource_names) + * for more details on Google Cloud resource names. + * @param {google.cloud.gkemulticloud.v1.AzureNodePool} request.azureNodePool + * Required. The specification of the + * {@link protos.google.cloud.gkemulticloud.v1.AzureNodePool|AzureNodePool} to create. + * @param {string} request.azureNodePoolId + * Required. A client provided ID the resource. Must be unique within the + * parent resource. + * + * The provided ID will be part of the + * {@link protos.google.cloud.gkemulticloud.v1.AzureNodePool|AzureNodePool} resource name + * formatted as + * `projects//locations//azureClusters//azureNodePools/`. + * + * Valid characters are `/{@link protos.0-9|a-z}-/`. Cannot be longer than 63 characters. + * @param {boolean} request.validateOnly + * If set, only validate the request, but do not actually create the node + * pool. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/azure_clusters.create_azure_node_pool.js + * region_tag:gkemulticloud_v1_generated_AzureClusters_CreateAzureNodePool_async + * @deprecated CreateAzureNodePool is deprecated and may be removed in a future version. + */ createAzureNodePool( - request?: protos.google.cloud.gkemulticloud.v1.ICreateAzureNodePoolRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkemulticloud.v1.ICreateAzureNodePoolRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.gkemulticloud.v1.IAzureNodePool, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createAzureNodePool( - request: protos.google.cloud.gkemulticloud.v1.ICreateAzureNodePoolRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.ICreateAzureNodePoolRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAzureNodePool, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createAzureNodePool( - request: protos.google.cloud.gkemulticloud.v1.ICreateAzureNodePoolRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.ICreateAzureNodePoolRequest, + callback: Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAzureNodePool, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createAzureNodePool( - request?: protos.google.cloud.gkemulticloud.v1.ICreateAzureNodePoolRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.gkemulticloud.v1.ICreateAzureNodePoolRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAzureNodePool, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAzureNodePool, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.gkemulticloud.v1.IAzureNodePool, + protos.google.cloud.gkemulticloud.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}); - this.warn('DEP$AzureClusters-$CreateAzureNodePool','CreateAzureNodePool is deprecated and may be removed in a future version.', 'DeprecationWarning'); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + this.warn( + 'DEP$AzureClusters-$CreateAzureNodePool', + 'CreateAzureNodePool is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAzureNodePool, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createAzureNodePool response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createAzureNodePool request %j', request); - return this.innerApiCalls.createAzureNodePool(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createAzureNodePool response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createAzureNodePool(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.gkemulticloud.v1.IAzureNodePool, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createAzureNodePool response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createAzureNodePool()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/azure_clusters.create_azure_node_pool.js - * region_tag:gkemulticloud_v1_generated_AzureClusters_CreateAzureNodePool_async - * @deprecated CreateAzureNodePool is deprecated and may be removed in a future version. - */ - async checkCreateAzureNodePoolProgress(name: string): Promise>{ - this.warn('DEP$AzureClusters-$checkCreateAzureNodePoolProgress','checkCreateAzureNodePoolProgress is deprecated and may be removed in a future version.', 'DeprecationWarning'); + /** + * Check the status of the long running operation returned by `createAzureNodePool()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/azure_clusters.create_azure_node_pool.js + * region_tag:gkemulticloud_v1_generated_AzureClusters_CreateAzureNodePool_async + * @deprecated CreateAzureNodePool is deprecated and may be removed in a future version. + */ + async checkCreateAzureNodePoolProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.gkemulticloud.v1.AzureNodePool, + protos.google.cloud.gkemulticloud.v1.OperationMetadata + > + > { + this.warn( + 'DEP$AzureClusters-$checkCreateAzureNodePoolProgress', + 'checkCreateAzureNodePoolProgress is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); this._log.info('createAzureNodePool long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createAzureNodePool, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createAzureNodePool, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.gkemulticloud.v1.AzureNodePool, + protos.google.cloud.gkemulticloud.v1.OperationMetadata + >; } -/** - * Updates an {@link protos.google.cloud.gkemulticloud.v1.AzureNodePool|AzureNodePool}. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.gkemulticloud.v1.AzureNodePool} request.azureNodePool - * Required. The {@link protos.google.cloud.gkemulticloud.v1.AzureNodePool|AzureNodePool} - * resource to update. - * @param {boolean} request.validateOnly - * If set, only validate the request, but don't actually update the node pool. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. Mask of fields to update. At least one path must be supplied in - * this field. The elements of the repeated paths field can only include these - * fields from {@link protos.google.cloud.gkemulticloud.v1.AzureNodePool|AzureNodePool}: - * - * *. `annotations`. - * * `version`. - * * `autoscaling.min_node_count`. - * * `autoscaling.max_node_count`. - * * `config.ssh_config.authorized_key`. - * * `management.auto_repair`. - * * `management`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/azure_clusters.update_azure_node_pool.js - * region_tag:gkemulticloud_v1_generated_AzureClusters_UpdateAzureNodePool_async - * @deprecated UpdateAzureNodePool is deprecated and may be removed in a future version. - */ + /** + * Updates an {@link protos.google.cloud.gkemulticloud.v1.AzureNodePool|AzureNodePool}. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.gkemulticloud.v1.AzureNodePool} request.azureNodePool + * Required. The {@link protos.google.cloud.gkemulticloud.v1.AzureNodePool|AzureNodePool} + * resource to update. + * @param {boolean} request.validateOnly + * If set, only validate the request, but don't actually update the node pool. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. Mask of fields to update. At least one path must be supplied in + * this field. The elements of the repeated paths field can only include these + * fields from {@link protos.google.cloud.gkemulticloud.v1.AzureNodePool|AzureNodePool}: + * + * *. `annotations`. + * * `version`. + * * `autoscaling.min_node_count`. + * * `autoscaling.max_node_count`. + * * `config.ssh_config.authorized_key`. + * * `management.auto_repair`. + * * `management`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/azure_clusters.update_azure_node_pool.js + * region_tag:gkemulticloud_v1_generated_AzureClusters_UpdateAzureNodePool_async + * @deprecated UpdateAzureNodePool is deprecated and may be removed in a future version. + */ updateAzureNodePool( - request?: protos.google.cloud.gkemulticloud.v1.IUpdateAzureNodePoolRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkemulticloud.v1.IUpdateAzureNodePoolRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.gkemulticloud.v1.IAzureNodePool, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateAzureNodePool( - request: protos.google.cloud.gkemulticloud.v1.IUpdateAzureNodePoolRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IUpdateAzureNodePoolRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAzureNodePool, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateAzureNodePool( - request: protos.google.cloud.gkemulticloud.v1.IUpdateAzureNodePoolRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IUpdateAzureNodePoolRequest, + callback: Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAzureNodePool, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateAzureNodePool( - request?: protos.google.cloud.gkemulticloud.v1.IUpdateAzureNodePoolRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.gkemulticloud.v1.IUpdateAzureNodePoolRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAzureNodePool, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAzureNodePool, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.gkemulticloud.v1.IAzureNodePool, + protos.google.cloud.gkemulticloud.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({ - 'azure_node_pool.name': request.azureNodePool!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'azure_node_pool.name': request.azureNodePool!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - this.warn('DEP$AzureClusters-$UpdateAzureNodePool','UpdateAzureNodePool is deprecated and may be removed in a future version.', 'DeprecationWarning'); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + this.warn( + 'DEP$AzureClusters-$UpdateAzureNodePool', + 'UpdateAzureNodePool is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.gkemulticloud.v1.IAzureNodePool, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateAzureNodePool response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateAzureNodePool request %j', request); - return this.innerApiCalls.updateAzureNodePool(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateAzureNodePool response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateAzureNodePool(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.gkemulticloud.v1.IAzureNodePool, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateAzureNodePool response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateAzureNodePool()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/azure_clusters.update_azure_node_pool.js - * region_tag:gkemulticloud_v1_generated_AzureClusters_UpdateAzureNodePool_async - * @deprecated UpdateAzureNodePool is deprecated and may be removed in a future version. - */ - async checkUpdateAzureNodePoolProgress(name: string): Promise>{ - this.warn('DEP$AzureClusters-$checkUpdateAzureNodePoolProgress','checkUpdateAzureNodePoolProgress is deprecated and may be removed in a future version.', 'DeprecationWarning'); + /** + * Check the status of the long running operation returned by `updateAzureNodePool()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/azure_clusters.update_azure_node_pool.js + * region_tag:gkemulticloud_v1_generated_AzureClusters_UpdateAzureNodePool_async + * @deprecated UpdateAzureNodePool is deprecated and may be removed in a future version. + */ + async checkUpdateAzureNodePoolProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.gkemulticloud.v1.AzureNodePool, + protos.google.cloud.gkemulticloud.v1.OperationMetadata + > + > { + this.warn( + 'DEP$AzureClusters-$checkUpdateAzureNodePoolProgress', + 'checkUpdateAzureNodePoolProgress is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); this._log.info('updateAzureNodePool long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.updateAzureNodePool, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateAzureNodePool, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.gkemulticloud.v1.AzureNodePool, + protos.google.cloud.gkemulticloud.v1.OperationMetadata + >; } -/** - * Deletes a specific - * {@link protos.google.cloud.gkemulticloud.v1.AzureNodePool|AzureNodePool} resource. - * - * If successful, the response contains a newly created - * {@link protos.google.longrunning.Operation|Operation} resource that can be - * described to track the status of the operation. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name the - * {@link protos.google.cloud.gkemulticloud.v1.AzureNodePool|AzureNodePool} to delete. - * - * `AzureNodePool` names are formatted as - * `projects//locations//azureClusters//azureNodePools/`. - * - * See [Resource Names](https://cloud.google.com/apis/design/resource_names) - * for more details on Google Cloud resource names. - * @param {boolean} request.validateOnly - * If set, only validate the request, but do not actually delete the node - * pool. - * @param {boolean} request.allowMissing - * If set to true, and the - * {@link protos.google.cloud.gkemulticloud.v1.AzureNodePool|AzureNodePool} resource is - * not found, the request will succeed but no action will be taken on the - * server and a completed {@link protos.google.longrunning.Operation|Operation} will be - * returned. - * - * Useful for idempotent deletion. - * @param {string} request.etag - * The current ETag of the - * {@link protos.google.cloud.gkemulticloud.v1.AzureNodePool|AzureNodePool}. - * - * Allows clients to perform deletions through optimistic concurrency control. - * - * If the provided ETag does not match the current etag of the node pool, - * the request will fail and an ABORTED error will be returned. - * @param {boolean} [request.ignoreErrors] - * Optional. If set to true, the deletion of - * {@link protos.google.cloud.gkemulticloud.v1.AzureNodePool|AzureNodePool} resource will - * succeed even if errors occur during deleting in node pool resources. Using - * this parameter may result in orphaned resources in the node pool. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/azure_clusters.delete_azure_node_pool.js - * region_tag:gkemulticloud_v1_generated_AzureClusters_DeleteAzureNodePool_async - * @deprecated DeleteAzureNodePool is deprecated and may be removed in a future version. - */ + /** + * Deletes a specific + * {@link protos.google.cloud.gkemulticloud.v1.AzureNodePool|AzureNodePool} resource. + * + * If successful, the response contains a newly created + * {@link protos.google.longrunning.Operation|Operation} resource that can be + * described to track the status of the operation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name the + * {@link protos.google.cloud.gkemulticloud.v1.AzureNodePool|AzureNodePool} to delete. + * + * `AzureNodePool` names are formatted as + * `projects//locations//azureClusters//azureNodePools/`. + * + * See [Resource Names](https://cloud.google.com/apis/design/resource_names) + * for more details on Google Cloud resource names. + * @param {boolean} request.validateOnly + * If set, only validate the request, but do not actually delete the node + * pool. + * @param {boolean} request.allowMissing + * If set to true, and the + * {@link protos.google.cloud.gkemulticloud.v1.AzureNodePool|AzureNodePool} resource is + * not found, the request will succeed but no action will be taken on the + * server and a completed {@link protos.google.longrunning.Operation|Operation} will be + * returned. + * + * Useful for idempotent deletion. + * @param {string} request.etag + * The current ETag of the + * {@link protos.google.cloud.gkemulticloud.v1.AzureNodePool|AzureNodePool}. + * + * Allows clients to perform deletions through optimistic concurrency control. + * + * If the provided ETag does not match the current etag of the node pool, + * the request will fail and an ABORTED error will be returned. + * @param {boolean} [request.ignoreErrors] + * Optional. If set to true, the deletion of + * {@link protos.google.cloud.gkemulticloud.v1.AzureNodePool|AzureNodePool} resource will + * succeed even if errors occur during deleting in node pool resources. Using + * this parameter may result in orphaned resources in the node pool. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/azure_clusters.delete_azure_node_pool.js + * region_tag:gkemulticloud_v1_generated_AzureClusters_DeleteAzureNodePool_async + * @deprecated DeleteAzureNodePool is deprecated and may be removed in a future version. + */ deleteAzureNodePool( - request?: protos.google.cloud.gkemulticloud.v1.IDeleteAzureNodePoolRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkemulticloud.v1.IDeleteAzureNodePoolRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteAzureNodePool( - request: protos.google.cloud.gkemulticloud.v1.IDeleteAzureNodePoolRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IDeleteAzureNodePoolRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteAzureNodePool( - request: protos.google.cloud.gkemulticloud.v1.IDeleteAzureNodePoolRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkemulticloud.v1.IDeleteAzureNodePoolRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteAzureNodePool( - request?: protos.google.cloud.gkemulticloud.v1.IDeleteAzureNodePoolRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.gkemulticloud.v1.IDeleteAzureNodePoolRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkemulticloud.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}); - this.warn('DEP$AzureClusters-$DeleteAzureNodePool','DeleteAzureNodePool is deprecated and may be removed in a future version.', 'DeprecationWarning'); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + this.warn( + 'DEP$AzureClusters-$DeleteAzureNodePool', + 'DeleteAzureNodePool is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteAzureNodePool response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteAzureNodePool request %j', request); - return this.innerApiCalls.deleteAzureNodePool(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteAzureNodePool response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteAzureNodePool(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteAzureNodePool response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteAzureNodePool()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/azure_clusters.delete_azure_node_pool.js - * region_tag:gkemulticloud_v1_generated_AzureClusters_DeleteAzureNodePool_async - * @deprecated DeleteAzureNodePool is deprecated and may be removed in a future version. - */ - async checkDeleteAzureNodePoolProgress(name: string): Promise>{ - this.warn('DEP$AzureClusters-$checkDeleteAzureNodePoolProgress','checkDeleteAzureNodePoolProgress is deprecated and may be removed in a future version.', 'DeprecationWarning'); + /** + * Check the status of the long running operation returned by `deleteAzureNodePool()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/azure_clusters.delete_azure_node_pool.js + * region_tag:gkemulticloud_v1_generated_AzureClusters_DeleteAzureNodePool_async + * @deprecated DeleteAzureNodePool is deprecated and may be removed in a future version. + */ + async checkDeleteAzureNodePoolProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.gkemulticloud.v1.OperationMetadata + > + > { + this.warn( + 'DEP$AzureClusters-$checkDeleteAzureNodePoolProgress', + 'checkDeleteAzureNodePoolProgress is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); this._log.info('deleteAzureNodePool long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteAzureNodePool, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists all {@link protos.google.cloud.gkemulticloud.v1.AzureClient|AzureClient} - * resources on a given Google Cloud project and region. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent location which owns this collection of - * {@link protos.google.cloud.gkemulticloud.v1.AzureClient|AzureClient} resources. - * - * Location names are formatted as `projects//locations/`. - * - * See [Resource Names](https://cloud.google.com/apis/design/resource_names) - * for more details on Google Cloud Platform resource names. - * @param {number} request.pageSize - * The maximum number of items to return. - * - * If not specified, a default value of 50 will be used by the service. - * Regardless of the pageSize value, the response can include a partial list - * and a caller should only rely on response's - * {@link protos.google.cloud.gkemulticloud.v1.ListAzureClientsResponse.next_page_token|nextPageToken} - * to determine if there are more instances left to be queried. - * @param {string} request.pageToken - * The `nextPageToken` value returned from a previous - * {@link protos.google.cloud.gkemulticloud.v1.AzureClusters.ListAzureClients|azureClients.list} - * request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link protos.google.cloud.gkemulticloud.v1.AzureClient|AzureClient}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listAzureClientsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @deprecated ListAzureClients is deprecated and may be removed in a future version. - */ + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteAzureNodePool, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.gkemulticloud.v1.OperationMetadata + >; + } + /** + * Lists all {@link protos.google.cloud.gkemulticloud.v1.AzureClient|AzureClient} + * resources on a given Google Cloud project and region. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent location which owns this collection of + * {@link protos.google.cloud.gkemulticloud.v1.AzureClient|AzureClient} resources. + * + * Location names are formatted as `projects//locations/`. + * + * See [Resource Names](https://cloud.google.com/apis/design/resource_names) + * for more details on Google Cloud Platform resource names. + * @param {number} request.pageSize + * The maximum number of items to return. + * + * If not specified, a default value of 50 will be used by the service. + * Regardless of the pageSize value, the response can include a partial list + * and a caller should only rely on response's + * {@link protos.google.cloud.gkemulticloud.v1.ListAzureClientsResponse.next_page_token|nextPageToken} + * to determine if there are more instances left to be queried. + * @param {string} request.pageToken + * The `nextPageToken` value returned from a previous + * {@link protos.google.cloud.gkemulticloud.v1.AzureClusters.ListAzureClients|azureClients.list} + * request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.gkemulticloud.v1.AzureClient|AzureClient}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listAzureClientsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @deprecated ListAzureClients is deprecated and may be removed in a future version. + */ listAzureClients( - request?: protos.google.cloud.gkemulticloud.v1.IListAzureClientsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gkemulticloud.v1.IAzureClient[], - protos.google.cloud.gkemulticloud.v1.IListAzureClientsRequest|null, - protos.google.cloud.gkemulticloud.v1.IListAzureClientsResponse - ]>; + request?: protos.google.cloud.gkemulticloud.v1.IListAzureClientsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gkemulticloud.v1.IAzureClient[], + protos.google.cloud.gkemulticloud.v1.IListAzureClientsRequest | null, + protos.google.cloud.gkemulticloud.v1.IListAzureClientsResponse, + ] + >; listAzureClients( - request: protos.google.cloud.gkemulticloud.v1.IListAzureClientsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.gkemulticloud.v1.IListAzureClientsRequest, - protos.google.cloud.gkemulticloud.v1.IListAzureClientsResponse|null|undefined, - protos.google.cloud.gkemulticloud.v1.IAzureClient>): void; + request: protos.google.cloud.gkemulticloud.v1.IListAzureClientsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.gkemulticloud.v1.IListAzureClientsRequest, + | protos.google.cloud.gkemulticloud.v1.IListAzureClientsResponse + | null + | undefined, + protos.google.cloud.gkemulticloud.v1.IAzureClient + >, + ): void; listAzureClients( - request: protos.google.cloud.gkemulticloud.v1.IListAzureClientsRequest, - callback: PaginationCallback< - protos.google.cloud.gkemulticloud.v1.IListAzureClientsRequest, - protos.google.cloud.gkemulticloud.v1.IListAzureClientsResponse|null|undefined, - protos.google.cloud.gkemulticloud.v1.IAzureClient>): void; + request: protos.google.cloud.gkemulticloud.v1.IListAzureClientsRequest, + callback: PaginationCallback< + protos.google.cloud.gkemulticloud.v1.IListAzureClientsRequest, + | protos.google.cloud.gkemulticloud.v1.IListAzureClientsResponse + | null + | undefined, + protos.google.cloud.gkemulticloud.v1.IAzureClient + >, + ): void; listAzureClients( - request?: protos.google.cloud.gkemulticloud.v1.IListAzureClientsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.gkemulticloud.v1.IListAzureClientsRequest, - protos.google.cloud.gkemulticloud.v1.IListAzureClientsResponse|null|undefined, - protos.google.cloud.gkemulticloud.v1.IAzureClient>, - callback?: PaginationCallback< + request?: protos.google.cloud.gkemulticloud.v1.IListAzureClientsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.gkemulticloud.v1.IListAzureClientsRequest, - protos.google.cloud.gkemulticloud.v1.IListAzureClientsResponse|null|undefined, - protos.google.cloud.gkemulticloud.v1.IAzureClient>): - Promise<[ - protos.google.cloud.gkemulticloud.v1.IAzureClient[], - protos.google.cloud.gkemulticloud.v1.IListAzureClientsRequest|null, - protos.google.cloud.gkemulticloud.v1.IListAzureClientsResponse - ]>|void { + | protos.google.cloud.gkemulticloud.v1.IListAzureClientsResponse + | null + | undefined, + protos.google.cloud.gkemulticloud.v1.IAzureClient + >, + callback?: PaginationCallback< + protos.google.cloud.gkemulticloud.v1.IListAzureClientsRequest, + | protos.google.cloud.gkemulticloud.v1.IListAzureClientsResponse + | null + | undefined, + protos.google.cloud.gkemulticloud.v1.IAzureClient + >, + ): Promise< + [ + protos.google.cloud.gkemulticloud.v1.IAzureClient[], + protos.google.cloud.gkemulticloud.v1.IListAzureClientsRequest | null, + protos.google.cloud.gkemulticloud.v1.IListAzureClientsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.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.warn('DEP$AzureClusters-$ListAzureClients','ListAzureClients is deprecated and may be removed in a future version.', 'DeprecationWarning'); - const wrappedCallback: PaginationCallback< - protos.google.cloud.gkemulticloud.v1.IListAzureClientsRequest, - protos.google.cloud.gkemulticloud.v1.IListAzureClientsResponse|null|undefined, - protos.google.cloud.gkemulticloud.v1.IAzureClient>|undefined = callback + this.warn( + 'DEP$AzureClusters-$ListAzureClients', + 'ListAzureClients is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.gkemulticloud.v1.IListAzureClientsRequest, + | protos.google.cloud.gkemulticloud.v1.IListAzureClientsResponse + | null + | undefined, + protos.google.cloud.gkemulticloud.v1.IAzureClient + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listAzureClients values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -2515,238 +3643,279 @@ export class AzureClustersClient { this._log.info('listAzureClients request %j', request); return this.innerApiCalls .listAzureClients(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.gkemulticloud.v1.IAzureClient[], - protos.google.cloud.gkemulticloud.v1.IListAzureClientsRequest|null, - protos.google.cloud.gkemulticloud.v1.IListAzureClientsResponse - ]) => { - this._log.info('listAzureClients values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.gkemulticloud.v1.IAzureClient[], + protos.google.cloud.gkemulticloud.v1.IListAzureClientsRequest | null, + protos.google.cloud.gkemulticloud.v1.IListAzureClientsResponse, + ]) => { + this._log.info('listAzureClients values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listAzureClients`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent location which owns this collection of - * {@link protos.google.cloud.gkemulticloud.v1.AzureClient|AzureClient} resources. - * - * Location names are formatted as `projects//locations/`. - * - * See [Resource Names](https://cloud.google.com/apis/design/resource_names) - * for more details on Google Cloud Platform resource names. - * @param {number} request.pageSize - * The maximum number of items to return. - * - * If not specified, a default value of 50 will be used by the service. - * Regardless of the pageSize value, the response can include a partial list - * and a caller should only rely on response's - * {@link protos.google.cloud.gkemulticloud.v1.ListAzureClientsResponse.next_page_token|nextPageToken} - * to determine if there are more instances left to be queried. - * @param {string} request.pageToken - * The `nextPageToken` value returned from a previous - * {@link protos.google.cloud.gkemulticloud.v1.AzureClusters.ListAzureClients|azureClients.list} - * request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.gkemulticloud.v1.AzureClient|AzureClient} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listAzureClientsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @deprecated ListAzureClients is deprecated and may be removed in a future version. - */ + /** + * Equivalent to `listAzureClients`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent location which owns this collection of + * {@link protos.google.cloud.gkemulticloud.v1.AzureClient|AzureClient} resources. + * + * Location names are formatted as `projects//locations/`. + * + * See [Resource Names](https://cloud.google.com/apis/design/resource_names) + * for more details on Google Cloud Platform resource names. + * @param {number} request.pageSize + * The maximum number of items to return. + * + * If not specified, a default value of 50 will be used by the service. + * Regardless of the pageSize value, the response can include a partial list + * and a caller should only rely on response's + * {@link protos.google.cloud.gkemulticloud.v1.ListAzureClientsResponse.next_page_token|nextPageToken} + * to determine if there are more instances left to be queried. + * @param {string} request.pageToken + * The `nextPageToken` value returned from a previous + * {@link protos.google.cloud.gkemulticloud.v1.AzureClusters.ListAzureClients|azureClients.list} + * request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.gkemulticloud.v1.AzureClient|AzureClient} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listAzureClientsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @deprecated ListAzureClients is deprecated and may be removed in a future version. + */ listAzureClientsStream( - request?: protos.google.cloud.gkemulticloud.v1.IListAzureClientsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.gkemulticloud.v1.IListAzureClientsRequest, + 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['listAzureClients']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); - this.warn('DEP$AzureClusters-$ListAzureClients','ListAzureClients is deprecated and may be removed in a future version.', 'DeprecationWarning'); + this.initialize().catch((err) => { + throw err; + }); + this.warn( + 'DEP$AzureClusters-$ListAzureClients', + 'ListAzureClients is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); this._log.info('listAzureClients stream %j', request); return this.descriptors.page.listAzureClients.createStream( this.innerApiCalls.listAzureClients as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listAzureClients`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used 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 location which owns this collection of - * {@link protos.google.cloud.gkemulticloud.v1.AzureClient|AzureClient} resources. - * - * Location names are formatted as `projects//locations/`. - * - * See [Resource Names](https://cloud.google.com/apis/design/resource_names) - * for more details on Google Cloud Platform resource names. - * @param {number} request.pageSize - * The maximum number of items to return. - * - * If not specified, a default value of 50 will be used by the service. - * Regardless of the pageSize value, the response can include a partial list - * and a caller should only rely on response's - * {@link protos.google.cloud.gkemulticloud.v1.ListAzureClientsResponse.next_page_token|nextPageToken} - * to determine if there are more instances left to be queried. - * @param {string} request.pageToken - * The `nextPageToken` value returned from a previous - * {@link protos.google.cloud.gkemulticloud.v1.AzureClusters.ListAzureClients|azureClients.list} - * request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.gkemulticloud.v1.AzureClient|AzureClient}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@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/azure_clusters.list_azure_clients.js - * region_tag:gkemulticloud_v1_generated_AzureClusters_ListAzureClients_async - * @deprecated ListAzureClients is deprecated and may be removed in a future version. - */ + /** + * Equivalent to `listAzureClients`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used 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 location which owns this collection of + * {@link protos.google.cloud.gkemulticloud.v1.AzureClient|AzureClient} resources. + * + * Location names are formatted as `projects//locations/`. + * + * See [Resource Names](https://cloud.google.com/apis/design/resource_names) + * for more details on Google Cloud Platform resource names. + * @param {number} request.pageSize + * The maximum number of items to return. + * + * If not specified, a default value of 50 will be used by the service. + * Regardless of the pageSize value, the response can include a partial list + * and a caller should only rely on response's + * {@link protos.google.cloud.gkemulticloud.v1.ListAzureClientsResponse.next_page_token|nextPageToken} + * to determine if there are more instances left to be queried. + * @param {string} request.pageToken + * The `nextPageToken` value returned from a previous + * {@link protos.google.cloud.gkemulticloud.v1.AzureClusters.ListAzureClients|azureClients.list} + * request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.gkemulticloud.v1.AzureClient|AzureClient}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@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/azure_clusters.list_azure_clients.js + * region_tag:gkemulticloud_v1_generated_AzureClusters_ListAzureClients_async + * @deprecated ListAzureClients is deprecated and may be removed in a future version. + */ listAzureClientsAsync( - request?: protos.google.cloud.gkemulticloud.v1.IListAzureClientsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.gkemulticloud.v1.IListAzureClientsRequest, + 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['listAzureClients']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); - this.warn('DEP$AzureClusters-$ListAzureClients','ListAzureClients is deprecated and may be removed in a future version.', 'DeprecationWarning'); + this.initialize().catch((err) => { + throw err; + }); + this.warn( + 'DEP$AzureClusters-$ListAzureClients', + 'ListAzureClients is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); this._log.info('listAzureClients iterate %j', request); return this.descriptors.page.listAzureClients.asyncIterate( this.innerApiCalls['listAzureClients'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists all {@link protos.google.cloud.gkemulticloud.v1.AzureCluster|AzureCluster} - * resources on a given Google Cloud project and region. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent location which owns this collection of - * {@link protos.google.cloud.gkemulticloud.v1.AzureCluster|AzureCluster} resources. - * - * Location names are formatted as `projects//locations/`. - * - * See [Resource Names](https://cloud.google.com/apis/design/resource_names) - * for more details on Google Cloud Platform resource names. - * @param {number} request.pageSize - * The maximum number of items to return. - * - * If not specified, a default value of 50 will be used by the service. - * Regardless of the pageSize value, the response can include a partial list - * and a caller should only rely on response's - * {@link protos.google.cloud.gkemulticloud.v1.ListAzureClustersResponse.next_page_token|nextPageToken} - * to determine if there are more instances left to be queried. - * @param {string} request.pageToken - * The `nextPageToken` value returned from a previous - * {@link protos.google.cloud.gkemulticloud.v1.AzureClusters.ListAzureClusters|azureClusters.list} - * request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link protos.google.cloud.gkemulticloud.v1.AzureCluster|AzureCluster}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listAzureClustersAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @deprecated ListAzureClusters is deprecated and may be removed in a future version. - */ + /** + * Lists all {@link protos.google.cloud.gkemulticloud.v1.AzureCluster|AzureCluster} + * resources on a given Google Cloud project and region. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent location which owns this collection of + * {@link protos.google.cloud.gkemulticloud.v1.AzureCluster|AzureCluster} resources. + * + * Location names are formatted as `projects//locations/`. + * + * See [Resource Names](https://cloud.google.com/apis/design/resource_names) + * for more details on Google Cloud Platform resource names. + * @param {number} request.pageSize + * The maximum number of items to return. + * + * If not specified, a default value of 50 will be used by the service. + * Regardless of the pageSize value, the response can include a partial list + * and a caller should only rely on response's + * {@link protos.google.cloud.gkemulticloud.v1.ListAzureClustersResponse.next_page_token|nextPageToken} + * to determine if there are more instances left to be queried. + * @param {string} request.pageToken + * The `nextPageToken` value returned from a previous + * {@link protos.google.cloud.gkemulticloud.v1.AzureClusters.ListAzureClusters|azureClusters.list} + * request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.gkemulticloud.v1.AzureCluster|AzureCluster}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listAzureClustersAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @deprecated ListAzureClusters is deprecated and may be removed in a future version. + */ listAzureClusters( - request?: protos.google.cloud.gkemulticloud.v1.IListAzureClustersRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gkemulticloud.v1.IAzureCluster[], - protos.google.cloud.gkemulticloud.v1.IListAzureClustersRequest|null, - protos.google.cloud.gkemulticloud.v1.IListAzureClustersResponse - ]>; + request?: protos.google.cloud.gkemulticloud.v1.IListAzureClustersRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gkemulticloud.v1.IAzureCluster[], + protos.google.cloud.gkemulticloud.v1.IListAzureClustersRequest | null, + protos.google.cloud.gkemulticloud.v1.IListAzureClustersResponse, + ] + >; listAzureClusters( - request: protos.google.cloud.gkemulticloud.v1.IListAzureClustersRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.gkemulticloud.v1.IListAzureClustersRequest, - protos.google.cloud.gkemulticloud.v1.IListAzureClustersResponse|null|undefined, - protos.google.cloud.gkemulticloud.v1.IAzureCluster>): void; + request: protos.google.cloud.gkemulticloud.v1.IListAzureClustersRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.gkemulticloud.v1.IListAzureClustersRequest, + | protos.google.cloud.gkemulticloud.v1.IListAzureClustersResponse + | null + | undefined, + protos.google.cloud.gkemulticloud.v1.IAzureCluster + >, + ): void; listAzureClusters( - request: protos.google.cloud.gkemulticloud.v1.IListAzureClustersRequest, - callback: PaginationCallback< - protos.google.cloud.gkemulticloud.v1.IListAzureClustersRequest, - protos.google.cloud.gkemulticloud.v1.IListAzureClustersResponse|null|undefined, - protos.google.cloud.gkemulticloud.v1.IAzureCluster>): void; + request: protos.google.cloud.gkemulticloud.v1.IListAzureClustersRequest, + callback: PaginationCallback< + protos.google.cloud.gkemulticloud.v1.IListAzureClustersRequest, + | protos.google.cloud.gkemulticloud.v1.IListAzureClustersResponse + | null + | undefined, + protos.google.cloud.gkemulticloud.v1.IAzureCluster + >, + ): void; listAzureClusters( - request?: protos.google.cloud.gkemulticloud.v1.IListAzureClustersRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.gkemulticloud.v1.IListAzureClustersRequest, - protos.google.cloud.gkemulticloud.v1.IListAzureClustersResponse|null|undefined, - protos.google.cloud.gkemulticloud.v1.IAzureCluster>, - callback?: PaginationCallback< + request?: protos.google.cloud.gkemulticloud.v1.IListAzureClustersRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.gkemulticloud.v1.IListAzureClustersRequest, - protos.google.cloud.gkemulticloud.v1.IListAzureClustersResponse|null|undefined, - protos.google.cloud.gkemulticloud.v1.IAzureCluster>): - Promise<[ - protos.google.cloud.gkemulticloud.v1.IAzureCluster[], - protos.google.cloud.gkemulticloud.v1.IListAzureClustersRequest|null, - protos.google.cloud.gkemulticloud.v1.IListAzureClustersResponse - ]>|void { + | protos.google.cloud.gkemulticloud.v1.IListAzureClustersResponse + | null + | undefined, + protos.google.cloud.gkemulticloud.v1.IAzureCluster + >, + callback?: PaginationCallback< + protos.google.cloud.gkemulticloud.v1.IListAzureClustersRequest, + | protos.google.cloud.gkemulticloud.v1.IListAzureClustersResponse + | null + | undefined, + protos.google.cloud.gkemulticloud.v1.IAzureCluster + >, + ): Promise< + [ + protos.google.cloud.gkemulticloud.v1.IAzureCluster[], + protos.google.cloud.gkemulticloud.v1.IListAzureClustersRequest | null, + protos.google.cloud.gkemulticloud.v1.IListAzureClustersResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.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.warn('DEP$AzureClusters-$ListAzureClusters','ListAzureClusters is deprecated and may be removed in a future version.', 'DeprecationWarning'); - const wrappedCallback: PaginationCallback< - protos.google.cloud.gkemulticloud.v1.IListAzureClustersRequest, - protos.google.cloud.gkemulticloud.v1.IListAzureClustersResponse|null|undefined, - protos.google.cloud.gkemulticloud.v1.IAzureCluster>|undefined = callback + this.warn( + 'DEP$AzureClusters-$ListAzureClusters', + 'ListAzureClusters is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.gkemulticloud.v1.IListAzureClustersRequest, + | protos.google.cloud.gkemulticloud.v1.IListAzureClustersResponse + | null + | undefined, + protos.google.cloud.gkemulticloud.v1.IAzureCluster + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listAzureClusters values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -2755,240 +3924,281 @@ export class AzureClustersClient { this._log.info('listAzureClusters request %j', request); return this.innerApiCalls .listAzureClusters(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.gkemulticloud.v1.IAzureCluster[], - protos.google.cloud.gkemulticloud.v1.IListAzureClustersRequest|null, - protos.google.cloud.gkemulticloud.v1.IListAzureClustersResponse - ]) => { - this._log.info('listAzureClusters values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.gkemulticloud.v1.IAzureCluster[], + protos.google.cloud.gkemulticloud.v1.IListAzureClustersRequest | null, + protos.google.cloud.gkemulticloud.v1.IListAzureClustersResponse, + ]) => { + this._log.info('listAzureClusters values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listAzureClusters`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent location which owns this collection of - * {@link protos.google.cloud.gkemulticloud.v1.AzureCluster|AzureCluster} resources. - * - * Location names are formatted as `projects//locations/`. - * - * See [Resource Names](https://cloud.google.com/apis/design/resource_names) - * for more details on Google Cloud Platform resource names. - * @param {number} request.pageSize - * The maximum number of items to return. - * - * If not specified, a default value of 50 will be used by the service. - * Regardless of the pageSize value, the response can include a partial list - * and a caller should only rely on response's - * {@link protos.google.cloud.gkemulticloud.v1.ListAzureClustersResponse.next_page_token|nextPageToken} - * to determine if there are more instances left to be queried. - * @param {string} request.pageToken - * The `nextPageToken` value returned from a previous - * {@link protos.google.cloud.gkemulticloud.v1.AzureClusters.ListAzureClusters|azureClusters.list} - * request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.gkemulticloud.v1.AzureCluster|AzureCluster} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listAzureClustersAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @deprecated ListAzureClusters is deprecated and may be removed in a future version. - */ + /** + * Equivalent to `listAzureClusters`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent location which owns this collection of + * {@link protos.google.cloud.gkemulticloud.v1.AzureCluster|AzureCluster} resources. + * + * Location names are formatted as `projects//locations/`. + * + * See [Resource Names](https://cloud.google.com/apis/design/resource_names) + * for more details on Google Cloud Platform resource names. + * @param {number} request.pageSize + * The maximum number of items to return. + * + * If not specified, a default value of 50 will be used by the service. + * Regardless of the pageSize value, the response can include a partial list + * and a caller should only rely on response's + * {@link protos.google.cloud.gkemulticloud.v1.ListAzureClustersResponse.next_page_token|nextPageToken} + * to determine if there are more instances left to be queried. + * @param {string} request.pageToken + * The `nextPageToken` value returned from a previous + * {@link protos.google.cloud.gkemulticloud.v1.AzureClusters.ListAzureClusters|azureClusters.list} + * request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.gkemulticloud.v1.AzureCluster|AzureCluster} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listAzureClustersAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @deprecated ListAzureClusters is deprecated and may be removed in a future version. + */ listAzureClustersStream( - request?: protos.google.cloud.gkemulticloud.v1.IListAzureClustersRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.gkemulticloud.v1.IListAzureClustersRequest, + 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['listAzureClusters']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); - this.warn('DEP$AzureClusters-$ListAzureClusters','ListAzureClusters is deprecated and may be removed in a future version.', 'DeprecationWarning'); + this.initialize().catch((err) => { + throw err; + }); + this.warn( + 'DEP$AzureClusters-$ListAzureClusters', + 'ListAzureClusters is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); this._log.info('listAzureClusters stream %j', request); return this.descriptors.page.listAzureClusters.createStream( this.innerApiCalls.listAzureClusters as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listAzureClusters`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used 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 location which owns this collection of - * {@link protos.google.cloud.gkemulticloud.v1.AzureCluster|AzureCluster} resources. - * - * Location names are formatted as `projects//locations/`. - * - * See [Resource Names](https://cloud.google.com/apis/design/resource_names) - * for more details on Google Cloud Platform resource names. - * @param {number} request.pageSize - * The maximum number of items to return. - * - * If not specified, a default value of 50 will be used by the service. - * Regardless of the pageSize value, the response can include a partial list - * and a caller should only rely on response's - * {@link protos.google.cloud.gkemulticloud.v1.ListAzureClustersResponse.next_page_token|nextPageToken} - * to determine if there are more instances left to be queried. - * @param {string} request.pageToken - * The `nextPageToken` value returned from a previous - * {@link protos.google.cloud.gkemulticloud.v1.AzureClusters.ListAzureClusters|azureClusters.list} - * request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.gkemulticloud.v1.AzureCluster|AzureCluster}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@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/azure_clusters.list_azure_clusters.js - * region_tag:gkemulticloud_v1_generated_AzureClusters_ListAzureClusters_async - * @deprecated ListAzureClusters is deprecated and may be removed in a future version. - */ + /** + * Equivalent to `listAzureClusters`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used 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 location which owns this collection of + * {@link protos.google.cloud.gkemulticloud.v1.AzureCluster|AzureCluster} resources. + * + * Location names are formatted as `projects//locations/`. + * + * See [Resource Names](https://cloud.google.com/apis/design/resource_names) + * for more details on Google Cloud Platform resource names. + * @param {number} request.pageSize + * The maximum number of items to return. + * + * If not specified, a default value of 50 will be used by the service. + * Regardless of the pageSize value, the response can include a partial list + * and a caller should only rely on response's + * {@link protos.google.cloud.gkemulticloud.v1.ListAzureClustersResponse.next_page_token|nextPageToken} + * to determine if there are more instances left to be queried. + * @param {string} request.pageToken + * The `nextPageToken` value returned from a previous + * {@link protos.google.cloud.gkemulticloud.v1.AzureClusters.ListAzureClusters|azureClusters.list} + * request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.gkemulticloud.v1.AzureCluster|AzureCluster}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@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/azure_clusters.list_azure_clusters.js + * region_tag:gkemulticloud_v1_generated_AzureClusters_ListAzureClusters_async + * @deprecated ListAzureClusters is deprecated and may be removed in a future version. + */ listAzureClustersAsync( - request?: protos.google.cloud.gkemulticloud.v1.IListAzureClustersRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.gkemulticloud.v1.IListAzureClustersRequest, + 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['listAzureClusters']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); - this.warn('DEP$AzureClusters-$ListAzureClusters','ListAzureClusters is deprecated and may be removed in a future version.', 'DeprecationWarning'); + this.initialize().catch((err) => { + throw err; + }); + this.warn( + 'DEP$AzureClusters-$ListAzureClusters', + 'ListAzureClusters is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); this._log.info('listAzureClusters iterate %j', request); return this.descriptors.page.listAzureClusters.asyncIterate( this.innerApiCalls['listAzureClusters'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists all {@link protos.google.cloud.gkemulticloud.v1.AzureNodePool|AzureNodePool} - * resources on a given - * {@link protos.google.cloud.gkemulticloud.v1.AzureCluster|AzureCluster}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent `AzureCluster` which owns this collection of - * {@link protos.google.cloud.gkemulticloud.v1.AzureNodePool|AzureNodePool} resources. - * - * `AzureCluster` names are formatted as - * `projects//locations//azureClusters/`. - * - * See [Resource Names](https://cloud.google.com/apis/design/resource_names) - * for more details on Google Cloud resource names. - * @param {number} request.pageSize - * The maximum number of items to return. - * - * If not specified, a default value of 50 will be used by the service. - * Regardless of the pageSize value, the response can include a partial list - * and a caller should only rely on response's - * {@link protos.google.cloud.gkemulticloud.v1.ListAzureNodePoolsResponse.next_page_token|nextPageToken} - * to determine if there are more instances left to be queried. - * @param {string} request.pageToken - * The `nextPageToken` value returned from a previous - * {@link protos.google.cloud.gkemulticloud.v1.AzureClusters.ListAzureNodePools|azureNodePools.list} - * request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link protos.google.cloud.gkemulticloud.v1.AzureNodePool|AzureNodePool}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listAzureNodePoolsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @deprecated ListAzureNodePools is deprecated and may be removed in a future version. - */ + /** + * Lists all {@link protos.google.cloud.gkemulticloud.v1.AzureNodePool|AzureNodePool} + * resources on a given + * {@link protos.google.cloud.gkemulticloud.v1.AzureCluster|AzureCluster}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent `AzureCluster` which owns this collection of + * {@link protos.google.cloud.gkemulticloud.v1.AzureNodePool|AzureNodePool} resources. + * + * `AzureCluster` names are formatted as + * `projects//locations//azureClusters/`. + * + * See [Resource Names](https://cloud.google.com/apis/design/resource_names) + * for more details on Google Cloud resource names. + * @param {number} request.pageSize + * The maximum number of items to return. + * + * If not specified, a default value of 50 will be used by the service. + * Regardless of the pageSize value, the response can include a partial list + * and a caller should only rely on response's + * {@link protos.google.cloud.gkemulticloud.v1.ListAzureNodePoolsResponse.next_page_token|nextPageToken} + * to determine if there are more instances left to be queried. + * @param {string} request.pageToken + * The `nextPageToken` value returned from a previous + * {@link protos.google.cloud.gkemulticloud.v1.AzureClusters.ListAzureNodePools|azureNodePools.list} + * request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.gkemulticloud.v1.AzureNodePool|AzureNodePool}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listAzureNodePoolsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @deprecated ListAzureNodePools is deprecated and may be removed in a future version. + */ listAzureNodePools( - request?: protos.google.cloud.gkemulticloud.v1.IListAzureNodePoolsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gkemulticloud.v1.IAzureNodePool[], - protos.google.cloud.gkemulticloud.v1.IListAzureNodePoolsRequest|null, - protos.google.cloud.gkemulticloud.v1.IListAzureNodePoolsResponse - ]>; + request?: protos.google.cloud.gkemulticloud.v1.IListAzureNodePoolsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gkemulticloud.v1.IAzureNodePool[], + protos.google.cloud.gkemulticloud.v1.IListAzureNodePoolsRequest | null, + protos.google.cloud.gkemulticloud.v1.IListAzureNodePoolsResponse, + ] + >; listAzureNodePools( - request: protos.google.cloud.gkemulticloud.v1.IListAzureNodePoolsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.gkemulticloud.v1.IListAzureNodePoolsRequest, - protos.google.cloud.gkemulticloud.v1.IListAzureNodePoolsResponse|null|undefined, - protos.google.cloud.gkemulticloud.v1.IAzureNodePool>): void; + request: protos.google.cloud.gkemulticloud.v1.IListAzureNodePoolsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.gkemulticloud.v1.IListAzureNodePoolsRequest, + | protos.google.cloud.gkemulticloud.v1.IListAzureNodePoolsResponse + | null + | undefined, + protos.google.cloud.gkemulticloud.v1.IAzureNodePool + >, + ): void; listAzureNodePools( - request: protos.google.cloud.gkemulticloud.v1.IListAzureNodePoolsRequest, - callback: PaginationCallback< - protos.google.cloud.gkemulticloud.v1.IListAzureNodePoolsRequest, - protos.google.cloud.gkemulticloud.v1.IListAzureNodePoolsResponse|null|undefined, - protos.google.cloud.gkemulticloud.v1.IAzureNodePool>): void; + request: protos.google.cloud.gkemulticloud.v1.IListAzureNodePoolsRequest, + callback: PaginationCallback< + protos.google.cloud.gkemulticloud.v1.IListAzureNodePoolsRequest, + | protos.google.cloud.gkemulticloud.v1.IListAzureNodePoolsResponse + | null + | undefined, + protos.google.cloud.gkemulticloud.v1.IAzureNodePool + >, + ): void; listAzureNodePools( - request?: protos.google.cloud.gkemulticloud.v1.IListAzureNodePoolsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.gkemulticloud.v1.IListAzureNodePoolsRequest, - protos.google.cloud.gkemulticloud.v1.IListAzureNodePoolsResponse|null|undefined, - protos.google.cloud.gkemulticloud.v1.IAzureNodePool>, - callback?: PaginationCallback< + request?: protos.google.cloud.gkemulticloud.v1.IListAzureNodePoolsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.gkemulticloud.v1.IListAzureNodePoolsRequest, - protos.google.cloud.gkemulticloud.v1.IListAzureNodePoolsResponse|null|undefined, - protos.google.cloud.gkemulticloud.v1.IAzureNodePool>): - Promise<[ - protos.google.cloud.gkemulticloud.v1.IAzureNodePool[], - protos.google.cloud.gkemulticloud.v1.IListAzureNodePoolsRequest|null, - protos.google.cloud.gkemulticloud.v1.IListAzureNodePoolsResponse - ]>|void { + | protos.google.cloud.gkemulticloud.v1.IListAzureNodePoolsResponse + | null + | undefined, + protos.google.cloud.gkemulticloud.v1.IAzureNodePool + >, + callback?: PaginationCallback< + protos.google.cloud.gkemulticloud.v1.IListAzureNodePoolsRequest, + | protos.google.cloud.gkemulticloud.v1.IListAzureNodePoolsResponse + | null + | undefined, + protos.google.cloud.gkemulticloud.v1.IAzureNodePool + >, + ): Promise< + [ + protos.google.cloud.gkemulticloud.v1.IAzureNodePool[], + protos.google.cloud.gkemulticloud.v1.IListAzureNodePoolsRequest | null, + protos.google.cloud.gkemulticloud.v1.IListAzureNodePoolsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.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.warn('DEP$AzureClusters-$ListAzureNodePools','ListAzureNodePools is deprecated and may be removed in a future version.', 'DeprecationWarning'); - const wrappedCallback: PaginationCallback< - protos.google.cloud.gkemulticloud.v1.IListAzureNodePoolsRequest, - protos.google.cloud.gkemulticloud.v1.IListAzureNodePoolsResponse|null|undefined, - protos.google.cloud.gkemulticloud.v1.IAzureNodePool>|undefined = callback + this.warn( + 'DEP$AzureClusters-$ListAzureNodePools', + 'ListAzureNodePools is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.gkemulticloud.v1.IListAzureNodePoolsRequest, + | protos.google.cloud.gkemulticloud.v1.IListAzureNodePoolsResponse + | null + | undefined, + protos.google.cloud.gkemulticloud.v1.IAzureNodePool + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listAzureNodePools values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -2997,143 +4207,155 @@ export class AzureClustersClient { this._log.info('listAzureNodePools request %j', request); return this.innerApiCalls .listAzureNodePools(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.gkemulticloud.v1.IAzureNodePool[], - protos.google.cloud.gkemulticloud.v1.IListAzureNodePoolsRequest|null, - protos.google.cloud.gkemulticloud.v1.IListAzureNodePoolsResponse - ]) => { - this._log.info('listAzureNodePools values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.gkemulticloud.v1.IAzureNodePool[], + protos.google.cloud.gkemulticloud.v1.IListAzureNodePoolsRequest | null, + protos.google.cloud.gkemulticloud.v1.IListAzureNodePoolsResponse, + ]) => { + this._log.info('listAzureNodePools values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listAzureNodePools`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent `AzureCluster` which owns this collection of - * {@link protos.google.cloud.gkemulticloud.v1.AzureNodePool|AzureNodePool} resources. - * - * `AzureCluster` names are formatted as - * `projects//locations//azureClusters/`. - * - * See [Resource Names](https://cloud.google.com/apis/design/resource_names) - * for more details on Google Cloud resource names. - * @param {number} request.pageSize - * The maximum number of items to return. - * - * If not specified, a default value of 50 will be used by the service. - * Regardless of the pageSize value, the response can include a partial list - * and a caller should only rely on response's - * {@link protos.google.cloud.gkemulticloud.v1.ListAzureNodePoolsResponse.next_page_token|nextPageToken} - * to determine if there are more instances left to be queried. - * @param {string} request.pageToken - * The `nextPageToken` value returned from a previous - * {@link protos.google.cloud.gkemulticloud.v1.AzureClusters.ListAzureNodePools|azureNodePools.list} - * request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.gkemulticloud.v1.AzureNodePool|AzureNodePool} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listAzureNodePoolsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @deprecated ListAzureNodePools is deprecated and may be removed in a future version. - */ + /** + * Equivalent to `listAzureNodePools`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent `AzureCluster` which owns this collection of + * {@link protos.google.cloud.gkemulticloud.v1.AzureNodePool|AzureNodePool} resources. + * + * `AzureCluster` names are formatted as + * `projects//locations//azureClusters/`. + * + * See [Resource Names](https://cloud.google.com/apis/design/resource_names) + * for more details on Google Cloud resource names. + * @param {number} request.pageSize + * The maximum number of items to return. + * + * If not specified, a default value of 50 will be used by the service. + * Regardless of the pageSize value, the response can include a partial list + * and a caller should only rely on response's + * {@link protos.google.cloud.gkemulticloud.v1.ListAzureNodePoolsResponse.next_page_token|nextPageToken} + * to determine if there are more instances left to be queried. + * @param {string} request.pageToken + * The `nextPageToken` value returned from a previous + * {@link protos.google.cloud.gkemulticloud.v1.AzureClusters.ListAzureNodePools|azureNodePools.list} + * request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.gkemulticloud.v1.AzureNodePool|AzureNodePool} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listAzureNodePoolsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @deprecated ListAzureNodePools is deprecated and may be removed in a future version. + */ listAzureNodePoolsStream( - request?: protos.google.cloud.gkemulticloud.v1.IListAzureNodePoolsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.gkemulticloud.v1.IListAzureNodePoolsRequest, + 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['listAzureNodePools']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); - this.warn('DEP$AzureClusters-$ListAzureNodePools','ListAzureNodePools is deprecated and may be removed in a future version.', 'DeprecationWarning'); + this.initialize().catch((err) => { + throw err; + }); + this.warn( + 'DEP$AzureClusters-$ListAzureNodePools', + 'ListAzureNodePools is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); this._log.info('listAzureNodePools stream %j', request); return this.descriptors.page.listAzureNodePools.createStream( this.innerApiCalls.listAzureNodePools as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listAzureNodePools`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used 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 `AzureCluster` which owns this collection of - * {@link protos.google.cloud.gkemulticloud.v1.AzureNodePool|AzureNodePool} resources. - * - * `AzureCluster` names are formatted as - * `projects//locations//azureClusters/`. - * - * See [Resource Names](https://cloud.google.com/apis/design/resource_names) - * for more details on Google Cloud resource names. - * @param {number} request.pageSize - * The maximum number of items to return. - * - * If not specified, a default value of 50 will be used by the service. - * Regardless of the pageSize value, the response can include a partial list - * and a caller should only rely on response's - * {@link protos.google.cloud.gkemulticloud.v1.ListAzureNodePoolsResponse.next_page_token|nextPageToken} - * to determine if there are more instances left to be queried. - * @param {string} request.pageToken - * The `nextPageToken` value returned from a previous - * {@link protos.google.cloud.gkemulticloud.v1.AzureClusters.ListAzureNodePools|azureNodePools.list} - * request, if any. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.gkemulticloud.v1.AzureNodePool|AzureNodePool}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@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/azure_clusters.list_azure_node_pools.js - * region_tag:gkemulticloud_v1_generated_AzureClusters_ListAzureNodePools_async - * @deprecated ListAzureNodePools is deprecated and may be removed in a future version. - */ + /** + * Equivalent to `listAzureNodePools`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used 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 `AzureCluster` which owns this collection of + * {@link protos.google.cloud.gkemulticloud.v1.AzureNodePool|AzureNodePool} resources. + * + * `AzureCluster` names are formatted as + * `projects//locations//azureClusters/`. + * + * See [Resource Names](https://cloud.google.com/apis/design/resource_names) + * for more details on Google Cloud resource names. + * @param {number} request.pageSize + * The maximum number of items to return. + * + * If not specified, a default value of 50 will be used by the service. + * Regardless of the pageSize value, the response can include a partial list + * and a caller should only rely on response's + * {@link protos.google.cloud.gkemulticloud.v1.ListAzureNodePoolsResponse.next_page_token|nextPageToken} + * to determine if there are more instances left to be queried. + * @param {string} request.pageToken + * The `nextPageToken` value returned from a previous + * {@link protos.google.cloud.gkemulticloud.v1.AzureClusters.ListAzureNodePools|azureNodePools.list} + * request, if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.gkemulticloud.v1.AzureNodePool|AzureNodePool}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@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/azure_clusters.list_azure_node_pools.js + * region_tag:gkemulticloud_v1_generated_AzureClusters_ListAzureNodePools_async + * @deprecated ListAzureNodePools is deprecated and may be removed in a future version. + */ listAzureNodePoolsAsync( - request?: protos.google.cloud.gkemulticloud.v1.IListAzureNodePoolsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.gkemulticloud.v1.IListAzureNodePoolsRequest, + 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['listAzureNodePools']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); - this.warn('DEP$AzureClusters-$ListAzureNodePools','ListAzureNodePools is deprecated and may be removed in a future version.', 'DeprecationWarning'); + this.initialize().catch((err) => { + throw err; + }); + this.warn( + 'DEP$AzureClusters-$ListAzureNodePools', + 'ListAzureNodePools is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); this._log.info('listAzureNodePools iterate %j', request); return this.descriptors.page.listAzureNodePools.asyncIterate( this.innerApiCalls['listAzureNodePools'] 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. @@ -3176,22 +4398,22 @@ export class AzureClustersClient { 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); } /** @@ -3226,15 +4448,15 @@ export class AzureClustersClient { */ 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); } /** @@ -3268,7 +4490,7 @@ export class AzureClustersClient { * await client.cancelOperation({name: ''}); * ``` */ - cancelOperation( + cancelOperation( request: protos.google.longrunning.CancelOperationRequest, optionsOrCallback?: | gax.CallOptions @@ -3281,25 +4503,24 @@ export class AzureClustersClient { 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 @@ -3338,22 +4559,22 @@ export class AzureClustersClient { 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); } @@ -3369,7 +4590,11 @@ export class AzureClustersClient { * @param {string} attached_cluster * @returns {string} Resource name string. */ - attachedClusterPath(project:string,location:string,attachedCluster:string) { + attachedClusterPath( + project: string, + location: string, + attachedCluster: string, + ) { return this.pathTemplates.attachedClusterPathTemplate.render({ project: project, location: location, @@ -3385,7 +4610,9 @@ export class AzureClustersClient { * @returns {string} A string representing the project. */ matchProjectFromAttachedClusterName(attachedClusterName: string) { - return this.pathTemplates.attachedClusterPathTemplate.match(attachedClusterName).project; + return this.pathTemplates.attachedClusterPathTemplate.match( + attachedClusterName, + ).project; } /** @@ -3396,7 +4623,9 @@ export class AzureClustersClient { * @returns {string} A string representing the location. */ matchLocationFromAttachedClusterName(attachedClusterName: string) { - return this.pathTemplates.attachedClusterPathTemplate.match(attachedClusterName).location; + return this.pathTemplates.attachedClusterPathTemplate.match( + attachedClusterName, + ).location; } /** @@ -3407,7 +4636,9 @@ export class AzureClustersClient { * @returns {string} A string representing the attached_cluster. */ matchAttachedClusterFromAttachedClusterName(attachedClusterName: string) { - return this.pathTemplates.attachedClusterPathTemplate.match(attachedClusterName).attached_cluster; + return this.pathTemplates.attachedClusterPathTemplate.match( + attachedClusterName, + ).attached_cluster; } /** @@ -3417,7 +4648,7 @@ export class AzureClustersClient { * @param {string} location * @returns {string} Resource name string. */ - attachedServerConfigPath(project:string,location:string) { + attachedServerConfigPath(project: string, location: string) { return this.pathTemplates.attachedServerConfigPathTemplate.render({ project: project, location: location, @@ -3432,7 +4663,9 @@ export class AzureClustersClient { * @returns {string} A string representing the project. */ matchProjectFromAttachedServerConfigName(attachedServerConfigName: string) { - return this.pathTemplates.attachedServerConfigPathTemplate.match(attachedServerConfigName).project; + return this.pathTemplates.attachedServerConfigPathTemplate.match( + attachedServerConfigName, + ).project; } /** @@ -3443,7 +4676,9 @@ export class AzureClustersClient { * @returns {string} A string representing the location. */ matchLocationFromAttachedServerConfigName(attachedServerConfigName: string) { - return this.pathTemplates.attachedServerConfigPathTemplate.match(attachedServerConfigName).location; + return this.pathTemplates.attachedServerConfigPathTemplate.match( + attachedServerConfigName, + ).location; } /** @@ -3454,7 +4689,7 @@ export class AzureClustersClient { * @param {string} aws_cluster * @returns {string} Resource name string. */ - awsClusterPath(project:string,location:string,awsCluster:string) { + awsClusterPath(project: string, location: string, awsCluster: string) { return this.pathTemplates.awsClusterPathTemplate.render({ project: project, location: location, @@ -3470,7 +4705,8 @@ export class AzureClustersClient { * @returns {string} A string representing the project. */ matchProjectFromAwsClusterName(awsClusterName: string) { - return this.pathTemplates.awsClusterPathTemplate.match(awsClusterName).project; + return this.pathTemplates.awsClusterPathTemplate.match(awsClusterName) + .project; } /** @@ -3481,7 +4717,8 @@ export class AzureClustersClient { * @returns {string} A string representing the location. */ matchLocationFromAwsClusterName(awsClusterName: string) { - return this.pathTemplates.awsClusterPathTemplate.match(awsClusterName).location; + return this.pathTemplates.awsClusterPathTemplate.match(awsClusterName) + .location; } /** @@ -3492,7 +4729,8 @@ export class AzureClustersClient { * @returns {string} A string representing the aws_cluster. */ matchAwsClusterFromAwsClusterName(awsClusterName: string) { - return this.pathTemplates.awsClusterPathTemplate.match(awsClusterName).aws_cluster; + return this.pathTemplates.awsClusterPathTemplate.match(awsClusterName) + .aws_cluster; } /** @@ -3504,7 +4742,12 @@ export class AzureClustersClient { * @param {string} aws_node_pool * @returns {string} Resource name string. */ - awsNodePoolPath(project:string,location:string,awsCluster:string,awsNodePool:string) { + awsNodePoolPath( + project: string, + location: string, + awsCluster: string, + awsNodePool: string, + ) { return this.pathTemplates.awsNodePoolPathTemplate.render({ project: project, location: location, @@ -3521,7 +4764,8 @@ export class AzureClustersClient { * @returns {string} A string representing the project. */ matchProjectFromAwsNodePoolName(awsNodePoolName: string) { - return this.pathTemplates.awsNodePoolPathTemplate.match(awsNodePoolName).project; + return this.pathTemplates.awsNodePoolPathTemplate.match(awsNodePoolName) + .project; } /** @@ -3532,7 +4776,8 @@ export class AzureClustersClient { * @returns {string} A string representing the location. */ matchLocationFromAwsNodePoolName(awsNodePoolName: string) { - return this.pathTemplates.awsNodePoolPathTemplate.match(awsNodePoolName).location; + return this.pathTemplates.awsNodePoolPathTemplate.match(awsNodePoolName) + .location; } /** @@ -3543,7 +4788,8 @@ export class AzureClustersClient { * @returns {string} A string representing the aws_cluster. */ matchAwsClusterFromAwsNodePoolName(awsNodePoolName: string) { - return this.pathTemplates.awsNodePoolPathTemplate.match(awsNodePoolName).aws_cluster; + return this.pathTemplates.awsNodePoolPathTemplate.match(awsNodePoolName) + .aws_cluster; } /** @@ -3554,7 +4800,8 @@ export class AzureClustersClient { * @returns {string} A string representing the aws_node_pool. */ matchAwsNodePoolFromAwsNodePoolName(awsNodePoolName: string) { - return this.pathTemplates.awsNodePoolPathTemplate.match(awsNodePoolName).aws_node_pool; + return this.pathTemplates.awsNodePoolPathTemplate.match(awsNodePoolName) + .aws_node_pool; } /** @@ -3564,7 +4811,7 @@ export class AzureClustersClient { * @param {string} location * @returns {string} Resource name string. */ - awsServerConfigPath(project:string,location:string) { + awsServerConfigPath(project: string, location: string) { return this.pathTemplates.awsServerConfigPathTemplate.render({ project: project, location: location, @@ -3579,7 +4826,9 @@ export class AzureClustersClient { * @returns {string} A string representing the project. */ matchProjectFromAwsServerConfigName(awsServerConfigName: string) { - return this.pathTemplates.awsServerConfigPathTemplate.match(awsServerConfigName).project; + return this.pathTemplates.awsServerConfigPathTemplate.match( + awsServerConfigName, + ).project; } /** @@ -3590,7 +4839,9 @@ export class AzureClustersClient { * @returns {string} A string representing the location. */ matchLocationFromAwsServerConfigName(awsServerConfigName: string) { - return this.pathTemplates.awsServerConfigPathTemplate.match(awsServerConfigName).location; + return this.pathTemplates.awsServerConfigPathTemplate.match( + awsServerConfigName, + ).location; } /** @@ -3601,7 +4852,7 @@ export class AzureClustersClient { * @param {string} azure_client * @returns {string} Resource name string. */ - azureClientPath(project:string,location:string,azureClient:string) { + azureClientPath(project: string, location: string, azureClient: string) { return this.pathTemplates.azureClientPathTemplate.render({ project: project, location: location, @@ -3617,7 +4868,8 @@ export class AzureClustersClient { * @returns {string} A string representing the project. */ matchProjectFromAzureClientName(azureClientName: string) { - return this.pathTemplates.azureClientPathTemplate.match(azureClientName).project; + return this.pathTemplates.azureClientPathTemplate.match(azureClientName) + .project; } /** @@ -3628,7 +4880,8 @@ export class AzureClustersClient { * @returns {string} A string representing the location. */ matchLocationFromAzureClientName(azureClientName: string) { - return this.pathTemplates.azureClientPathTemplate.match(azureClientName).location; + return this.pathTemplates.azureClientPathTemplate.match(azureClientName) + .location; } /** @@ -3639,7 +4892,8 @@ export class AzureClustersClient { * @returns {string} A string representing the azure_client. */ matchAzureClientFromAzureClientName(azureClientName: string) { - return this.pathTemplates.azureClientPathTemplate.match(azureClientName).azure_client; + return this.pathTemplates.azureClientPathTemplate.match(azureClientName) + .azure_client; } /** @@ -3650,7 +4904,7 @@ export class AzureClustersClient { * @param {string} azure_cluster * @returns {string} Resource name string. */ - azureClusterPath(project:string,location:string,azureCluster:string) { + azureClusterPath(project: string, location: string, azureCluster: string) { return this.pathTemplates.azureClusterPathTemplate.render({ project: project, location: location, @@ -3666,7 +4920,8 @@ export class AzureClustersClient { * @returns {string} A string representing the project. */ matchProjectFromAzureClusterName(azureClusterName: string) { - return this.pathTemplates.azureClusterPathTemplate.match(azureClusterName).project; + return this.pathTemplates.azureClusterPathTemplate.match(azureClusterName) + .project; } /** @@ -3677,7 +4932,8 @@ export class AzureClustersClient { * @returns {string} A string representing the location. */ matchLocationFromAzureClusterName(azureClusterName: string) { - return this.pathTemplates.azureClusterPathTemplate.match(azureClusterName).location; + return this.pathTemplates.azureClusterPathTemplate.match(azureClusterName) + .location; } /** @@ -3688,7 +4944,8 @@ export class AzureClustersClient { * @returns {string} A string representing the azure_cluster. */ matchAzureClusterFromAzureClusterName(azureClusterName: string) { - return this.pathTemplates.azureClusterPathTemplate.match(azureClusterName).azure_cluster; + return this.pathTemplates.azureClusterPathTemplate.match(azureClusterName) + .azure_cluster; } /** @@ -3700,7 +4957,12 @@ export class AzureClustersClient { * @param {string} azure_node_pool * @returns {string} Resource name string. */ - azureNodePoolPath(project:string,location:string,azureCluster:string,azureNodePool:string) { + azureNodePoolPath( + project: string, + location: string, + azureCluster: string, + azureNodePool: string, + ) { return this.pathTemplates.azureNodePoolPathTemplate.render({ project: project, location: location, @@ -3717,7 +4979,8 @@ export class AzureClustersClient { * @returns {string} A string representing the project. */ matchProjectFromAzureNodePoolName(azureNodePoolName: string) { - return this.pathTemplates.azureNodePoolPathTemplate.match(azureNodePoolName).project; + return this.pathTemplates.azureNodePoolPathTemplate.match(azureNodePoolName) + .project; } /** @@ -3728,7 +4991,8 @@ export class AzureClustersClient { * @returns {string} A string representing the location. */ matchLocationFromAzureNodePoolName(azureNodePoolName: string) { - return this.pathTemplates.azureNodePoolPathTemplate.match(azureNodePoolName).location; + return this.pathTemplates.azureNodePoolPathTemplate.match(azureNodePoolName) + .location; } /** @@ -3739,7 +5003,8 @@ export class AzureClustersClient { * @returns {string} A string representing the azure_cluster. */ matchAzureClusterFromAzureNodePoolName(azureNodePoolName: string) { - return this.pathTemplates.azureNodePoolPathTemplate.match(azureNodePoolName).azure_cluster; + return this.pathTemplates.azureNodePoolPathTemplate.match(azureNodePoolName) + .azure_cluster; } /** @@ -3750,7 +5015,8 @@ export class AzureClustersClient { * @returns {string} A string representing the azure_node_pool. */ matchAzureNodePoolFromAzureNodePoolName(azureNodePoolName: string) { - return this.pathTemplates.azureNodePoolPathTemplate.match(azureNodePoolName).azure_node_pool; + return this.pathTemplates.azureNodePoolPathTemplate.match(azureNodePoolName) + .azure_node_pool; } /** @@ -3760,7 +5026,7 @@ export class AzureClustersClient { * @param {string} location * @returns {string} Resource name string. */ - azureServerConfigPath(project:string,location:string) { + azureServerConfigPath(project: string, location: string) { return this.pathTemplates.azureServerConfigPathTemplate.render({ project: project, location: location, @@ -3775,7 +5041,9 @@ export class AzureClustersClient { * @returns {string} A string representing the project. */ matchProjectFromAzureServerConfigName(azureServerConfigName: string) { - return this.pathTemplates.azureServerConfigPathTemplate.match(azureServerConfigName).project; + return this.pathTemplates.azureServerConfigPathTemplate.match( + azureServerConfigName, + ).project; } /** @@ -3786,7 +5054,9 @@ export class AzureClustersClient { * @returns {string} A string representing the location. */ matchLocationFromAzureServerConfigName(azureServerConfigName: string) { - return this.pathTemplates.azureServerConfigPathTemplate.match(azureServerConfigName).location; + return this.pathTemplates.azureServerConfigPathTemplate.match( + azureServerConfigName, + ).location; } /** @@ -3796,7 +5066,7 @@ export class AzureClustersClient { * @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, @@ -3831,7 +5101,7 @@ export class AzureClustersClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -3856,7 +5126,7 @@ export class AzureClustersClient { */ close(): Promise { if (this.azureClustersStub && !this._terminated) { - return this.azureClustersStub.then(stub => { + return this.azureClustersStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); @@ -3865,4 +5135,4 @@ export class AzureClustersClient { } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-gkemulticloud/src/v1/index.ts b/packages/google-cloud-gkemulticloud/src/v1/index.ts index dcd34b636961..ca38cd559f46 100644 --- a/packages/google-cloud-gkemulticloud/src/v1/index.ts +++ b/packages/google-cloud-gkemulticloud/src/v1/index.ts @@ -16,6 +16,6 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {AttachedClustersClient} from './attached_clusters_client'; -export {AwsClustersClient} from './aws_clusters_client'; -export {AzureClustersClient} from './azure_clusters_client'; +export { AttachedClustersClient } from './attached_clusters_client'; +export { AwsClustersClient } from './aws_clusters_client'; +export { AzureClustersClient } from './azure_clusters_client'; diff --git a/packages/google-cloud-gkemulticloud/system-test/fixtures/sample/src/index.ts b/packages/google-cloud-gkemulticloud/system-test/fixtures/sample/src/index.ts index d446ad0b3b10..f1eb02b9fa09 100644 --- a/packages/google-cloud-gkemulticloud/system-test/fixtures/sample/src/index.ts +++ b/packages/google-cloud-gkemulticloud/system-test/fixtures/sample/src/index.ts @@ -16,7 +16,11 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -import {AttachedClustersClient, AwsClustersClient, AzureClustersClient} from '@google-cloud/gkemulticloud'; +import { + AttachedClustersClient, + AwsClustersClient, + AzureClustersClient, +} from '@google-cloud/gkemulticloud'; // check that the client class type name can be used function doStuffWithAttachedClustersClient(client: AttachedClustersClient) { diff --git a/packages/google-cloud-gkemulticloud/system-test/install.ts b/packages/google-cloud-gkemulticloud/system-test/install.ts index f66069aa3940..ccf167042d2e 100644 --- a/packages/google-cloud-gkemulticloud/system-test/install.ts +++ b/packages/google-cloud-gkemulticloud/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-gkemulticloud/test/gapic_attached_clusters_v1.ts b/packages/google-cloud-gkemulticloud/test/gapic_attached_clusters_v1.ts index 280a9916edce..c2f1de4ba46c 100644 --- a/packages/google-cloud-gkemulticloud/test/gapic_attached_clusters_v1.ts +++ b/packages/google-cloud-gkemulticloud/test/gapic_attached_clusters_v1.ts @@ -19,2288 +19,2999 @@ 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 attachedclustersModule 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('v1.AttachedClustersClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new attachedclustersModule.v1.AttachedClustersClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'gkemulticloud.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new attachedclustersModule.v1.AttachedClustersClient(); - 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 = attachedclustersModule.v1.AttachedClustersClient.servicePath; - assert.strictEqual(servicePath, 'gkemulticloud.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = attachedclustersModule.v1.AttachedClustersClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'gkemulticloud.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new attachedclustersModule.v1.AttachedClustersClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'gkemulticloud.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new attachedclustersModule.v1.AttachedClustersClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'gkemulticloud.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 attachedclustersModule.v1.AttachedClustersClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'gkemulticloud.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 attachedclustersModule.v1.AttachedClustersClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'gkemulticloud.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 attachedclustersModule.v1.AttachedClustersClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); - - it('has port', () => { - const port = attachedclustersModule.v1.AttachedClustersClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new attachedclustersModule.v1.AttachedClustersClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new attachedclustersModule.v1.AttachedClustersClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.attachedClustersStub, undefined); - await client.initialize(); - assert(client.attachedClustersStub); - }); - - it('has close method for the initialized client', done => { - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.attachedClustersStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new attachedclustersModule.v1.AttachedClustersClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'gkemulticloud.googleapis.com'); + }); - it('has close method for the non-initialized client', done => { - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.attachedClustersStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has universeDomain', () => { + const client = new attachedclustersModule.v1.AttachedClustersClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + attachedclustersModule.v1.AttachedClustersClient.servicePath; + assert.strictEqual(servicePath, 'gkemulticloud.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + attachedclustersModule.v1.AttachedClustersClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'gkemulticloud.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new attachedclustersModule.v1.AttachedClustersClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'gkemulticloud.example.com'); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new attachedclustersModule.v1.AttachedClustersClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'gkemulticloud.example.com'); }); - describe('getAttachedCluster', () => { - it('invokes getAttachedCluster without error', async () => { - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkemulticloud.v1.GetAttachedClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkemulticloud.v1.GetAttachedClusterRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.gkemulticloud.v1.AttachedCluster() - ); - client.innerApiCalls.getAttachedCluster = stubSimpleCall(expectedResponse); - const [response] = await client.getAttachedCluster(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getAttachedCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getAttachedCluster 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 attachedclustersModule.v1.AttachedClustersClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'gkemulticloud.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 attachedclustersModule.v1.AttachedClustersClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual( + servicePath, + 'gkemulticloud.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 attachedclustersModule.v1.AttachedClustersClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('invokes getAttachedCluster without error using callback', async () => { - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkemulticloud.v1.GetAttachedClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkemulticloud.v1.GetAttachedClusterRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.gkemulticloud.v1.AttachedCluster() - ); - client.innerApiCalls.getAttachedCluster = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getAttachedCluster( - request, - (err?: Error|null, result?: protos.google.cloud.gkemulticloud.v1.IAttachedCluster|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getAttachedCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getAttachedCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has port', () => { + const port = attachedclustersModule.v1.AttachedClustersClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('invokes getAttachedCluster with error', async () => { - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkemulticloud.v1.GetAttachedClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkemulticloud.v1.GetAttachedClusterRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getAttachedCluster = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getAttachedCluster(request), expectedError); - const actualRequest = (client.innerApiCalls.getAttachedCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getAttachedCluster 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 attachedclustersModule.v1.AttachedClustersClient(); + assert(client); + }); - it('invokes getAttachedCluster with closed client', async () => { - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkemulticloud.v1.GetAttachedClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkemulticloud.v1.GetAttachedClusterRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getAttachedCluster(request), expectedError); - }); + it('should create a client with gRPC fallback', () => { + const client = new attachedclustersModule.v1.AttachedClustersClient({ + fallback: true, + }); + assert(client); }); - describe('getAttachedServerConfig', () => { - it('invokes getAttachedServerConfig without error', async () => { - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkemulticloud.v1.GetAttachedServerConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkemulticloud.v1.GetAttachedServerConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.gkemulticloud.v1.AttachedServerConfig() - ); - client.innerApiCalls.getAttachedServerConfig = stubSimpleCall(expectedResponse); - const [response] = await client.getAttachedServerConfig(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getAttachedServerConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getAttachedServerConfig 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 attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.attachedClustersStub, undefined); + await client.initialize(); + assert(client.attachedClustersStub); + }); - it('invokes getAttachedServerConfig without error using callback', async () => { - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkemulticloud.v1.GetAttachedServerConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkemulticloud.v1.GetAttachedServerConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.gkemulticloud.v1.AttachedServerConfig() - ); - client.innerApiCalls.getAttachedServerConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getAttachedServerConfig( - request, - (err?: Error|null, result?: protos.google.cloud.gkemulticloud.v1.IAttachedServerConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getAttachedServerConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getAttachedServerConfig 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 attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.attachedClustersStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes getAttachedServerConfig with error', async () => { - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkemulticloud.v1.GetAttachedServerConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkemulticloud.v1.GetAttachedServerConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getAttachedServerConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getAttachedServerConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.getAttachedServerConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getAttachedServerConfig 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 attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.attachedClustersStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes getAttachedServerConfig with closed client', async () => { - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkemulticloud.v1.GetAttachedServerConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkemulticloud.v1.GetAttachedServerConfigRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getAttachedServerConfig(request), expectedError); - }); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new attachedclustersModule.v1.AttachedClustersClient({ + 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('generateAttachedClusterInstallManifest', () => { - it('invokes generateAttachedClusterInstallManifest without error', async () => { - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkemulticloud.v1.GenerateAttachedClusterInstallManifestRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkemulticloud.v1.GenerateAttachedClusterInstallManifestRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.gkemulticloud.v1.GenerateAttachedClusterInstallManifestResponse() - ); - client.innerApiCalls.generateAttachedClusterInstallManifest = stubSimpleCall(expectedResponse); - const [response] = await client.generateAttachedClusterInstallManifest(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.generateAttachedClusterInstallManifest as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.generateAttachedClusterInstallManifest 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 attachedclustersModule.v1.AttachedClustersClient({ + 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('getAttachedCluster', () => { + it('invokes getAttachedCluster without error', async () => { + const client = new attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.GetAttachedClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkemulticloud.v1.GetAttachedClusterRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.AttachedCluster(), + ); + client.innerApiCalls.getAttachedCluster = + stubSimpleCall(expectedResponse); + const [response] = await client.getAttachedCluster(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getAttachedCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getAttachedCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes generateAttachedClusterInstallManifest without error using callback', async () => { - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkemulticloud.v1.GenerateAttachedClusterInstallManifestRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkemulticloud.v1.GenerateAttachedClusterInstallManifestRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.gkemulticloud.v1.GenerateAttachedClusterInstallManifestResponse() - ); - client.innerApiCalls.generateAttachedClusterInstallManifest = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.generateAttachedClusterInstallManifest( - request, - (err?: Error|null, result?: protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterInstallManifestResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.generateAttachedClusterInstallManifest as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.generateAttachedClusterInstallManifest as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getAttachedCluster without error using callback', async () => { + const client = new attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.GetAttachedClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkemulticloud.v1.GetAttachedClusterRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.AttachedCluster(), + ); + client.innerApiCalls.getAttachedCluster = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getAttachedCluster( + request, + ( + err?: Error | null, + result?: protos.google.cloud.gkemulticloud.v1.IAttachedCluster | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getAttachedCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getAttachedCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes generateAttachedClusterInstallManifest with error', async () => { - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkemulticloud.v1.GenerateAttachedClusterInstallManifestRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkemulticloud.v1.GenerateAttachedClusterInstallManifestRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.generateAttachedClusterInstallManifest = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.generateAttachedClusterInstallManifest(request), expectedError); - const actualRequest = (client.innerApiCalls.generateAttachedClusterInstallManifest as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.generateAttachedClusterInstallManifest as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getAttachedCluster with error', async () => { + const client = new attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.GetAttachedClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkemulticloud.v1.GetAttachedClusterRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getAttachedCluster = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getAttachedCluster(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getAttachedCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getAttachedCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes generateAttachedClusterInstallManifest with closed client', async () => { - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkemulticloud.v1.GenerateAttachedClusterInstallManifestRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkemulticloud.v1.GenerateAttachedClusterInstallManifestRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.generateAttachedClusterInstallManifest(request), expectedError); - }); + it('invokes getAttachedCluster with closed client', async () => { + const client = new attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.GetAttachedClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkemulticloud.v1.GetAttachedClusterRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getAttachedCluster(request), expectedError); + }); + }); + + describe('getAttachedServerConfig', () => { + it('invokes getAttachedServerConfig without error', async () => { + const client = new attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.GetAttachedServerConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkemulticloud.v1.GetAttachedServerConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.AttachedServerConfig(), + ); + client.innerApiCalls.getAttachedServerConfig = + stubSimpleCall(expectedResponse); + const [response] = await client.getAttachedServerConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getAttachedServerConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getAttachedServerConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('generateAttachedClusterAgentToken', () => { - it('invokes generateAttachedClusterAgentToken without error', async () => { - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkemulticloud.v1.GenerateAttachedClusterAgentTokenRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkemulticloud.v1.GenerateAttachedClusterAgentTokenRequest', ['attachedCluster']); - request.attachedCluster = defaultValue1; - const expectedHeaderRequestParams = `attached_cluster=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.gkemulticloud.v1.GenerateAttachedClusterAgentTokenResponse() - ); - client.innerApiCalls.generateAttachedClusterAgentToken = stubSimpleCall(expectedResponse); - const [response] = await client.generateAttachedClusterAgentToken(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.generateAttachedClusterAgentToken as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.generateAttachedClusterAgentToken as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getAttachedServerConfig without error using callback', async () => { + const client = new attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.GetAttachedServerConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkemulticloud.v1.GetAttachedServerConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.AttachedServerConfig(), + ); + client.innerApiCalls.getAttachedServerConfig = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getAttachedServerConfig( + request, + ( + err?: Error | null, + result?: protos.google.cloud.gkemulticloud.v1.IAttachedServerConfig | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getAttachedServerConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getAttachedServerConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes generateAttachedClusterAgentToken without error using callback', async () => { - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkemulticloud.v1.GenerateAttachedClusterAgentTokenRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkemulticloud.v1.GenerateAttachedClusterAgentTokenRequest', ['attachedCluster']); - request.attachedCluster = defaultValue1; - const expectedHeaderRequestParams = `attached_cluster=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.gkemulticloud.v1.GenerateAttachedClusterAgentTokenResponse() - ); - client.innerApiCalls.generateAttachedClusterAgentToken = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.generateAttachedClusterAgentToken( - request, - (err?: Error|null, result?: protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterAgentTokenResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.generateAttachedClusterAgentToken as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.generateAttachedClusterAgentToken as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getAttachedServerConfig with error', async () => { + const client = new attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.GetAttachedServerConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkemulticloud.v1.GetAttachedServerConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getAttachedServerConfig = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getAttachedServerConfig(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.getAttachedServerConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getAttachedServerConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes generateAttachedClusterAgentToken with error', async () => { - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkemulticloud.v1.GenerateAttachedClusterAgentTokenRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkemulticloud.v1.GenerateAttachedClusterAgentTokenRequest', ['attachedCluster']); - request.attachedCluster = defaultValue1; - const expectedHeaderRequestParams = `attached_cluster=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.generateAttachedClusterAgentToken = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.generateAttachedClusterAgentToken(request), expectedError); - const actualRequest = (client.innerApiCalls.generateAttachedClusterAgentToken as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.generateAttachedClusterAgentToken as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getAttachedServerConfig with closed client', async () => { + const client = new attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.GetAttachedServerConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkemulticloud.v1.GetAttachedServerConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.getAttachedServerConfig(request), + expectedError, + ); + }); + }); + + describe('generateAttachedClusterInstallManifest', () => { + it('invokes generateAttachedClusterInstallManifest without error', async () => { + const client = new attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.GenerateAttachedClusterInstallManifestRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkemulticloud.v1.GenerateAttachedClusterInstallManifestRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.GenerateAttachedClusterInstallManifestResponse(), + ); + client.innerApiCalls.generateAttachedClusterInstallManifest = + stubSimpleCall(expectedResponse); + const [response] = + await client.generateAttachedClusterInstallManifest(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.generateAttachedClusterInstallManifest as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.generateAttachedClusterInstallManifest as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes generateAttachedClusterAgentToken with closed client', async () => { - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkemulticloud.v1.GenerateAttachedClusterAgentTokenRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkemulticloud.v1.GenerateAttachedClusterAgentTokenRequest', ['attachedCluster']); - request.attachedCluster = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.generateAttachedClusterAgentToken(request), expectedError); - }); + it('invokes generateAttachedClusterInstallManifest without error using callback', async () => { + const client = new attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.GenerateAttachedClusterInstallManifestRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkemulticloud.v1.GenerateAttachedClusterInstallManifestRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.GenerateAttachedClusterInstallManifestResponse(), + ); + client.innerApiCalls.generateAttachedClusterInstallManifest = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.generateAttachedClusterInstallManifest( + request, + ( + err?: Error | null, + result?: protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterInstallManifestResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.generateAttachedClusterInstallManifest as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.generateAttachedClusterInstallManifest as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createAttachedCluster', () => { - it('invokes createAttachedCluster without error', async () => { - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkemulticloud.v1.CreateAttachedClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkemulticloud.v1.CreateAttachedClusterRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createAttachedCluster = stubLongRunningCall(expectedResponse); - const [operation] = await client.createAttachedCluster(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createAttachedCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createAttachedCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes generateAttachedClusterInstallManifest with error', async () => { + const client = new attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.GenerateAttachedClusterInstallManifestRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkemulticloud.v1.GenerateAttachedClusterInstallManifestRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.generateAttachedClusterInstallManifest = + stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.generateAttachedClusterInstallManifest(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.generateAttachedClusterInstallManifest as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.generateAttachedClusterInstallManifest as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createAttachedCluster without error using callback', async () => { - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkemulticloud.v1.CreateAttachedClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkemulticloud.v1.CreateAttachedClusterRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createAttachedCluster = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createAttachedCluster( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createAttachedCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createAttachedCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes generateAttachedClusterInstallManifest with closed client', async () => { + const client = new attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.GenerateAttachedClusterInstallManifestRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkemulticloud.v1.GenerateAttachedClusterInstallManifestRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.generateAttachedClusterInstallManifest(request), + expectedError, + ); + }); + }); + + describe('generateAttachedClusterAgentToken', () => { + it('invokes generateAttachedClusterAgentToken without error', async () => { + const client = new attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.GenerateAttachedClusterAgentTokenRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkemulticloud.v1.GenerateAttachedClusterAgentTokenRequest', + ['attachedCluster'], + ); + request.attachedCluster = defaultValue1; + const expectedHeaderRequestParams = `attached_cluster=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.GenerateAttachedClusterAgentTokenResponse(), + ); + client.innerApiCalls.generateAttachedClusterAgentToken = + stubSimpleCall(expectedResponse); + const [response] = + await client.generateAttachedClusterAgentToken(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.generateAttachedClusterAgentToken as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.generateAttachedClusterAgentToken as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createAttachedCluster with call error', async () => { - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkemulticloud.v1.CreateAttachedClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkemulticloud.v1.CreateAttachedClusterRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createAttachedCluster = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createAttachedCluster(request), expectedError); - const actualRequest = (client.innerApiCalls.createAttachedCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createAttachedCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes generateAttachedClusterAgentToken without error using callback', async () => { + const client = new attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.GenerateAttachedClusterAgentTokenRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkemulticloud.v1.GenerateAttachedClusterAgentTokenRequest', + ['attachedCluster'], + ); + request.attachedCluster = defaultValue1; + const expectedHeaderRequestParams = `attached_cluster=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.GenerateAttachedClusterAgentTokenResponse(), + ); + client.innerApiCalls.generateAttachedClusterAgentToken = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.generateAttachedClusterAgentToken( + request, + ( + err?: Error | null, + result?: protos.google.cloud.gkemulticloud.v1.IGenerateAttachedClusterAgentTokenResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.generateAttachedClusterAgentToken as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.generateAttachedClusterAgentToken as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createAttachedCluster with LRO error', async () => { - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkemulticloud.v1.CreateAttachedClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkemulticloud.v1.CreateAttachedClusterRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createAttachedCluster = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createAttachedCluster(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createAttachedCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createAttachedCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes generateAttachedClusterAgentToken with error', async () => { + const client = new attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.GenerateAttachedClusterAgentTokenRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkemulticloud.v1.GenerateAttachedClusterAgentTokenRequest', + ['attachedCluster'], + ); + request.attachedCluster = defaultValue1; + const expectedHeaderRequestParams = `attached_cluster=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.generateAttachedClusterAgentToken = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.generateAttachedClusterAgentToken(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.generateAttachedClusterAgentToken as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.generateAttachedClusterAgentToken as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateAttachedClusterProgress without error', async () => { - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateAttachedClusterProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes generateAttachedClusterAgentToken with closed client', async () => { + const client = new attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.GenerateAttachedClusterAgentTokenRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkemulticloud.v1.GenerateAttachedClusterAgentTokenRequest', + ['attachedCluster'], + ); + request.attachedCluster = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.generateAttachedClusterAgentToken(request), + expectedError, + ); + }); + }); + + describe('createAttachedCluster', () => { + it('invokes createAttachedCluster without error', async () => { + const client = new attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.CreateAttachedClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkemulticloud.v1.CreateAttachedClusterRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createAttachedCluster = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createAttachedCluster(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createAttachedCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createAttachedCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateAttachedClusterProgress with error', async () => { - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateAttachedClusterProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes createAttachedCluster without error using callback', async () => { + const client = new attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.CreateAttachedClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkemulticloud.v1.CreateAttachedClusterRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createAttachedCluster = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createAttachedCluster( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.gkemulticloud.v1.IAttachedCluster, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.gkemulticloud.v1.IAttachedCluster, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createAttachedCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createAttachedCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateAttachedCluster', () => { - it('invokes updateAttachedCluster without error', async () => { - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkemulticloud.v1.UpdateAttachedClusterRequest() - ); - request.attachedCluster ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkemulticloud.v1.UpdateAttachedClusterRequest', ['attachedCluster', 'name']); - request.attachedCluster.name = defaultValue1; - const expectedHeaderRequestParams = `attached_cluster.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateAttachedCluster = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateAttachedCluster(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateAttachedCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateAttachedCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createAttachedCluster with call error', async () => { + const client = new attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.CreateAttachedClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkemulticloud.v1.CreateAttachedClusterRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createAttachedCluster = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.createAttachedCluster(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.createAttachedCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createAttachedCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateAttachedCluster without error using callback', async () => { - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkemulticloud.v1.UpdateAttachedClusterRequest() - ); - request.attachedCluster ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkemulticloud.v1.UpdateAttachedClusterRequest', ['attachedCluster', 'name']); - request.attachedCluster.name = defaultValue1; - const expectedHeaderRequestParams = `attached_cluster.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateAttachedCluster = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateAttachedCluster( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateAttachedCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateAttachedCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createAttachedCluster with LRO error', async () => { + const client = new attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.CreateAttachedClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkemulticloud.v1.CreateAttachedClusterRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createAttachedCluster = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createAttachedCluster(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createAttachedCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createAttachedCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateAttachedCluster with call error', async () => { - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkemulticloud.v1.UpdateAttachedClusterRequest() - ); - request.attachedCluster ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkemulticloud.v1.UpdateAttachedClusterRequest', ['attachedCluster', 'name']); - request.attachedCluster.name = defaultValue1; - const expectedHeaderRequestParams = `attached_cluster.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateAttachedCluster = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateAttachedCluster(request), expectedError); - const actualRequest = (client.innerApiCalls.updateAttachedCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateAttachedCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateAttachedClusterProgress without error', async () => { + const client = new attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateAttachedClusterProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes updateAttachedCluster with LRO error', async () => { - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkemulticloud.v1.UpdateAttachedClusterRequest() - ); - request.attachedCluster ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkemulticloud.v1.UpdateAttachedClusterRequest', ['attachedCluster', 'name']); - request.attachedCluster.name = defaultValue1; - const expectedHeaderRequestParams = `attached_cluster.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateAttachedCluster = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateAttachedCluster(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateAttachedCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateAttachedCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateAttachedClusterProgress with error', async () => { + const client = new attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateAttachedClusterProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateAttachedCluster', () => { + it('invokes updateAttachedCluster without error', async () => { + const client = new attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.UpdateAttachedClusterRequest(), + ); + request.attachedCluster ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkemulticloud.v1.UpdateAttachedClusterRequest', + ['attachedCluster', 'name'], + ); + request.attachedCluster.name = defaultValue1; + const expectedHeaderRequestParams = `attached_cluster.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateAttachedCluster = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateAttachedCluster(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateAttachedCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateAttachedCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateAttachedClusterProgress without error', async () => { - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateAttachedClusterProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes updateAttachedCluster without error using callback', async () => { + const client = new attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.UpdateAttachedClusterRequest(), + ); + request.attachedCluster ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkemulticloud.v1.UpdateAttachedClusterRequest', + ['attachedCluster', 'name'], + ); + request.attachedCluster.name = defaultValue1; + const expectedHeaderRequestParams = `attached_cluster.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateAttachedCluster = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateAttachedCluster( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.gkemulticloud.v1.IAttachedCluster, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.gkemulticloud.v1.IAttachedCluster, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateAttachedCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateAttachedCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateAttachedClusterProgress with error', async () => { - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateAttachedClusterProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes updateAttachedCluster with call error', async () => { + const client = new attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.UpdateAttachedClusterRequest(), + ); + request.attachedCluster ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkemulticloud.v1.UpdateAttachedClusterRequest', + ['attachedCluster', 'name'], + ); + request.attachedCluster.name = defaultValue1; + const expectedHeaderRequestParams = `attached_cluster.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateAttachedCluster = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.updateAttachedCluster(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.updateAttachedCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateAttachedCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('importAttachedCluster', () => { - it('invokes importAttachedCluster without error', async () => { - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkemulticloud.v1.ImportAttachedClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkemulticloud.v1.ImportAttachedClusterRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.importAttachedCluster = stubLongRunningCall(expectedResponse); - const [operation] = await client.importAttachedCluster(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.importAttachedCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importAttachedCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateAttachedCluster with LRO error', async () => { + const client = new attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.UpdateAttachedClusterRequest(), + ); + request.attachedCluster ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkemulticloud.v1.UpdateAttachedClusterRequest', + ['attachedCluster', 'name'], + ); + request.attachedCluster.name = defaultValue1; + const expectedHeaderRequestParams = `attached_cluster.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateAttachedCluster = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateAttachedCluster(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateAttachedCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateAttachedCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes importAttachedCluster without error using callback', async () => { - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkemulticloud.v1.ImportAttachedClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkemulticloud.v1.ImportAttachedClusterRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.importAttachedCluster = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.importAttachedCluster( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.importAttachedCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importAttachedCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateAttachedClusterProgress without error', async () => { + const client = new attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdateAttachedClusterProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes importAttachedCluster with call error', async () => { - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkemulticloud.v1.ImportAttachedClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkemulticloud.v1.ImportAttachedClusterRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.importAttachedCluster = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.importAttachedCluster(request), expectedError); - const actualRequest = (client.innerApiCalls.importAttachedCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importAttachedCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateAttachedClusterProgress with error', async () => { + const client = new attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateAttachedClusterProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('importAttachedCluster', () => { + it('invokes importAttachedCluster without error', async () => { + const client = new attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.ImportAttachedClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkemulticloud.v1.ImportAttachedClusterRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.importAttachedCluster = + stubLongRunningCall(expectedResponse); + const [operation] = await client.importAttachedCluster(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.importAttachedCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importAttachedCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes importAttachedCluster with LRO error', async () => { - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkemulticloud.v1.ImportAttachedClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkemulticloud.v1.ImportAttachedClusterRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.importAttachedCluster = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.importAttachedCluster(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.importAttachedCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importAttachedCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes importAttachedCluster without error using callback', async () => { + const client = new attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.ImportAttachedClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkemulticloud.v1.ImportAttachedClusterRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.importAttachedCluster = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.importAttachedCluster( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.gkemulticloud.v1.IAttachedCluster, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.gkemulticloud.v1.IAttachedCluster, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.importAttachedCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importAttachedCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkImportAttachedClusterProgress without error', async () => { - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkImportAttachedClusterProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes importAttachedCluster with call error', async () => { + const client = new attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.ImportAttachedClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkemulticloud.v1.ImportAttachedClusterRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importAttachedCluster = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.importAttachedCluster(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.importAttachedCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importAttachedCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkImportAttachedClusterProgress with error', async () => { - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkImportAttachedClusterProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes importAttachedCluster with LRO error', async () => { + const client = new attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.ImportAttachedClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkemulticloud.v1.ImportAttachedClusterRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importAttachedCluster = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.importAttachedCluster(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.importAttachedCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importAttachedCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteAttachedCluster', () => { - it('invokes deleteAttachedCluster without error', async () => { - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkemulticloud.v1.DeleteAttachedClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkemulticloud.v1.DeleteAttachedClusterRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteAttachedCluster = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteAttachedCluster(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteAttachedCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteAttachedCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkImportAttachedClusterProgress without error', async () => { + const client = new attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkImportAttachedClusterProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes deleteAttachedCluster without error using callback', async () => { - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkemulticloud.v1.DeleteAttachedClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkemulticloud.v1.DeleteAttachedClusterRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteAttachedCluster = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteAttachedCluster( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteAttachedCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteAttachedCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkImportAttachedClusterProgress with error', async () => { + const client = new attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkImportAttachedClusterProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteAttachedCluster', () => { + it('invokes deleteAttachedCluster without error', async () => { + const client = new attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.DeleteAttachedClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkemulticloud.v1.DeleteAttachedClusterRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteAttachedCluster = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteAttachedCluster(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteAttachedCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteAttachedCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteAttachedCluster with call error', async () => { - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkemulticloud.v1.DeleteAttachedClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkemulticloud.v1.DeleteAttachedClusterRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteAttachedCluster = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteAttachedCluster(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteAttachedCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteAttachedCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteAttachedCluster without error using callback', async () => { + const client = new attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.DeleteAttachedClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkemulticloud.v1.DeleteAttachedClusterRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteAttachedCluster = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteAttachedCluster( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.gkemulticloud.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteAttachedCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteAttachedCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteAttachedCluster with LRO error', async () => { - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkemulticloud.v1.DeleteAttachedClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkemulticloud.v1.DeleteAttachedClusterRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteAttachedCluster = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteAttachedCluster(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteAttachedCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteAttachedCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteAttachedCluster with call error', async () => { + const client = new attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.DeleteAttachedClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkemulticloud.v1.DeleteAttachedClusterRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteAttachedCluster = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.deleteAttachedCluster(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.deleteAttachedCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteAttachedCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteAttachedClusterProgress without error', async () => { - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteAttachedClusterProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes deleteAttachedCluster with LRO error', async () => { + const client = new attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.DeleteAttachedClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkemulticloud.v1.DeleteAttachedClusterRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteAttachedCluster = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteAttachedCluster(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteAttachedCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteAttachedCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteAttachedClusterProgress with error', async () => { - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteAttachedClusterProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkDeleteAttachedClusterProgress without error', async () => { + const client = new attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteAttachedClusterProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('listAttachedClusters', () => { - it('invokes listAttachedClusters without error', async () => { - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkemulticloud.v1.ListAttachedClustersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkemulticloud.v1.ListAttachedClustersRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkemulticloud.v1.AttachedCluster()), - generateSampleMessage(new protos.google.cloud.gkemulticloud.v1.AttachedCluster()), - generateSampleMessage(new protos.google.cloud.gkemulticloud.v1.AttachedCluster()), - ]; - client.innerApiCalls.listAttachedClusters = stubSimpleCall(expectedResponse); - const [response] = await client.listAttachedClusters(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listAttachedClusters as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listAttachedClusters as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteAttachedClusterProgress with error', async () => { + const client = new attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteAttachedClusterProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listAttachedClusters', () => { + it('invokes listAttachedClusters without error', async () => { + const client = new attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.ListAttachedClustersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkemulticloud.v1.ListAttachedClustersRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.AttachedCluster(), + ), + generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.AttachedCluster(), + ), + generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.AttachedCluster(), + ), + ]; + client.innerApiCalls.listAttachedClusters = + stubSimpleCall(expectedResponse); + const [response] = await client.listAttachedClusters(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listAttachedClusters as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listAttachedClusters as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listAttachedClusters without error using callback', async () => { - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkemulticloud.v1.ListAttachedClustersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkemulticloud.v1.ListAttachedClustersRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkemulticloud.v1.AttachedCluster()), - generateSampleMessage(new protos.google.cloud.gkemulticloud.v1.AttachedCluster()), - generateSampleMessage(new protos.google.cloud.gkemulticloud.v1.AttachedCluster()), - ]; - client.innerApiCalls.listAttachedClusters = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listAttachedClusters( - request, - (err?: Error|null, result?: protos.google.cloud.gkemulticloud.v1.IAttachedCluster[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listAttachedClusters as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listAttachedClusters as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listAttachedClusters without error using callback', async () => { + const client = new attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.ListAttachedClustersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkemulticloud.v1.ListAttachedClustersRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.AttachedCluster(), + ), + generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.AttachedCluster(), + ), + generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.AttachedCluster(), + ), + ]; + client.innerApiCalls.listAttachedClusters = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listAttachedClusters( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.gkemulticloud.v1.IAttachedCluster[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listAttachedClusters as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listAttachedClusters as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listAttachedClusters with error', async () => { - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkemulticloud.v1.ListAttachedClustersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkemulticloud.v1.ListAttachedClustersRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listAttachedClusters = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listAttachedClusters(request), expectedError); - const actualRequest = (client.innerApiCalls.listAttachedClusters as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listAttachedClusters as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listAttachedClusters with error', async () => { + const client = new attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.ListAttachedClustersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkemulticloud.v1.ListAttachedClustersRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listAttachedClusters = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listAttachedClusters(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listAttachedClusters as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listAttachedClusters as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listAttachedClustersStream without error', async () => { - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkemulticloud.v1.ListAttachedClustersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkemulticloud.v1.ListAttachedClustersRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkemulticloud.v1.AttachedCluster()), - generateSampleMessage(new protos.google.cloud.gkemulticloud.v1.AttachedCluster()), - generateSampleMessage(new protos.google.cloud.gkemulticloud.v1.AttachedCluster()), - ]; - client.descriptors.page.listAttachedClusters.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listAttachedClustersStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.gkemulticloud.v1.AttachedCluster[] = []; - stream.on('data', (response: protos.google.cloud.gkemulticloud.v1.AttachedCluster) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listAttachedClusters.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listAttachedClusters, request)); - assert( - (client.descriptors.page.listAttachedClusters.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listAttachedClustersStream without error', async () => { + const client = new attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.ListAttachedClustersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkemulticloud.v1.ListAttachedClustersRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.AttachedCluster(), + ), + generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.AttachedCluster(), + ), + generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.AttachedCluster(), + ), + ]; + client.descriptors.page.listAttachedClusters.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listAttachedClustersStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.gkemulticloud.v1.AttachedCluster[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.gkemulticloud.v1.AttachedCluster) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listAttachedClusters.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listAttachedClusters, request), + ); + assert( + (client.descriptors.page.listAttachedClusters.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listAttachedClustersStream with error', async () => { - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkemulticloud.v1.ListAttachedClustersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkemulticloud.v1.ListAttachedClustersRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listAttachedClusters.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listAttachedClustersStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.gkemulticloud.v1.AttachedCluster[] = []; - stream.on('data', (response: protos.google.cloud.gkemulticloud.v1.AttachedCluster) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listAttachedClusters.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listAttachedClusters, request)); - assert( - (client.descriptors.page.listAttachedClusters.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listAttachedClustersStream with error', async () => { + const client = new attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.ListAttachedClustersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkemulticloud.v1.ListAttachedClustersRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listAttachedClusters.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listAttachedClustersStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.gkemulticloud.v1.AttachedCluster[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.gkemulticloud.v1.AttachedCluster) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listAttachedClusters.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listAttachedClusters, request), + ); + assert( + (client.descriptors.page.listAttachedClusters.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listAttachedClusters without error', async () => { - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkemulticloud.v1.ListAttachedClustersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkemulticloud.v1.ListAttachedClustersRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkemulticloud.v1.AttachedCluster()), - generateSampleMessage(new protos.google.cloud.gkemulticloud.v1.AttachedCluster()), - generateSampleMessage(new protos.google.cloud.gkemulticloud.v1.AttachedCluster()), - ]; - client.descriptors.page.listAttachedClusters.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.gkemulticloud.v1.IAttachedCluster[] = []; - const iterable = client.listAttachedClustersAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listAttachedClusters.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listAttachedClusters.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listAttachedClusters without error', async () => { + const client = new attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.ListAttachedClustersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkemulticloud.v1.ListAttachedClustersRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.AttachedCluster(), + ), + generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.AttachedCluster(), + ), + generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.AttachedCluster(), + ), + ]; + client.descriptors.page.listAttachedClusters.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.gkemulticloud.v1.IAttachedCluster[] = + []; + const iterable = client.listAttachedClustersAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listAttachedClusters.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listAttachedClusters.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listAttachedClusters with error', async () => { - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkemulticloud.v1.ListAttachedClustersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gkemulticloud.v1.ListAttachedClustersRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listAttachedClusters.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listAttachedClustersAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.gkemulticloud.v1.IAttachedCluster[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listAttachedClusters.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listAttachedClusters.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listAttachedClusters with error', async () => { + const client = new attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkemulticloud.v1.ListAttachedClustersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gkemulticloud.v1.ListAttachedClustersRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listAttachedClusters.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAttachedClustersAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.gkemulticloud.v1.IAttachedCluster[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listAttachedClusters.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listAttachedClusters.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 attachedclustersModule.v1.AttachedClustersClient({ - 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 attachedclustersModule.v1.AttachedClustersClient({ - 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 attachedclustersModule.v1.AttachedClustersClient({ - 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 attachedclustersModule.v1.AttachedClustersClient({ + 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 attachedclustersModule.v1.AttachedClustersClient({ - 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 attachedclustersModule.v1.AttachedClustersClient({ - 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 attachedclustersModule.v1.AttachedClustersClient({ - 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 attachedclustersModule.v1.AttachedClustersClient({ + 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 attachedclustersModule.v1.AttachedClustersClient({ - 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 attachedclustersModule.v1.AttachedClustersClient({ - 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 attachedclustersModule.v1.AttachedClustersClient({ - 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 attachedclustersModule.v1.AttachedClustersClient({ + 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 attachedclustersModule.v1.AttachedClustersClient({ - 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 attachedclustersModule.v1.AttachedClustersClient({ - 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 attachedclustersModule.v1.AttachedClustersClient({ + 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 attachedclustersModule.v1.AttachedClustersClient({ + 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 attachedclustersModule.v1.AttachedClustersClient({ + 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 attachedclustersModule.v1.AttachedClustersClient({ + 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 attachedclustersModule.v1.AttachedClustersClient({ + 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 attachedclustersModule.v1.AttachedClustersClient({ + 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 attachedclustersModule.v1.AttachedClustersClient({ + 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 attachedclustersModule.v1.AttachedClustersClient({ + 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('attachedCluster', async () => { + const fakePath = '/rendered/path/attachedCluster'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + attached_cluster: 'attachedClusterValue', + }; + const client = new attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.attachedClusterPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.attachedClusterPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('attachedClusterPath', () => { + const result = client.attachedClusterPath( + 'projectValue', + 'locationValue', + 'attachedClusterValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.attachedClusterPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromAttachedClusterName', () => { + const result = client.matchProjectFromAttachedClusterName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.attachedClusterPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromAttachedClusterName', () => { + const result = client.matchLocationFromAttachedClusterName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.attachedClusterPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchAttachedClusterFromAttachedClusterName', () => { + const result = + client.matchAttachedClusterFromAttachedClusterName(fakePath); + assert.strictEqual(result, 'attachedClusterValue'); + assert( + (client.pathTemplates.attachedClusterPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); - describe('Path templates', () => { - - describe('attachedCluster', async () => { - const fakePath = "/rendered/path/attachedCluster"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - attached_cluster: "attachedClusterValue", - }; - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.attachedClusterPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.attachedClusterPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('attachedClusterPath', () => { - const result = client.attachedClusterPath("projectValue", "locationValue", "attachedClusterValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.attachedClusterPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAttachedClusterName', () => { - const result = client.matchProjectFromAttachedClusterName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.attachedClusterPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromAttachedClusterName', () => { - const result = client.matchLocationFromAttachedClusterName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.attachedClusterPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchAttachedClusterFromAttachedClusterName', () => { - const result = client.matchAttachedClusterFromAttachedClusterName(fakePath); - assert.strictEqual(result, "attachedClusterValue"); - assert((client.pathTemplates.attachedClusterPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('attachedServerConfig', async () => { - const fakePath = "/rendered/path/attachedServerConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.attachedServerConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.attachedServerConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('attachedServerConfigPath', () => { - const result = client.attachedServerConfigPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.attachedServerConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAttachedServerConfigName', () => { - const result = client.matchProjectFromAttachedServerConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.attachedServerConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromAttachedServerConfigName', () => { - const result = client.matchLocationFromAttachedServerConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.attachedServerConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('attachedServerConfig', async () => { + const fakePath = '/rendered/path/attachedServerConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = new attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.attachedServerConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.attachedServerConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('attachedServerConfigPath', () => { + const result = client.attachedServerConfigPath( + 'projectValue', + 'locationValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.attachedServerConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromAttachedServerConfigName', () => { + const result = + client.matchProjectFromAttachedServerConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.attachedServerConfigPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromAttachedServerConfigName', () => { + const result = + client.matchLocationFromAttachedServerConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.attachedServerConfigPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('awsCluster', async () => { - const fakePath = "/rendered/path/awsCluster"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - aws_cluster: "awsClusterValue", - }; - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.awsClusterPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.awsClusterPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('awsClusterPath', () => { - const result = client.awsClusterPath("projectValue", "locationValue", "awsClusterValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.awsClusterPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAwsClusterName', () => { - const result = client.matchProjectFromAwsClusterName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.awsClusterPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromAwsClusterName', () => { - const result = client.matchLocationFromAwsClusterName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.awsClusterPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchAwsClusterFromAwsClusterName', () => { - const result = client.matchAwsClusterFromAwsClusterName(fakePath); - assert.strictEqual(result, "awsClusterValue"); - assert((client.pathTemplates.awsClusterPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('awsCluster', async () => { + const fakePath = '/rendered/path/awsCluster'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + aws_cluster: 'awsClusterValue', + }; + const client = new attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.awsClusterPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.awsClusterPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('awsClusterPath', () => { + const result = client.awsClusterPath( + 'projectValue', + 'locationValue', + 'awsClusterValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.awsClusterPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromAwsClusterName', () => { + const result = client.matchProjectFromAwsClusterName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.awsClusterPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromAwsClusterName', () => { + const result = client.matchLocationFromAwsClusterName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.awsClusterPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchAwsClusterFromAwsClusterName', () => { + const result = client.matchAwsClusterFromAwsClusterName(fakePath); + assert.strictEqual(result, 'awsClusterValue'); + assert( + (client.pathTemplates.awsClusterPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('awsNodePool', async () => { - const fakePath = "/rendered/path/awsNodePool"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - aws_cluster: "awsClusterValue", - aws_node_pool: "awsNodePoolValue", - }; - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.awsNodePoolPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.awsNodePoolPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('awsNodePoolPath', () => { - const result = client.awsNodePoolPath("projectValue", "locationValue", "awsClusterValue", "awsNodePoolValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.awsNodePoolPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAwsNodePoolName', () => { - const result = client.matchProjectFromAwsNodePoolName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.awsNodePoolPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromAwsNodePoolName', () => { - const result = client.matchLocationFromAwsNodePoolName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.awsNodePoolPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchAwsClusterFromAwsNodePoolName', () => { - const result = client.matchAwsClusterFromAwsNodePoolName(fakePath); - assert.strictEqual(result, "awsClusterValue"); - assert((client.pathTemplates.awsNodePoolPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchAwsNodePoolFromAwsNodePoolName', () => { - const result = client.matchAwsNodePoolFromAwsNodePoolName(fakePath); - assert.strictEqual(result, "awsNodePoolValue"); - assert((client.pathTemplates.awsNodePoolPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('awsNodePool', async () => { + const fakePath = '/rendered/path/awsNodePool'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + aws_cluster: 'awsClusterValue', + aws_node_pool: 'awsNodePoolValue', + }; + const client = new attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.awsNodePoolPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.awsNodePoolPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('awsNodePoolPath', () => { + const result = client.awsNodePoolPath( + 'projectValue', + 'locationValue', + 'awsClusterValue', + 'awsNodePoolValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.awsNodePoolPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromAwsNodePoolName', () => { + const result = client.matchProjectFromAwsNodePoolName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.awsNodePoolPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromAwsNodePoolName', () => { + const result = client.matchLocationFromAwsNodePoolName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.awsNodePoolPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchAwsClusterFromAwsNodePoolName', () => { + const result = client.matchAwsClusterFromAwsNodePoolName(fakePath); + assert.strictEqual(result, 'awsClusterValue'); + assert( + (client.pathTemplates.awsNodePoolPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchAwsNodePoolFromAwsNodePoolName', () => { + const result = client.matchAwsNodePoolFromAwsNodePoolName(fakePath); + assert.strictEqual(result, 'awsNodePoolValue'); + assert( + (client.pathTemplates.awsNodePoolPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('awsServerConfig', async () => { - const fakePath = "/rendered/path/awsServerConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.awsServerConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.awsServerConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('awsServerConfigPath', () => { - const result = client.awsServerConfigPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.awsServerConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAwsServerConfigName', () => { - const result = client.matchProjectFromAwsServerConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.awsServerConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromAwsServerConfigName', () => { - const result = client.matchLocationFromAwsServerConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.awsServerConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('awsServerConfig', async () => { + const fakePath = '/rendered/path/awsServerConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = new attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.awsServerConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.awsServerConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('awsServerConfigPath', () => { + const result = client.awsServerConfigPath( + 'projectValue', + 'locationValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.awsServerConfigPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromAwsServerConfigName', () => { + const result = client.matchProjectFromAwsServerConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.awsServerConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromAwsServerConfigName', () => { + const result = client.matchLocationFromAwsServerConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.awsServerConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('azureClient', async () => { - const fakePath = "/rendered/path/azureClient"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - azure_client: "azureClientValue", - }; - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.azureClientPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.azureClientPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('azureClientPath', () => { - const result = client.azureClientPath("projectValue", "locationValue", "azureClientValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.azureClientPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAzureClientName', () => { - const result = client.matchProjectFromAzureClientName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.azureClientPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromAzureClientName', () => { - const result = client.matchLocationFromAzureClientName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.azureClientPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchAzureClientFromAzureClientName', () => { - const result = client.matchAzureClientFromAzureClientName(fakePath); - assert.strictEqual(result, "azureClientValue"); - assert((client.pathTemplates.azureClientPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('azureClient', async () => { + const fakePath = '/rendered/path/azureClient'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + azure_client: 'azureClientValue', + }; + const client = new attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.azureClientPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.azureClientPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('azureClientPath', () => { + const result = client.azureClientPath( + 'projectValue', + 'locationValue', + 'azureClientValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.azureClientPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromAzureClientName', () => { + const result = client.matchProjectFromAzureClientName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.azureClientPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromAzureClientName', () => { + const result = client.matchLocationFromAzureClientName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.azureClientPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchAzureClientFromAzureClientName', () => { + const result = client.matchAzureClientFromAzureClientName(fakePath); + assert.strictEqual(result, 'azureClientValue'); + assert( + (client.pathTemplates.azureClientPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('azureCluster', async () => { - const fakePath = "/rendered/path/azureCluster"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - azure_cluster: "azureClusterValue", - }; - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.azureClusterPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.azureClusterPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('azureClusterPath', () => { - const result = client.azureClusterPath("projectValue", "locationValue", "azureClusterValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.azureClusterPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAzureClusterName', () => { - const result = client.matchProjectFromAzureClusterName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.azureClusterPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromAzureClusterName', () => { - const result = client.matchLocationFromAzureClusterName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.azureClusterPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchAzureClusterFromAzureClusterName', () => { - const result = client.matchAzureClusterFromAzureClusterName(fakePath); - assert.strictEqual(result, "azureClusterValue"); - assert((client.pathTemplates.azureClusterPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('azureCluster', async () => { + const fakePath = '/rendered/path/azureCluster'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + azure_cluster: 'azureClusterValue', + }; + const client = new attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.azureClusterPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.azureClusterPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('azureClusterPath', () => { + const result = client.azureClusterPath( + 'projectValue', + 'locationValue', + 'azureClusterValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.azureClusterPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromAzureClusterName', () => { + const result = client.matchProjectFromAzureClusterName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.azureClusterPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromAzureClusterName', () => { + const result = client.matchLocationFromAzureClusterName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.azureClusterPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchAzureClusterFromAzureClusterName', () => { + const result = client.matchAzureClusterFromAzureClusterName(fakePath); + assert.strictEqual(result, 'azureClusterValue'); + assert( + (client.pathTemplates.azureClusterPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('azureNodePool', async () => { - const fakePath = "/rendered/path/azureNodePool"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - azure_cluster: "azureClusterValue", - azure_node_pool: "azureNodePoolValue", - }; - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.azureNodePoolPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.azureNodePoolPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('azureNodePoolPath', () => { - const result = client.azureNodePoolPath("projectValue", "locationValue", "azureClusterValue", "azureNodePoolValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.azureNodePoolPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAzureNodePoolName', () => { - const result = client.matchProjectFromAzureNodePoolName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.azureNodePoolPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromAzureNodePoolName', () => { - const result = client.matchLocationFromAzureNodePoolName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.azureNodePoolPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchAzureClusterFromAzureNodePoolName', () => { - const result = client.matchAzureClusterFromAzureNodePoolName(fakePath); - assert.strictEqual(result, "azureClusterValue"); - assert((client.pathTemplates.azureNodePoolPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchAzureNodePoolFromAzureNodePoolName', () => { - const result = client.matchAzureNodePoolFromAzureNodePoolName(fakePath); - assert.strictEqual(result, "azureNodePoolValue"); - assert((client.pathTemplates.azureNodePoolPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('azureNodePool', async () => { + const fakePath = '/rendered/path/azureNodePool'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + azure_cluster: 'azureClusterValue', + azure_node_pool: 'azureNodePoolValue', + }; + const client = new attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.azureNodePoolPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.azureNodePoolPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('azureNodePoolPath', () => { + const result = client.azureNodePoolPath( + 'projectValue', + 'locationValue', + 'azureClusterValue', + 'azureNodePoolValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.azureNodePoolPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromAzureNodePoolName', () => { + const result = client.matchProjectFromAzureNodePoolName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.azureNodePoolPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromAzureNodePoolName', () => { + const result = client.matchLocationFromAzureNodePoolName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.azureNodePoolPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchAzureClusterFromAzureNodePoolName', () => { + const result = client.matchAzureClusterFromAzureNodePoolName(fakePath); + assert.strictEqual(result, 'azureClusterValue'); + assert( + (client.pathTemplates.azureNodePoolPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchAzureNodePoolFromAzureNodePoolName', () => { + const result = client.matchAzureNodePoolFromAzureNodePoolName(fakePath); + assert.strictEqual(result, 'azureNodePoolValue'); + assert( + (client.pathTemplates.azureNodePoolPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('azureServerConfig', async () => { - const fakePath = "/rendered/path/azureServerConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new attachedclustersModule.v1.AttachedClustersClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.azureServerConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.azureServerConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('azureServerConfigPath', () => { - const result = client.azureServerConfigPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.azureServerConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAzureServerConfigName', () => { - const result = client.matchProjectFromAzureServerConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.azureServerConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromAzureServerConfigName', () => { - const result = client.matchLocationFromAzureServerConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.azureServerConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('azureServerConfig', async () => { + const fakePath = '/rendered/path/azureServerConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = new attachedclustersModule.v1.AttachedClustersClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.azureServerConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.azureServerConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('azureServerConfigPath', () => { + const result = client.azureServerConfigPath( + 'projectValue', + 'locationValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.azureServerConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromAzureServerConfigName', () => { + const result = client.matchProjectFromAzureServerConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.azureServerConfigPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromAzureServerConfigName', () => { + const result = client.matchLocationFromAzureServerConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.azureServerConfigPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('location', async () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new attachedclustersModule.v1.AttachedClustersClient({ - 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 attachedclustersModule.v1.AttachedClustersClient({ + 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 attachedclustersModule.v1.AttachedClustersClient({ - 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 attachedclustersModule.v1.AttachedClustersClient({ + 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-gkemulticloud/webpack.config.js b/packages/google-cloud-gkemulticloud/webpack.config.js index df641e6f0aa1..01b1c9f6e02c 100644 --- a/packages/google-cloud-gkemulticloud/webpack.config.js +++ b/packages/google-cloud-gkemulticloud/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-gkerecommender/.eslintignore b/packages/google-cloud-gkerecommender/.eslintignore new file mode 100644 index 000000000000..cfc348ec4d11 --- /dev/null +++ b/packages/google-cloud-gkerecommender/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/packages/google-cloud-gkerecommender/.eslintrc.json b/packages/google-cloud-gkerecommender/.eslintrc.json new file mode 100644 index 000000000000..3e8d97ccb390 --- /dev/null +++ b/packages/google-cloud-gkerecommender/.eslintrc.json @@ -0,0 +1,4 @@ +{ + "extends": "./node_modules/gts", + "root": true +} diff --git a/packages/google-cloud-gkerecommender/README.md b/packages/google-cloud-gkerecommender/README.md index 53b5676f88f6..6e97d620991f 100644 --- a/packages/google-cloud-gkerecommender/README.md +++ b/packages/google-cloud-gkerecommender/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-gkerecommender/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-gkerecommender/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-gkerecommender/protos/protos.d.ts b/packages/google-cloud-gkerecommender/protos/protos.d.ts index 0c70708fb7e9..238ae9ca60ac 100644 --- a/packages/google-cloud-gkerecommender/protos/protos.d.ts +++ b/packages/google-cloud-gkerecommender/protos/protos.d.ts @@ -3172,6 +3172,9 @@ export namespace google { /** CommonLanguageSettings destinations */ destinations?: (google.api.ClientLibraryDestination[]|null); + + /** CommonLanguageSettings selectiveGapicGeneration */ + selectiveGapicGeneration?: (google.api.ISelectiveGapicGeneration|null); } /** Represents a CommonLanguageSettings. */ @@ -3189,6 +3192,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 @@ -3889,6 +3895,9 @@ export namespace google { /** PythonSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** PythonSettings experimentalFeatures */ + experimentalFeatures?: (google.api.PythonSettings.IExperimentalFeatures|null); } /** Represents a PythonSettings. */ @@ -3903,6 +3912,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 @@ -3981,6 +3993,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 { @@ -4307,6 +4431,9 @@ export namespace google { /** GoSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** GoSettings renamedServices */ + renamedServices?: ({ [k: string]: string }|null); } /** Represents a GoSettings. */ @@ -4321,6 +4448,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 @@ -4645,6 +4775,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, @@ -4774,6 +5007,7 @@ export namespace google { /** Edition enum. */ enum Edition { EDITION_UNKNOWN = 0, + EDITION_LEGACY = 900, EDITION_PROTO2 = 998, EDITION_PROTO3 = 999, EDITION_2023 = 1000, @@ -4804,6 +5038,9 @@ export namespace google { /** FileDescriptorProto weakDependency */ weakDependency?: (number[]|null); + /** FileDescriptorProto optionDependency */ + optionDependency?: (string[]|null); + /** FileDescriptorProto messageType */ messageType?: (google.protobuf.IDescriptorProto[]|null); @@ -4853,6 +5090,9 @@ export namespace google { /** FileDescriptorProto weakDependency. */ public weakDependency: number[]; + /** FileDescriptorProto optionDependency. */ + public optionDependency: string[]; + /** FileDescriptorProto messageType. */ public messageType: google.protobuf.IDescriptorProto[]; @@ -4987,6 +5227,9 @@ export namespace google { /** DescriptorProto reservedName */ reservedName?: (string[]|null); + + /** DescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents a DescriptorProto. */ @@ -5028,6 +5271,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 @@ -5875,6 +6121,9 @@ export namespace google { /** EnumDescriptorProto reservedName */ reservedName?: (string[]|null); + + /** EnumDescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents an EnumDescriptorProto. */ @@ -5901,6 +6150,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 @@ -6829,6 +7081,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); @@ -6881,6 +7136,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[]; @@ -7101,6 +7359,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. */ @@ -7339,6 +7712,9 @@ export namespace google { /** EnumValueOptions debugRedact */ debugRedact?: (boolean|null); + /** EnumValueOptions featureSupport */ + featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** EnumValueOptions uninterpretedOption */ uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); } @@ -7361,6 +7737,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[]; @@ -7950,6 +8329,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. */ @@ -7979,6 +8364,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 @@ -8101,6 +8492,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. */ @@ -8220,8 +8721,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. */ @@ -8236,8 +8740,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. @@ -8770,6 +9277,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-gkerecommender/protos/protos.js b/packages/google-cloud-gkerecommender/protos/protos.js index f2cf3a71d0af..26c05509fe1f 100644 --- a/packages/google-cloud-gkerecommender/protos/protos.js +++ b/packages/google-cloud-gkerecommender/protos/protos.js @@ -7750,6 +7750,7 @@ * @interface ICommonLanguageSettings * @property {string|null} [referenceDocsUri] CommonLanguageSettings referenceDocsUri * @property {Array.|null} [destinations] CommonLanguageSettings destinations + * @property {google.api.ISelectiveGapicGeneration|null} [selectiveGapicGeneration] CommonLanguageSettings selectiveGapicGeneration */ /** @@ -7784,6 +7785,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 @@ -7816,6 +7825,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; }; @@ -7867,6 +7878,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; @@ -7918,6 +7933,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; }; @@ -7960,6 +7980,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; }; @@ -7978,8 +8003,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) { @@ -7987,6 +8014,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; }; @@ -9809,6 +9838,7 @@ * @memberof google.api * @interface IPythonSettings * @property {google.api.ICommonLanguageSettings|null} [common] PythonSettings common + * @property {google.api.PythonSettings.IExperimentalFeatures|null} [experimentalFeatures] PythonSettings experimentalFeatures */ /** @@ -9834,6 +9864,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 @@ -9860,6 +9898,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; }; @@ -9900,6 +9940,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; @@ -9940,6 +9984,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; }; @@ -9960,6 +10009,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; }; @@ -9976,10 +10030,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; }; @@ -10009,6 +10067,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; })(); @@ -10885,6 +11195,7 @@ * @memberof google.api * @interface IGoSettings * @property {google.api.ICommonLanguageSettings|null} [common] GoSettings common + * @property {Object.|null} [renamedServices] GoSettings renamedServices */ /** @@ -10896,6 +11207,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) @@ -10910,6 +11222,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 @@ -10936,6 +11256,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; }; @@ -10966,7 +11289,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) @@ -10976,6 +11299,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; @@ -11016,6 +11362,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; }; @@ -11036,6 +11390,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; }; @@ -11052,10 +11413,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; }; @@ -11694,29 +12063,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; })(); @@ -11991,6 +12605,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 @@ -12005,6 +12620,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; @@ -12029,6 +12645,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 @@ -12051,6 +12668,7 @@ this.dependency = []; this.publicDependency = []; this.weakDependency = []; + this.optionDependency = []; this.messageType = []; this.enumType = []; this.service = []; @@ -12101,6 +12719,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 @@ -12222,6 +12848,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; }; @@ -12294,6 +12923,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 = []; @@ -12396,6 +13031,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"; @@ -12450,6 +13092,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -12502,6 +13145,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"); @@ -12565,6 +13215,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -12630,6 +13284,7 @@ object.extension = []; object.publicDependency = []; object.weakDependency = []; + object.optionDependency = []; } if (options.defaults) { object.name = ""; @@ -12686,6 +13341,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; }; @@ -12734,6 +13394,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 */ /** @@ -12839,6 +13500,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 @@ -12891,6 +13560,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; }; @@ -12983,6 +13654,10 @@ message.reservedName.push(reader.string()); break; } + case 11: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -13096,6 +13771,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; }; @@ -13195,6 +13879,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; }; @@ -13224,6 +13928,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; @@ -13269,6 +13974,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; }; @@ -15313,6 +16020,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 */ /** @@ -15373,6 +16081,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 @@ -15410,6 +16126,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; }; @@ -15472,6 +16190,10 @@ message.reservedName.push(reader.string()); break; } + case 6: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -15540,6 +16262,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; }; @@ -15589,6 +16320,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; }; @@ -15613,6 +16364,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; @@ -15633,6 +16385,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; }; @@ -17878,6 +18632,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 */ @@ -17997,6 +18752,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 @@ -18063,6 +18826,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(); @@ -18162,6 +18927,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 = []; @@ -18293,6 +19062,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"; @@ -18476,6 +19250,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"); @@ -18568,6 +19347,7 @@ object.debugRedact = false; object.retention = options.enums === String ? "RETENTION_UNKNOWN" : 0; object.features = null; + object.featureSupport = null; } if (message.ctype != null && message.hasOwnProperty("ctype")) object.ctype = options.enums === String ? $root.google.protobuf.FieldOptions.CType[message.ctype] === undefined ? message.ctype : $root.google.protobuf.FieldOptions.CType[message.ctype] : message.ctype; @@ -18599,6 +19379,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) @@ -18869,6 +19651,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -18910,103 +19693,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; @@ -19601,6 +20870,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 */ @@ -19644,6 +20914,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 @@ -19682,6 +20960,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(); @@ -19733,6 +21013,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 = []; @@ -19785,6 +21069,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"; @@ -19818,6 +21107,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"); @@ -19850,6 +21144,7 @@ object.deprecated = false; object.features = null; object.debugRedact = false; + object.featureSupport = null; } if (message.deprecated != null && message.hasOwnProperty("deprecated")) object.deprecated = message.deprecated; @@ -19857,6 +21152,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) @@ -21296,6 +22593,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 */ /** @@ -21361,6 +22660,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 @@ -21397,6 +22712,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; }; @@ -21457,6 +22776,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; @@ -21547,6 +22874,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; }; @@ -21686,6 +23033,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; }; @@ -21709,6 +23104,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; @@ -21722,6 +23119,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; }; @@ -21849,6 +23250,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; })(); @@ -22033,6 +23647,7 @@ default: return "minimumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -22050,6 +23665,7 @@ default: return "maximumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -22098,6 +23714,10 @@ case 0: message.minimumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.minimumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.minimumEdition = 998; @@ -22150,6 +23770,10 @@ case 0: message.maximumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.maximumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.maximumEdition = 998; @@ -22258,7 +23882,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 */ /** @@ -22285,12 +23910,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. @@ -22316,10 +23949,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; }; @@ -22360,8 +23995,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: @@ -22404,6 +24043,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -22416,10 +24056,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; }; @@ -22447,6 +24092,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -22488,10 +24137,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; }; @@ -22510,13 +24164,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; }; @@ -23731,6 +25388,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-gkerecommender/protos/protos.json b/packages/google-cloud-gkerecommender/protos/protos.json index 44898330a4f2..07068f71b19c 100644 --- a/packages/google-cloud-gkerecommender/protos/protos.json +++ b/packages/google-cloud-gkerecommender/protos/protos.json @@ -821,8 +821,7 @@ "java_multiple_files": true, "java_outer_classname": "FieldBehaviorProto", "java_package": "com.google.api", - "objc_class_prefix": "GAPI", - "cc_enable_arenas": true + "objc_class_prefix": "GAPI" }, "nested": { "http": { @@ -946,6 +945,10 @@ "rule": "repeated", "type": "ClientLibraryDestination", "id": 2 + }, + "selectiveGapicGeneration": { + "type": "SelectiveGapicGeneration", + "id": 3 } } }, @@ -1086,6 +1089,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 + } + } } } }, @@ -1143,6 +1168,11 @@ "common": { "type": "CommonLanguageSettings", "id": 1 + }, + "renamedServices": { + "keyType": "string", + "type": "string", + "id": 2 } } }, @@ -1204,6 +1234,19 @@ "PACKAGE_MANAGER": 20 } }, + "SelectiveGapicGeneration": { + "fields": { + "methods": { + "rule": "repeated", + "type": "string", + "id": 1 + }, + "generateOmittedAsInternal": { + "type": "bool", + "id": 2 + } + } + }, "LaunchStage": { "values": { "LAUNCH_STAGE_UNSPECIFIED": 0, @@ -1259,12 +1302,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, @@ -1303,6 +1353,11 @@ "type": "int32", "id": 11 }, + "optionDependency": { + "rule": "repeated", + "type": "string", + "id": 15 + }, "messageType": { "rule": "repeated", "type": "DescriptorProto", @@ -1391,6 +1446,10 @@ "rule": "repeated", "type": "string", "id": 10 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 11 } }, "nested": { @@ -1616,6 +1675,10 @@ "rule": "repeated", "type": "string", "id": 5 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 6 } }, "nested": { @@ -1666,7 +1729,14 @@ "type": "ServiceOptions", "id": 3 } - } + }, + "reserved": [ + [ + 4, + 4 + ], + "stream" + ] }, "MethodDescriptorProto": { "edition": "proto2", @@ -1830,6 +1900,7 @@ 42, 42 ], + "php_generic_services", [ 38, 38 @@ -1965,7 +2036,8 @@ "type": "bool", "id": 10, "options": { - "default": false + "default": false, + "deprecated": true } }, "debugRedact": { @@ -1993,6 +2065,10 @@ "type": "FeatureSet", "id": 21 }, + "featureSupport": { + "type": "FeatureSupport", + "id": 22 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -2062,6 +2138,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 + } + } } } }, @@ -2150,6 +2246,10 @@ "default": false } }, + "featureSupport": { + "type": "FieldOptions.FeatureSupport", + "id": 4 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -2292,6 +2392,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_2023", "edition_defaults.value": "EXPLICIT" } @@ -2302,6 +2403,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "OPEN" } @@ -2312,6 +2414,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "PACKED" } @@ -2322,6 +2425,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "VERIFY" } @@ -2332,7 +2436,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" } }, @@ -2342,27 +2447,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, @@ -2407,7 +2523,13 @@ "UTF8_VALIDATION_UNKNOWN": 0, "VERIFY": 2, "NONE": 3 - } + }, + "reserved": [ + [ + 1, + 1 + ] + ] }, "MessageEncoding": { "values": { @@ -2422,6 +2544,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 + } + } + } } } }, @@ -2449,11 +2598,26 @@ "type": "Edition", "id": 3 }, - "features": { + "overridableFeatures": { "type": "FeatureSet", - "id": 2 + "id": 4 + }, + "fixedFeatures": { + "type": "FeatureSet", + "id": 5 } - } + }, + "reserved": [ + [ + 1, + 1 + ], + [ + 2, + 2 + ], + "features" + ] } } }, @@ -2466,6 +2630,12 @@ "id": 1 } }, + "extensions": [ + [ + 536000000, + 536000000 + ] + ], "nested": { "Location": { "fields": { @@ -2551,6 +2721,14 @@ } } }, + "SymbolVisibility": { + "edition": "proto2", + "values": { + "VISIBILITY_UNSET": 0, + "VISIBILITY_LOCAL": 1, + "VISIBILITY_EXPORT": 2 + } + }, "Duration": { "fields": { "seconds": { diff --git a/packages/google-cloud-gkerecommender/src/v1/gke_inference_quickstart_client.ts b/packages/google-cloud-gkerecommender/src/v1/gke_inference_quickstart_client.ts index e5777b36d8c5..d73dbd48d1c2 100644 --- a/packages/google-cloud-gkerecommender/src/v1/gke_inference_quickstart_client.ts +++ b/packages/google-cloud-gkerecommender/src/v1/gke_inference_quickstart_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 @@ -47,7 +54,7 @@ export class GkeInferenceQuickstartClient { 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('gkerecommender'); @@ -60,8 +67,8 @@ export class GkeInferenceQuickstartClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - gkeInferenceQuickstartStub?: Promise<{[name: string]: Function}>; + innerApiCalls: { [name: string]: Function }; + gkeInferenceQuickstartStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of GkeInferenceQuickstartClient. @@ -102,21 +109,43 @@ export class GkeInferenceQuickstartClient { * const client = new GkeInferenceQuickstartClient({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 GkeInferenceQuickstartClient; - 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 GkeInferenceQuickstartClient; + 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 = 'gkerecommender.' + 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 +170,7 @@ export class GkeInferenceQuickstartClient { 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,10 +184,7 @@ export class GkeInferenceQuickstartClient { } // 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,20 +205,35 @@ export class GkeInferenceQuickstartClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - fetchModels: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'models'), - fetchModelServers: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'modelServers'), - fetchModelServerVersions: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'modelServerVersions'), - fetchProfiles: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'profile') + fetchModels: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'models', + ), + fetchModelServers: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'modelServers', + ), + fetchModelServerVersions: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'modelServerVersions', + ), + fetchProfiles: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'profile', + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.gkerecommender.v1.GkeInferenceQuickstart', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.gkerecommender.v1.GkeInferenceQuickstart', + 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 @@ -223,37 +264,48 @@ export class GkeInferenceQuickstartClient { // Put together the "service stub" for // google.cloud.gkerecommender.v1.GkeInferenceQuickstart. this.gkeInferenceQuickstartStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.gkerecommender.v1.GkeInferenceQuickstart') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.gkerecommender.v1.GkeInferenceQuickstart, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.gkerecommender.v1.GkeInferenceQuickstart', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.gkerecommender.v1 + .GkeInferenceQuickstart, + 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 gkeInferenceQuickstartStubMethods = - ['fetchModels', 'fetchModelServers', 'fetchModelServerVersions', 'fetchProfiles', 'generateOptimizedManifest', 'fetchBenchmarkingData']; + const gkeInferenceQuickstartStubMethods = [ + 'fetchModels', + 'fetchModelServers', + 'fetchModelServerVersions', + 'fetchProfiles', + 'generateOptimizedManifest', + 'fetchBenchmarkingData', + ]; for (const methodName of gkeInferenceQuickstartStubMethods) { const callPromise = this.gkeInferenceQuickstartStub.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; @@ -268,8 +320,14 @@ export class GkeInferenceQuickstartClient { * @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 'gkerecommender.googleapis.com'; } @@ -280,8 +338,14 @@ export class GkeInferenceQuickstartClient { * @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 'gkerecommender.googleapis.com'; } @@ -312,9 +376,7 @@ export class GkeInferenceQuickstartClient { * @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; @@ -323,8 +385,9 @@ export class GkeInferenceQuickstartClient { * 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; @@ -335,306 +398,432 @@ export class GkeInferenceQuickstartClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Generates an optimized deployment manifest for a given model and model - * server, based on the specified accelerator, performance targets, and - * configurations. See [Run best practice inference with GKE Inference - * Quickstart - * recipes](https://cloud.google.com/kubernetes-engine/docs/how-to/machine-learning/inference/inference-quickstart) - * for deployment details. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.gkerecommender.v1.ModelServerInfo} request.modelServerInfo - * Required. The model server configuration to generate the manifest for. Use - * {@link protos.google.cloud.gkerecommender.v1.GkeInferenceQuickstart.FetchProfiles|GkeInferenceQuickstart.FetchProfiles} - * to find valid configurations. - * @param {string} request.acceleratorType - * Required. The accelerator type. Use - * {@link protos.google.cloud.gkerecommender.v1.GkeInferenceQuickstart.FetchProfiles|GkeInferenceQuickstart.FetchProfiles} - * to find valid accelerators for a given `model_server_info`. - * @param {string} [request.kubernetesNamespace] - * Optional. The kubernetes namespace to deploy the manifests in. - * @param {google.cloud.gkerecommender.v1.PerformanceRequirements} [request.performanceRequirements] - * Optional. The performance requirements to use for generating Horizontal Pod - * Autoscaler (HPA) resources. If provided, the manifest includes HPA - * resources to adjust the model server replica count to maintain the - * specified targets (e.g., NTPOT, TTFT) at a P50 latency. Cost targets are - * not currently supported for HPA generation. If the specified targets are - * not achievable, the HPA manifest will not be generated. - * @param {google.cloud.gkerecommender.v1.StorageConfig} [request.storageConfig] - * Optional. The storage configuration for the model. If not provided, the - * model is loaded from Huggingface. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.gkerecommender.v1.GenerateOptimizedManifestResponse|GenerateOptimizedManifestResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_inference_quickstart.generate_optimized_manifest.js - * region_tag:gkerecommender_v1_generated_GkeInferenceQuickstart_GenerateOptimizedManifest_async - */ + /** + * Generates an optimized deployment manifest for a given model and model + * server, based on the specified accelerator, performance targets, and + * configurations. See [Run best practice inference with GKE Inference + * Quickstart + * recipes](https://cloud.google.com/kubernetes-engine/docs/how-to/machine-learning/inference/inference-quickstart) + * for deployment details. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.gkerecommender.v1.ModelServerInfo} request.modelServerInfo + * Required. The model server configuration to generate the manifest for. Use + * {@link protos.google.cloud.gkerecommender.v1.GkeInferenceQuickstart.FetchProfiles|GkeInferenceQuickstart.FetchProfiles} + * to find valid configurations. + * @param {string} request.acceleratorType + * Required. The accelerator type. Use + * {@link protos.google.cloud.gkerecommender.v1.GkeInferenceQuickstart.FetchProfiles|GkeInferenceQuickstart.FetchProfiles} + * to find valid accelerators for a given `model_server_info`. + * @param {string} [request.kubernetesNamespace] + * Optional. The kubernetes namespace to deploy the manifests in. + * @param {google.cloud.gkerecommender.v1.PerformanceRequirements} [request.performanceRequirements] + * Optional. The performance requirements to use for generating Horizontal Pod + * Autoscaler (HPA) resources. If provided, the manifest includes HPA + * resources to adjust the model server replica count to maintain the + * specified targets (e.g., NTPOT, TTFT) at a P50 latency. Cost targets are + * not currently supported for HPA generation. If the specified targets are + * not achievable, the HPA manifest will not be generated. + * @param {google.cloud.gkerecommender.v1.StorageConfig} [request.storageConfig] + * Optional. The storage configuration for the model. If not provided, the + * model is loaded from Huggingface. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.gkerecommender.v1.GenerateOptimizedManifestResponse|GenerateOptimizedManifestResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_inference_quickstart.generate_optimized_manifest.js + * region_tag:gkerecommender_v1_generated_GkeInferenceQuickstart_GenerateOptimizedManifest_async + */ generateOptimizedManifest( - request?: protos.google.cloud.gkerecommender.v1.IGenerateOptimizedManifestRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gkerecommender.v1.IGenerateOptimizedManifestResponse, - protos.google.cloud.gkerecommender.v1.IGenerateOptimizedManifestRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkerecommender.v1.IGenerateOptimizedManifestRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gkerecommender.v1.IGenerateOptimizedManifestResponse, + ( + | protos.google.cloud.gkerecommender.v1.IGenerateOptimizedManifestRequest + | undefined + ), + {} | undefined, + ] + >; generateOptimizedManifest( - request: protos.google.cloud.gkerecommender.v1.IGenerateOptimizedManifestRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.gkerecommender.v1.IGenerateOptimizedManifestResponse, - protos.google.cloud.gkerecommender.v1.IGenerateOptimizedManifestRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkerecommender.v1.IGenerateOptimizedManifestRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.gkerecommender.v1.IGenerateOptimizedManifestResponse, + | protos.google.cloud.gkerecommender.v1.IGenerateOptimizedManifestRequest + | null + | undefined, + {} | null | undefined + >, + ): void; generateOptimizedManifest( - request: protos.google.cloud.gkerecommender.v1.IGenerateOptimizedManifestRequest, - callback: Callback< - protos.google.cloud.gkerecommender.v1.IGenerateOptimizedManifestResponse, - protos.google.cloud.gkerecommender.v1.IGenerateOptimizedManifestRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkerecommender.v1.IGenerateOptimizedManifestRequest, + callback: Callback< + protos.google.cloud.gkerecommender.v1.IGenerateOptimizedManifestResponse, + | protos.google.cloud.gkerecommender.v1.IGenerateOptimizedManifestRequest + | null + | undefined, + {} | null | undefined + >, + ): void; generateOptimizedManifest( - request?: protos.google.cloud.gkerecommender.v1.IGenerateOptimizedManifestRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.gkerecommender.v1.IGenerateOptimizedManifestResponse, - protos.google.cloud.gkerecommender.v1.IGenerateOptimizedManifestRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.gkerecommender.v1.IGenerateOptimizedManifestRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.gkerecommender.v1.IGenerateOptimizedManifestResponse, - protos.google.cloud.gkerecommender.v1.IGenerateOptimizedManifestRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.gkerecommender.v1.IGenerateOptimizedManifestResponse, - protos.google.cloud.gkerecommender.v1.IGenerateOptimizedManifestRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.gkerecommender.v1.IGenerateOptimizedManifestRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.gkerecommender.v1.IGenerateOptimizedManifestResponse, + | protos.google.cloud.gkerecommender.v1.IGenerateOptimizedManifestRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.gkerecommender.v1.IGenerateOptimizedManifestResponse, + ( + | protos.google.cloud.gkerecommender.v1.IGenerateOptimizedManifestRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === '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('generateOptimizedManifest request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.gkerecommender.v1.IGenerateOptimizedManifestResponse, - protos.google.cloud.gkerecommender.v1.IGenerateOptimizedManifestRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.gkerecommender.v1.IGenerateOptimizedManifestResponse, + | protos.google.cloud.gkerecommender.v1.IGenerateOptimizedManifestRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('generateOptimizedManifest response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.generateOptimizedManifest(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.gkerecommender.v1.IGenerateOptimizedManifestResponse, - protos.google.cloud.gkerecommender.v1.IGenerateOptimizedManifestRequest|undefined, - {}|undefined - ]) => { - this._log.info('generateOptimizedManifest response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .generateOptimizedManifest(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.gkerecommender.v1.IGenerateOptimizedManifestResponse, + ( + | protos.google.cloud.gkerecommender.v1.IGenerateOptimizedManifestRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('generateOptimizedManifest response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Fetches all of the benchmarking data available for a profile. Benchmarking - * data returns all of the performance metrics available for a given model - * server setup on a given instance type. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.gkerecommender.v1.ModelServerInfo} request.modelServerInfo - * Required. The model server configuration to get benchmarking data for. Use - * {@link protos.google.cloud.gkerecommender.v1.GkeInferenceQuickstart.FetchProfiles|GkeInferenceQuickstart.FetchProfiles} - * to find valid configurations. - * @param {string} [request.instanceType] - * Optional. The instance type to filter benchmarking data. Instance types are - * in the format `a2-highgpu-1g`. If not provided, all instance types for the - * given profile's `model_server_info` will be returned. Use - * {@link protos.google.cloud.gkerecommender.v1.GkeInferenceQuickstart.FetchProfiles|GkeInferenceQuickstart.FetchProfiles} - * to find available instance types. - * @param {string} [request.pricingModel] - * Optional. The pricing model to use for the benchmarking data. Defaults to - * `spot`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.gkerecommender.v1.FetchBenchmarkingDataResponse|FetchBenchmarkingDataResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/gke_inference_quickstart.fetch_benchmarking_data.js - * region_tag:gkerecommender_v1_generated_GkeInferenceQuickstart_FetchBenchmarkingData_async - */ + /** + * Fetches all of the benchmarking data available for a profile. Benchmarking + * data returns all of the performance metrics available for a given model + * server setup on a given instance type. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.gkerecommender.v1.ModelServerInfo} request.modelServerInfo + * Required. The model server configuration to get benchmarking data for. Use + * {@link protos.google.cloud.gkerecommender.v1.GkeInferenceQuickstart.FetchProfiles|GkeInferenceQuickstart.FetchProfiles} + * to find valid configurations. + * @param {string} [request.instanceType] + * Optional. The instance type to filter benchmarking data. Instance types are + * in the format `a2-highgpu-1g`. If not provided, all instance types for the + * given profile's `model_server_info` will be returned. Use + * {@link protos.google.cloud.gkerecommender.v1.GkeInferenceQuickstart.FetchProfiles|GkeInferenceQuickstart.FetchProfiles} + * to find available instance types. + * @param {string} [request.pricingModel] + * Optional. The pricing model to use for the benchmarking data. Defaults to + * `spot`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.gkerecommender.v1.FetchBenchmarkingDataResponse|FetchBenchmarkingDataResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/gke_inference_quickstart.fetch_benchmarking_data.js + * region_tag:gkerecommender_v1_generated_GkeInferenceQuickstart_FetchBenchmarkingData_async + */ fetchBenchmarkingData( - request?: protos.google.cloud.gkerecommender.v1.IFetchBenchmarkingDataRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gkerecommender.v1.IFetchBenchmarkingDataResponse, - protos.google.cloud.gkerecommender.v1.IFetchBenchmarkingDataRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gkerecommender.v1.IFetchBenchmarkingDataRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gkerecommender.v1.IFetchBenchmarkingDataResponse, + ( + | protos.google.cloud.gkerecommender.v1.IFetchBenchmarkingDataRequest + | undefined + ), + {} | undefined, + ] + >; fetchBenchmarkingData( - request: protos.google.cloud.gkerecommender.v1.IFetchBenchmarkingDataRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.gkerecommender.v1.IFetchBenchmarkingDataResponse, - protos.google.cloud.gkerecommender.v1.IFetchBenchmarkingDataRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkerecommender.v1.IFetchBenchmarkingDataRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.gkerecommender.v1.IFetchBenchmarkingDataResponse, + | protos.google.cloud.gkerecommender.v1.IFetchBenchmarkingDataRequest + | null + | undefined, + {} | null | undefined + >, + ): void; fetchBenchmarkingData( - request: protos.google.cloud.gkerecommender.v1.IFetchBenchmarkingDataRequest, - callback: Callback< - protos.google.cloud.gkerecommender.v1.IFetchBenchmarkingDataResponse, - protos.google.cloud.gkerecommender.v1.IFetchBenchmarkingDataRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gkerecommender.v1.IFetchBenchmarkingDataRequest, + callback: Callback< + protos.google.cloud.gkerecommender.v1.IFetchBenchmarkingDataResponse, + | protos.google.cloud.gkerecommender.v1.IFetchBenchmarkingDataRequest + | null + | undefined, + {} | null | undefined + >, + ): void; fetchBenchmarkingData( - request?: protos.google.cloud.gkerecommender.v1.IFetchBenchmarkingDataRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.gkerecommender.v1.IFetchBenchmarkingDataRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.gkerecommender.v1.IFetchBenchmarkingDataResponse, - protos.google.cloud.gkerecommender.v1.IFetchBenchmarkingDataRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.gkerecommender.v1.IFetchBenchmarkingDataResponse, - protos.google.cloud.gkerecommender.v1.IFetchBenchmarkingDataRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.gkerecommender.v1.IFetchBenchmarkingDataResponse, - protos.google.cloud.gkerecommender.v1.IFetchBenchmarkingDataRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.gkerecommender.v1.IFetchBenchmarkingDataRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.gkerecommender.v1.IFetchBenchmarkingDataResponse, + | protos.google.cloud.gkerecommender.v1.IFetchBenchmarkingDataRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.gkerecommender.v1.IFetchBenchmarkingDataResponse, + ( + | protos.google.cloud.gkerecommender.v1.IFetchBenchmarkingDataRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === '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('fetchBenchmarkingData request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.gkerecommender.v1.IFetchBenchmarkingDataResponse, - protos.google.cloud.gkerecommender.v1.IFetchBenchmarkingDataRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.gkerecommender.v1.IFetchBenchmarkingDataResponse, + | protos.google.cloud.gkerecommender.v1.IFetchBenchmarkingDataRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('fetchBenchmarkingData response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.fetchBenchmarkingData(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.gkerecommender.v1.IFetchBenchmarkingDataResponse, - protos.google.cloud.gkerecommender.v1.IFetchBenchmarkingDataRequest|undefined, - {}|undefined - ]) => { - this._log.info('fetchBenchmarkingData response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .fetchBenchmarkingData(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.gkerecommender.v1.IFetchBenchmarkingDataResponse, + ( + | protos.google.cloud.gkerecommender.v1.IFetchBenchmarkingDataRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('fetchBenchmarkingData response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } - /** - * Fetches available models. Open-source models follow the Huggingface Hub - * `owner/model_name` format. - * - * @param {Object} request - * The request object that will be sent. - * @param {number} [request.pageSize] - * Optional. The target number of results to return in a single response. - * If not specified, a default value will be chosen by the service. - * Note that the response may include a partial list and a caller should - * only rely on the response's - * {@link protos.google.cloud.gkerecommender.v1.FetchModelsResponse.next_page_token|next_page_token} - * to determine if there are more instances left to be queried. - * @param {string} [request.pageToken] - * Optional. The value of - * {@link protos.google.cloud.gkerecommender.v1.FetchModelsResponse.next_page_token|next_page_token} - * received from a previous `FetchModelsRequest` call. - * Provide this to retrieve the subsequent page in a multi-page list of - * results. When paginating, all other parameters provided to - * `FetchModelsRequest` 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 string. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `fetchModelsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Fetches available models. Open-source models follow the Huggingface Hub + * `owner/model_name` format. + * + * @param {Object} request + * The request object that will be sent. + * @param {number} [request.pageSize] + * Optional. The target number of results to return in a single response. + * If not specified, a default value will be chosen by the service. + * Note that the response may include a partial list and a caller should + * only rely on the response's + * {@link protos.google.cloud.gkerecommender.v1.FetchModelsResponse.next_page_token|next_page_token} + * to determine if there are more instances left to be queried. + * @param {string} [request.pageToken] + * Optional. The value of + * {@link protos.google.cloud.gkerecommender.v1.FetchModelsResponse.next_page_token|next_page_token} + * received from a previous `FetchModelsRequest` call. + * Provide this to retrieve the subsequent page in a multi-page list of + * results. When paginating, all other parameters provided to + * `FetchModelsRequest` 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 string. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `fetchModelsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ fetchModels( - request?: protos.google.cloud.gkerecommender.v1.IFetchModelsRequest, - options?: CallOptions): - Promise<[ - string[], - protos.google.cloud.gkerecommender.v1.IFetchModelsRequest|null, - protos.google.cloud.gkerecommender.v1.IFetchModelsResponse - ]>; + request?: protos.google.cloud.gkerecommender.v1.IFetchModelsRequest, + options?: CallOptions, + ): Promise< + [ + string[], + protos.google.cloud.gkerecommender.v1.IFetchModelsRequest | null, + protos.google.cloud.gkerecommender.v1.IFetchModelsResponse, + ] + >; fetchModels( - request: protos.google.cloud.gkerecommender.v1.IFetchModelsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.gkerecommender.v1.IFetchModelsRequest, - protos.google.cloud.gkerecommender.v1.IFetchModelsResponse|null|undefined, - string>): void; + request: protos.google.cloud.gkerecommender.v1.IFetchModelsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.gkerecommender.v1.IFetchModelsRequest, + | protos.google.cloud.gkerecommender.v1.IFetchModelsResponse + | null + | undefined, + string + >, + ): void; fetchModels( - request: protos.google.cloud.gkerecommender.v1.IFetchModelsRequest, - callback: PaginationCallback< - protos.google.cloud.gkerecommender.v1.IFetchModelsRequest, - protos.google.cloud.gkerecommender.v1.IFetchModelsResponse|null|undefined, - string>): void; + request: protos.google.cloud.gkerecommender.v1.IFetchModelsRequest, + callback: PaginationCallback< + protos.google.cloud.gkerecommender.v1.IFetchModelsRequest, + | protos.google.cloud.gkerecommender.v1.IFetchModelsResponse + | null + | undefined, + string + >, + ): void; fetchModels( - request?: protos.google.cloud.gkerecommender.v1.IFetchModelsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.gkerecommender.v1.IFetchModelsRequest, - protos.google.cloud.gkerecommender.v1.IFetchModelsResponse|null|undefined, - string>, - callback?: PaginationCallback< + request?: protos.google.cloud.gkerecommender.v1.IFetchModelsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.gkerecommender.v1.IFetchModelsRequest, - protos.google.cloud.gkerecommender.v1.IFetchModelsResponse|null|undefined, - string>): - Promise<[ - string[], - protos.google.cloud.gkerecommender.v1.IFetchModelsRequest|null, - protos.google.cloud.gkerecommender.v1.IFetchModelsResponse - ]>|void { + | protos.google.cloud.gkerecommender.v1.IFetchModelsResponse + | null + | undefined, + string + >, + callback?: PaginationCallback< + protos.google.cloud.gkerecommender.v1.IFetchModelsRequest, + | protos.google.cloud.gkerecommender.v1.IFetchModelsResponse + | null + | undefined, + string + >, + ): Promise< + [ + string[], + protos.google.cloud.gkerecommender.v1.IFetchModelsRequest | null, + protos.google.cloud.gkerecommender.v1.IFetchModelsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === '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.gkerecommender.v1.IFetchModelsRequest, - protos.google.cloud.gkerecommender.v1.IFetchModelsResponse|null|undefined, - string>|undefined = callback + this.initialize().catch((err) => { + throw err; + }); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.gkerecommender.v1.IFetchModelsRequest, + | protos.google.cloud.gkerecommender.v1.IFetchModelsResponse + | null + | undefined, + string + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('fetchModels values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -643,205 +832,237 @@ export class GkeInferenceQuickstartClient { this._log.info('fetchModels request %j', request); return this.innerApiCalls .fetchModels(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - string[], - protos.google.cloud.gkerecommender.v1.IFetchModelsRequest|null, - protos.google.cloud.gkerecommender.v1.IFetchModelsResponse - ]) => { - this._log.info('fetchModels values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + string[], + protos.google.cloud.gkerecommender.v1.IFetchModelsRequest | null, + protos.google.cloud.gkerecommender.v1.IFetchModelsResponse, + ]) => { + this._log.info('fetchModels values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `fetchModels`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {number} [request.pageSize] - * Optional. The target number of results to return in a single response. - * If not specified, a default value will be chosen by the service. - * Note that the response may include a partial list and a caller should - * only rely on the response's - * {@link protos.google.cloud.gkerecommender.v1.FetchModelsResponse.next_page_token|next_page_token} - * to determine if there are more instances left to be queried. - * @param {string} [request.pageToken] - * Optional. The value of - * {@link protos.google.cloud.gkerecommender.v1.FetchModelsResponse.next_page_token|next_page_token} - * received from a previous `FetchModelsRequest` call. - * Provide this to retrieve the subsequent page in a multi-page list of - * results. When paginating, all other parameters provided to - * `FetchModelsRequest` 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 string on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `fetchModelsAsync()` - * method described below for async iteration which you can stop as 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 `fetchModels`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {number} [request.pageSize] + * Optional. The target number of results to return in a single response. + * If not specified, a default value will be chosen by the service. + * Note that the response may include a partial list and a caller should + * only rely on the response's + * {@link protos.google.cloud.gkerecommender.v1.FetchModelsResponse.next_page_token|next_page_token} + * to determine if there are more instances left to be queried. + * @param {string} [request.pageToken] + * Optional. The value of + * {@link protos.google.cloud.gkerecommender.v1.FetchModelsResponse.next_page_token|next_page_token} + * received from a previous `FetchModelsRequest` call. + * Provide this to retrieve the subsequent page in a multi-page list of + * results. When paginating, all other parameters provided to + * `FetchModelsRequest` 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 string on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `fetchModelsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ fetchModelsStream( - request?: protos.google.cloud.gkerecommender.v1.IFetchModelsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.gkerecommender.v1.IFetchModelsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; const defaultCallSettings = this._defaults['fetchModels']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('fetchModels stream %j', request); return this.descriptors.page.fetchModels.createStream( this.innerApiCalls.fetchModels as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `fetchModels`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {number} [request.pageSize] - * Optional. The target number of results to return in a single response. - * If not specified, a default value will be chosen by the service. - * Note that the response may include a partial list and a caller should - * only rely on the response's - * {@link protos.google.cloud.gkerecommender.v1.FetchModelsResponse.next_page_token|next_page_token} - * to determine if there are more instances left to be queried. - * @param {string} [request.pageToken] - * Optional. The value of - * {@link protos.google.cloud.gkerecommender.v1.FetchModelsResponse.next_page_token|next_page_token} - * received from a previous `FetchModelsRequest` call. - * Provide this to retrieve the subsequent page in a multi-page list of - * results. When paginating, all other parameters provided to - * `FetchModelsRequest` 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 - * string. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@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/gke_inference_quickstart.fetch_models.js - * region_tag:gkerecommender_v1_generated_GkeInferenceQuickstart_FetchModels_async - */ + /** + * Equivalent to `fetchModels`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {number} [request.pageSize] + * Optional. The target number of results to return in a single response. + * If not specified, a default value will be chosen by the service. + * Note that the response may include a partial list and a caller should + * only rely on the response's + * {@link protos.google.cloud.gkerecommender.v1.FetchModelsResponse.next_page_token|next_page_token} + * to determine if there are more instances left to be queried. + * @param {string} [request.pageToken] + * Optional. The value of + * {@link protos.google.cloud.gkerecommender.v1.FetchModelsResponse.next_page_token|next_page_token} + * received from a previous `FetchModelsRequest` call. + * Provide this to retrieve the subsequent page in a multi-page list of + * results. When paginating, all other parameters provided to + * `FetchModelsRequest` 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 + * string. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@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/gke_inference_quickstart.fetch_models.js + * region_tag:gkerecommender_v1_generated_GkeInferenceQuickstart_FetchModels_async + */ fetchModelsAsync( - request?: protos.google.cloud.gkerecommender.v1.IFetchModelsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.gkerecommender.v1.IFetchModelsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; const defaultCallSettings = this._defaults['fetchModels']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('fetchModels iterate %j', request); return this.descriptors.page.fetchModels.asyncIterate( this.innerApiCalls['fetchModels'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Fetches available model servers. Open-source model servers use simplified, - * lowercase names (e.g., `vllm`). - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.model - * Required. The model for which to list model servers. Open-source models - * follow the Huggingface Hub `owner/model_name` format. Use - * {@link protos.google.cloud.gkerecommender.v1.GkeInferenceQuickstart.FetchModels|GkeInferenceQuickstart.FetchModels} - * to find available models. - * @param {number} [request.pageSize] - * Optional. The target number of results to return in a single response. - * If not specified, a default value will be chosen by the service. - * Note that the response may include a partial list and a caller should - * only rely on the response's - * {@link protos.google.cloud.gkerecommender.v1.FetchModelServersResponse.next_page_token|next_page_token} - * to determine if there are more instances left to be queried. - * @param {string} [request.pageToken] - * Optional. The value of - * {@link protos.google.cloud.gkerecommender.v1.FetchModelServersResponse.next_page_token|next_page_token} - * received from a previous `FetchModelServersRequest` call. - * Provide this to retrieve the subsequent page in a multi-page list of - * results. When paginating, all other parameters provided to - * `FetchModelServersRequest` 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 string. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `fetchModelServersAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Fetches available model servers. Open-source model servers use simplified, + * lowercase names (e.g., `vllm`). + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.model + * Required. The model for which to list model servers. Open-source models + * follow the Huggingface Hub `owner/model_name` format. Use + * {@link protos.google.cloud.gkerecommender.v1.GkeInferenceQuickstart.FetchModels|GkeInferenceQuickstart.FetchModels} + * to find available models. + * @param {number} [request.pageSize] + * Optional. The target number of results to return in a single response. + * If not specified, a default value will be chosen by the service. + * Note that the response may include a partial list and a caller should + * only rely on the response's + * {@link protos.google.cloud.gkerecommender.v1.FetchModelServersResponse.next_page_token|next_page_token} + * to determine if there are more instances left to be queried. + * @param {string} [request.pageToken] + * Optional. The value of + * {@link protos.google.cloud.gkerecommender.v1.FetchModelServersResponse.next_page_token|next_page_token} + * received from a previous `FetchModelServersRequest` call. + * Provide this to retrieve the subsequent page in a multi-page list of + * results. When paginating, all other parameters provided to + * `FetchModelServersRequest` 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 string. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `fetchModelServersAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ fetchModelServers( - request?: protos.google.cloud.gkerecommender.v1.IFetchModelServersRequest, - options?: CallOptions): - Promise<[ - string[], - protos.google.cloud.gkerecommender.v1.IFetchModelServersRequest|null, - protos.google.cloud.gkerecommender.v1.IFetchModelServersResponse - ]>; + request?: protos.google.cloud.gkerecommender.v1.IFetchModelServersRequest, + options?: CallOptions, + ): Promise< + [ + string[], + protos.google.cloud.gkerecommender.v1.IFetchModelServersRequest | null, + protos.google.cloud.gkerecommender.v1.IFetchModelServersResponse, + ] + >; fetchModelServers( - request: protos.google.cloud.gkerecommender.v1.IFetchModelServersRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.gkerecommender.v1.IFetchModelServersRequest, - protos.google.cloud.gkerecommender.v1.IFetchModelServersResponse|null|undefined, - string>): void; + request: protos.google.cloud.gkerecommender.v1.IFetchModelServersRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.gkerecommender.v1.IFetchModelServersRequest, + | protos.google.cloud.gkerecommender.v1.IFetchModelServersResponse + | null + | undefined, + string + >, + ): void; fetchModelServers( - request: protos.google.cloud.gkerecommender.v1.IFetchModelServersRequest, - callback: PaginationCallback< - protos.google.cloud.gkerecommender.v1.IFetchModelServersRequest, - protos.google.cloud.gkerecommender.v1.IFetchModelServersResponse|null|undefined, - string>): void; + request: protos.google.cloud.gkerecommender.v1.IFetchModelServersRequest, + callback: PaginationCallback< + protos.google.cloud.gkerecommender.v1.IFetchModelServersRequest, + | protos.google.cloud.gkerecommender.v1.IFetchModelServersResponse + | null + | undefined, + string + >, + ): void; fetchModelServers( - request?: protos.google.cloud.gkerecommender.v1.IFetchModelServersRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.gkerecommender.v1.IFetchModelServersRequest, - protos.google.cloud.gkerecommender.v1.IFetchModelServersResponse|null|undefined, - string>, - callback?: PaginationCallback< + request?: protos.google.cloud.gkerecommender.v1.IFetchModelServersRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.gkerecommender.v1.IFetchModelServersRequest, - protos.google.cloud.gkerecommender.v1.IFetchModelServersResponse|null|undefined, - string>): - Promise<[ - string[], - protos.google.cloud.gkerecommender.v1.IFetchModelServersRequest|null, - protos.google.cloud.gkerecommender.v1.IFetchModelServersResponse - ]>|void { + | protos.google.cloud.gkerecommender.v1.IFetchModelServersResponse + | null + | undefined, + string + >, + callback?: PaginationCallback< + protos.google.cloud.gkerecommender.v1.IFetchModelServersRequest, + | protos.google.cloud.gkerecommender.v1.IFetchModelServersResponse + | null + | undefined, + string + >, + ): Promise< + [ + string[], + protos.google.cloud.gkerecommender.v1.IFetchModelServersRequest | null, + protos.google.cloud.gkerecommender.v1.IFetchModelServersResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === '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.gkerecommender.v1.IFetchModelServersRequest, - protos.google.cloud.gkerecommender.v1.IFetchModelServersResponse|null|undefined, - string>|undefined = callback + this.initialize().catch((err) => { + throw err; + }); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.gkerecommender.v1.IFetchModelServersRequest, + | protos.google.cloud.gkerecommender.v1.IFetchModelServersResponse + | null + | undefined, + string + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('fetchModelServers values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -850,227 +1071,259 @@ export class GkeInferenceQuickstartClient { this._log.info('fetchModelServers request %j', request); return this.innerApiCalls .fetchModelServers(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - string[], - protos.google.cloud.gkerecommender.v1.IFetchModelServersRequest|null, - protos.google.cloud.gkerecommender.v1.IFetchModelServersResponse - ]) => { - this._log.info('fetchModelServers values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + string[], + protos.google.cloud.gkerecommender.v1.IFetchModelServersRequest | null, + protos.google.cloud.gkerecommender.v1.IFetchModelServersResponse, + ]) => { + this._log.info('fetchModelServers values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `fetchModelServers`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.model - * Required. The model for which to list model servers. Open-source models - * follow the Huggingface Hub `owner/model_name` format. Use - * {@link protos.google.cloud.gkerecommender.v1.GkeInferenceQuickstart.FetchModels|GkeInferenceQuickstart.FetchModels} - * to find available models. - * @param {number} [request.pageSize] - * Optional. The target number of results to return in a single response. - * If not specified, a default value will be chosen by the service. - * Note that the response may include a partial list and a caller should - * only rely on the response's - * {@link protos.google.cloud.gkerecommender.v1.FetchModelServersResponse.next_page_token|next_page_token} - * to determine if there are more instances left to be queried. - * @param {string} [request.pageToken] - * Optional. The value of - * {@link protos.google.cloud.gkerecommender.v1.FetchModelServersResponse.next_page_token|next_page_token} - * received from a previous `FetchModelServersRequest` call. - * Provide this to retrieve the subsequent page in a multi-page list of - * results. When paginating, all other parameters provided to - * `FetchModelServersRequest` 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 string on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `fetchModelServersAsync()` - * method described below for async iteration which you can stop as 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 `fetchModelServers`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.model + * Required. The model for which to list model servers. Open-source models + * follow the Huggingface Hub `owner/model_name` format. Use + * {@link protos.google.cloud.gkerecommender.v1.GkeInferenceQuickstart.FetchModels|GkeInferenceQuickstart.FetchModels} + * to find available models. + * @param {number} [request.pageSize] + * Optional. The target number of results to return in a single response. + * If not specified, a default value will be chosen by the service. + * Note that the response may include a partial list and a caller should + * only rely on the response's + * {@link protos.google.cloud.gkerecommender.v1.FetchModelServersResponse.next_page_token|next_page_token} + * to determine if there are more instances left to be queried. + * @param {string} [request.pageToken] + * Optional. The value of + * {@link protos.google.cloud.gkerecommender.v1.FetchModelServersResponse.next_page_token|next_page_token} + * received from a previous `FetchModelServersRequest` call. + * Provide this to retrieve the subsequent page in a multi-page list of + * results. When paginating, all other parameters provided to + * `FetchModelServersRequest` 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 string on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `fetchModelServersAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ fetchModelServersStream( - request?: protos.google.cloud.gkerecommender.v1.IFetchModelServersRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.gkerecommender.v1.IFetchModelServersRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; const defaultCallSettings = this._defaults['fetchModelServers']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('fetchModelServers stream %j', request); return this.descriptors.page.fetchModelServers.createStream( this.innerApiCalls.fetchModelServers as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `fetchModelServers`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.model - * Required. The model for which to list model servers. Open-source models - * follow the Huggingface Hub `owner/model_name` format. Use - * {@link protos.google.cloud.gkerecommender.v1.GkeInferenceQuickstart.FetchModels|GkeInferenceQuickstart.FetchModels} - * to find available models. - * @param {number} [request.pageSize] - * Optional. The target number of results to return in a single response. - * If not specified, a default value will be chosen by the service. - * Note that the response may include a partial list and a caller should - * only rely on the response's - * {@link protos.google.cloud.gkerecommender.v1.FetchModelServersResponse.next_page_token|next_page_token} - * to determine if there are more instances left to be queried. - * @param {string} [request.pageToken] - * Optional. The value of - * {@link protos.google.cloud.gkerecommender.v1.FetchModelServersResponse.next_page_token|next_page_token} - * received from a previous `FetchModelServersRequest` call. - * Provide this to retrieve the subsequent page in a multi-page list of - * results. When paginating, all other parameters provided to - * `FetchModelServersRequest` 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 - * string. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@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/gke_inference_quickstart.fetch_model_servers.js - * region_tag:gkerecommender_v1_generated_GkeInferenceQuickstart_FetchModelServers_async - */ + /** + * Equivalent to `fetchModelServers`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.model + * Required. The model for which to list model servers. Open-source models + * follow the Huggingface Hub `owner/model_name` format. Use + * {@link protos.google.cloud.gkerecommender.v1.GkeInferenceQuickstart.FetchModels|GkeInferenceQuickstart.FetchModels} + * to find available models. + * @param {number} [request.pageSize] + * Optional. The target number of results to return in a single response. + * If not specified, a default value will be chosen by the service. + * Note that the response may include a partial list and a caller should + * only rely on the response's + * {@link protos.google.cloud.gkerecommender.v1.FetchModelServersResponse.next_page_token|next_page_token} + * to determine if there are more instances left to be queried. + * @param {string} [request.pageToken] + * Optional. The value of + * {@link protos.google.cloud.gkerecommender.v1.FetchModelServersResponse.next_page_token|next_page_token} + * received from a previous `FetchModelServersRequest` call. + * Provide this to retrieve the subsequent page in a multi-page list of + * results. When paginating, all other parameters provided to + * `FetchModelServersRequest` 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 + * string. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@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/gke_inference_quickstart.fetch_model_servers.js + * region_tag:gkerecommender_v1_generated_GkeInferenceQuickstart_FetchModelServers_async + */ fetchModelServersAsync( - request?: protos.google.cloud.gkerecommender.v1.IFetchModelServersRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.gkerecommender.v1.IFetchModelServersRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; const defaultCallSettings = this._defaults['fetchModelServers']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('fetchModelServers iterate %j', request); return this.descriptors.page.fetchModelServers.asyncIterate( this.innerApiCalls['fetchModelServers'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Fetches available model server versions. Open-source servers use their own - * versioning schemas (e.g., `vllm` uses semver like `v1.0.0`). - * - * Some model servers have different versioning schemas depending on the - * accelerator. For example, `vllm` uses semver on GPUs, but returns nightly - * build tags on TPUs. All available versions will be returned when different - * schemas are present. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.model - * Required. The model for which to list model server versions. Open-source - * models follow the Huggingface Hub `owner/model_name` format. Use - * {@link protos.google.cloud.gkerecommender.v1.GkeInferenceQuickstart.FetchModels|GkeInferenceQuickstart.FetchModels} - * to find available models. - * @param {string} request.modelServer - * Required. The model server for which to list versions. Open-source model - * servers use simplified, lowercase names (e.g., `vllm`). Use - * {@link protos.google.cloud.gkerecommender.v1.GkeInferenceQuickstart.FetchModelServers|GkeInferenceQuickstart.FetchModelServers} - * to find available model servers. - * @param {number} [request.pageSize] - * Optional. The target number of results to return in a single response. - * If not specified, a default value will be chosen by the service. - * Note that the response may include a partial list and a caller should - * only rely on the response's - * {@link protos.google.cloud.gkerecommender.v1.FetchModelServerVersionsResponse.next_page_token|next_page_token} - * to determine if there are more instances left to be queried. - * @param {string} [request.pageToken] - * Optional. The value of - * {@link protos.google.cloud.gkerecommender.v1.FetchModelServerVersionsResponse.next_page_token|next_page_token} - * received from a previous `FetchModelServerVersionsRequest` call. - * Provide this to retrieve the subsequent page in a multi-page list of - * results. When paginating, all other parameters provided to - * `FetchModelServerVersionsRequest` 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 string. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `fetchModelServerVersionsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Fetches available model server versions. Open-source servers use their own + * versioning schemas (e.g., `vllm` uses semver like `v1.0.0`). + * + * Some model servers have different versioning schemas depending on the + * accelerator. For example, `vllm` uses semver on GPUs, but returns nightly + * build tags on TPUs. All available versions will be returned when different + * schemas are present. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.model + * Required. The model for which to list model server versions. Open-source + * models follow the Huggingface Hub `owner/model_name` format. Use + * {@link protos.google.cloud.gkerecommender.v1.GkeInferenceQuickstart.FetchModels|GkeInferenceQuickstart.FetchModels} + * to find available models. + * @param {string} request.modelServer + * Required. The model server for which to list versions. Open-source model + * servers use simplified, lowercase names (e.g., `vllm`). Use + * {@link protos.google.cloud.gkerecommender.v1.GkeInferenceQuickstart.FetchModelServers|GkeInferenceQuickstart.FetchModelServers} + * to find available model servers. + * @param {number} [request.pageSize] + * Optional. The target number of results to return in a single response. + * If not specified, a default value will be chosen by the service. + * Note that the response may include a partial list and a caller should + * only rely on the response's + * {@link protos.google.cloud.gkerecommender.v1.FetchModelServerVersionsResponse.next_page_token|next_page_token} + * to determine if there are more instances left to be queried. + * @param {string} [request.pageToken] + * Optional. The value of + * {@link protos.google.cloud.gkerecommender.v1.FetchModelServerVersionsResponse.next_page_token|next_page_token} + * received from a previous `FetchModelServerVersionsRequest` call. + * Provide this to retrieve the subsequent page in a multi-page list of + * results. When paginating, all other parameters provided to + * `FetchModelServerVersionsRequest` 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 string. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `fetchModelServerVersionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ fetchModelServerVersions( - request?: protos.google.cloud.gkerecommender.v1.IFetchModelServerVersionsRequest, - options?: CallOptions): - Promise<[ - string[], - protos.google.cloud.gkerecommender.v1.IFetchModelServerVersionsRequest|null, - protos.google.cloud.gkerecommender.v1.IFetchModelServerVersionsResponse - ]>; + request?: protos.google.cloud.gkerecommender.v1.IFetchModelServerVersionsRequest, + options?: CallOptions, + ): Promise< + [ + string[], + protos.google.cloud.gkerecommender.v1.IFetchModelServerVersionsRequest | null, + protos.google.cloud.gkerecommender.v1.IFetchModelServerVersionsResponse, + ] + >; fetchModelServerVersions( - request: protos.google.cloud.gkerecommender.v1.IFetchModelServerVersionsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.gkerecommender.v1.IFetchModelServerVersionsRequest, - protos.google.cloud.gkerecommender.v1.IFetchModelServerVersionsResponse|null|undefined, - string>): void; + request: protos.google.cloud.gkerecommender.v1.IFetchModelServerVersionsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.gkerecommender.v1.IFetchModelServerVersionsRequest, + | protos.google.cloud.gkerecommender.v1.IFetchModelServerVersionsResponse + | null + | undefined, + string + >, + ): void; fetchModelServerVersions( - request: protos.google.cloud.gkerecommender.v1.IFetchModelServerVersionsRequest, - callback: PaginationCallback< - protos.google.cloud.gkerecommender.v1.IFetchModelServerVersionsRequest, - protos.google.cloud.gkerecommender.v1.IFetchModelServerVersionsResponse|null|undefined, - string>): void; + request: protos.google.cloud.gkerecommender.v1.IFetchModelServerVersionsRequest, + callback: PaginationCallback< + protos.google.cloud.gkerecommender.v1.IFetchModelServerVersionsRequest, + | protos.google.cloud.gkerecommender.v1.IFetchModelServerVersionsResponse + | null + | undefined, + string + >, + ): void; fetchModelServerVersions( - request?: protos.google.cloud.gkerecommender.v1.IFetchModelServerVersionsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< + request?: protos.google.cloud.gkerecommender.v1.IFetchModelServerVersionsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.gkerecommender.v1.IFetchModelServerVersionsRequest, - protos.google.cloud.gkerecommender.v1.IFetchModelServerVersionsResponse|null|undefined, - string>, - callback?: PaginationCallback< - protos.google.cloud.gkerecommender.v1.IFetchModelServerVersionsRequest, - protos.google.cloud.gkerecommender.v1.IFetchModelServerVersionsResponse|null|undefined, - string>): - Promise<[ - string[], - protos.google.cloud.gkerecommender.v1.IFetchModelServerVersionsRequest|null, - protos.google.cloud.gkerecommender.v1.IFetchModelServerVersionsResponse - ]>|void { + | protos.google.cloud.gkerecommender.v1.IFetchModelServerVersionsResponse + | null + | undefined, + string + >, + callback?: PaginationCallback< + protos.google.cloud.gkerecommender.v1.IFetchModelServerVersionsRequest, + | protos.google.cloud.gkerecommender.v1.IFetchModelServerVersionsResponse + | null + | undefined, + string + >, + ): Promise< + [ + string[], + protos.google.cloud.gkerecommender.v1.IFetchModelServerVersionsRequest | null, + protos.google.cloud.gkerecommender.v1.IFetchModelServerVersionsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === '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.gkerecommender.v1.IFetchModelServerVersionsRequest, - protos.google.cloud.gkerecommender.v1.IFetchModelServerVersionsResponse|null|undefined, - string>|undefined = callback + this.initialize().catch((err) => { + throw err; + }); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.gkerecommender.v1.IFetchModelServerVersionsRequest, + | protos.google.cloud.gkerecommender.v1.IFetchModelServerVersionsResponse + | null + | undefined, + string + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('fetchModelServerVersions values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1079,251 +1332,283 @@ export class GkeInferenceQuickstartClient { this._log.info('fetchModelServerVersions request %j', request); return this.innerApiCalls .fetchModelServerVersions(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - string[], - protos.google.cloud.gkerecommender.v1.IFetchModelServerVersionsRequest|null, - protos.google.cloud.gkerecommender.v1.IFetchModelServerVersionsResponse - ]) => { - this._log.info('fetchModelServerVersions values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + string[], + protos.google.cloud.gkerecommender.v1.IFetchModelServerVersionsRequest | null, + protos.google.cloud.gkerecommender.v1.IFetchModelServerVersionsResponse, + ]) => { + this._log.info('fetchModelServerVersions values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `fetchModelServerVersions`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.model - * Required. The model for which to list model server versions. Open-source - * models follow the Huggingface Hub `owner/model_name` format. Use - * {@link protos.google.cloud.gkerecommender.v1.GkeInferenceQuickstart.FetchModels|GkeInferenceQuickstart.FetchModels} - * to find available models. - * @param {string} request.modelServer - * Required. The model server for which to list versions. Open-source model - * servers use simplified, lowercase names (e.g., `vllm`). Use - * {@link protos.google.cloud.gkerecommender.v1.GkeInferenceQuickstart.FetchModelServers|GkeInferenceQuickstart.FetchModelServers} - * to find available model servers. - * @param {number} [request.pageSize] - * Optional. The target number of results to return in a single response. - * If not specified, a default value will be chosen by the service. - * Note that the response may include a partial list and a caller should - * only rely on the response's - * {@link protos.google.cloud.gkerecommender.v1.FetchModelServerVersionsResponse.next_page_token|next_page_token} - * to determine if there are more instances left to be queried. - * @param {string} [request.pageToken] - * Optional. The value of - * {@link protos.google.cloud.gkerecommender.v1.FetchModelServerVersionsResponse.next_page_token|next_page_token} - * received from a previous `FetchModelServerVersionsRequest` call. - * Provide this to retrieve the subsequent page in a multi-page list of - * results. When paginating, all other parameters provided to - * `FetchModelServerVersionsRequest` 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 string on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `fetchModelServerVersionsAsync()` - * method described below for async iteration which you can stop as 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 `fetchModelServerVersions`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.model + * Required. The model for which to list model server versions. Open-source + * models follow the Huggingface Hub `owner/model_name` format. Use + * {@link protos.google.cloud.gkerecommender.v1.GkeInferenceQuickstart.FetchModels|GkeInferenceQuickstart.FetchModels} + * to find available models. + * @param {string} request.modelServer + * Required. The model server for which to list versions. Open-source model + * servers use simplified, lowercase names (e.g., `vllm`). Use + * {@link protos.google.cloud.gkerecommender.v1.GkeInferenceQuickstart.FetchModelServers|GkeInferenceQuickstart.FetchModelServers} + * to find available model servers. + * @param {number} [request.pageSize] + * Optional. The target number of results to return in a single response. + * If not specified, a default value will be chosen by the service. + * Note that the response may include a partial list and a caller should + * only rely on the response's + * {@link protos.google.cloud.gkerecommender.v1.FetchModelServerVersionsResponse.next_page_token|next_page_token} + * to determine if there are more instances left to be queried. + * @param {string} [request.pageToken] + * Optional. The value of + * {@link protos.google.cloud.gkerecommender.v1.FetchModelServerVersionsResponse.next_page_token|next_page_token} + * received from a previous `FetchModelServerVersionsRequest` call. + * Provide this to retrieve the subsequent page in a multi-page list of + * results. When paginating, all other parameters provided to + * `FetchModelServerVersionsRequest` 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 string on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `fetchModelServerVersionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ fetchModelServerVersionsStream( - request?: protos.google.cloud.gkerecommender.v1.IFetchModelServerVersionsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.gkerecommender.v1.IFetchModelServerVersionsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; const defaultCallSettings = this._defaults['fetchModelServerVersions']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('fetchModelServerVersions stream %j', request); return this.descriptors.page.fetchModelServerVersions.createStream( this.innerApiCalls.fetchModelServerVersions as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `fetchModelServerVersions`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.model - * Required. The model for which to list model server versions. Open-source - * models follow the Huggingface Hub `owner/model_name` format. Use - * {@link protos.google.cloud.gkerecommender.v1.GkeInferenceQuickstart.FetchModels|GkeInferenceQuickstart.FetchModels} - * to find available models. - * @param {string} request.modelServer - * Required. The model server for which to list versions. Open-source model - * servers use simplified, lowercase names (e.g., `vllm`). Use - * {@link protos.google.cloud.gkerecommender.v1.GkeInferenceQuickstart.FetchModelServers|GkeInferenceQuickstart.FetchModelServers} - * to find available model servers. - * @param {number} [request.pageSize] - * Optional. The target number of results to return in a single response. - * If not specified, a default value will be chosen by the service. - * Note that the response may include a partial list and a caller should - * only rely on the response's - * {@link protos.google.cloud.gkerecommender.v1.FetchModelServerVersionsResponse.next_page_token|next_page_token} - * to determine if there are more instances left to be queried. - * @param {string} [request.pageToken] - * Optional. The value of - * {@link protos.google.cloud.gkerecommender.v1.FetchModelServerVersionsResponse.next_page_token|next_page_token} - * received from a previous `FetchModelServerVersionsRequest` call. - * Provide this to retrieve the subsequent page in a multi-page list of - * results. When paginating, all other parameters provided to - * `FetchModelServerVersionsRequest` 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 - * string. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@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/gke_inference_quickstart.fetch_model_server_versions.js - * region_tag:gkerecommender_v1_generated_GkeInferenceQuickstart_FetchModelServerVersions_async - */ + /** + * Equivalent to `fetchModelServerVersions`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.model + * Required. The model for which to list model server versions. Open-source + * models follow the Huggingface Hub `owner/model_name` format. Use + * {@link protos.google.cloud.gkerecommender.v1.GkeInferenceQuickstart.FetchModels|GkeInferenceQuickstart.FetchModels} + * to find available models. + * @param {string} request.modelServer + * Required. The model server for which to list versions. Open-source model + * servers use simplified, lowercase names (e.g., `vllm`). Use + * {@link protos.google.cloud.gkerecommender.v1.GkeInferenceQuickstart.FetchModelServers|GkeInferenceQuickstart.FetchModelServers} + * to find available model servers. + * @param {number} [request.pageSize] + * Optional. The target number of results to return in a single response. + * If not specified, a default value will be chosen by the service. + * Note that the response may include a partial list and a caller should + * only rely on the response's + * {@link protos.google.cloud.gkerecommender.v1.FetchModelServerVersionsResponse.next_page_token|next_page_token} + * to determine if there are more instances left to be queried. + * @param {string} [request.pageToken] + * Optional. The value of + * {@link protos.google.cloud.gkerecommender.v1.FetchModelServerVersionsResponse.next_page_token|next_page_token} + * received from a previous `FetchModelServerVersionsRequest` call. + * Provide this to retrieve the subsequent page in a multi-page list of + * results. When paginating, all other parameters provided to + * `FetchModelServerVersionsRequest` 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 + * string. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@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/gke_inference_quickstart.fetch_model_server_versions.js + * region_tag:gkerecommender_v1_generated_GkeInferenceQuickstart_FetchModelServerVersions_async + */ fetchModelServerVersionsAsync( - request?: protos.google.cloud.gkerecommender.v1.IFetchModelServerVersionsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.gkerecommender.v1.IFetchModelServerVersionsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; const defaultCallSettings = this._defaults['fetchModelServerVersions']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('fetchModelServerVersions iterate %j', request); return this.descriptors.page.fetchModelServerVersions.asyncIterate( this.innerApiCalls['fetchModelServerVersions'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Fetches available profiles. A profile contains performance metrics and - * cost information for a specific model server setup. Profiles can be - * filtered by parameters. If no filters are provided, all profiles are - * returned. - * - * Profiles display a single value per performance metric based on the - * provided performance requirements. If no requirements are given, the - * metrics represent the inflection point. See [Run best practice inference - * with GKE Inference Quickstart - * recipes](https://cloud.google.com/kubernetes-engine/docs/how-to/machine-learning/inference/inference-quickstart#how) - * for details. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} [request.model] - * Optional. The model to filter profiles by. Open-source models follow the - * Huggingface Hub `owner/model_name` format. If not provided, all models are - * returned. Use - * {@link protos.google.cloud.gkerecommender.v1.GkeInferenceQuickstart.FetchModels|GkeInferenceQuickstart.FetchModels} - * to find available models. - * @param {string} [request.modelServer] - * Optional. The model server to filter profiles by. If not provided, all - * model servers are returned. Use - * {@link protos.google.cloud.gkerecommender.v1.GkeInferenceQuickstart.FetchModelServers|GkeInferenceQuickstart.FetchModelServers} - * to find available model servers for a given model. - * @param {string} [request.modelServerVersion] - * Optional. The model server version to filter profiles by. If not provided, - * all model server versions are returned. Use - * {@link protos.google.cloud.gkerecommender.v1.GkeInferenceQuickstart.FetchModelServerVersions|GkeInferenceQuickstart.FetchModelServerVersions} - * to find available versions for a given model and server. - * @param {google.cloud.gkerecommender.v1.PerformanceRequirements} [request.performanceRequirements] - * Optional. The performance requirements to filter profiles. Profiles that do - * not meet these requirements are filtered out. If not provided, all profiles - * are returned. - * @param {number} [request.pageSize] - * Optional. The target number of results to return in a single response. If - * not specified, a default value will be chosen by the service. Note that the - * response may include a partial list and a caller should only rely on the - * response's - * {@link protos.google.cloud.gkerecommender.v1.FetchProfilesResponse.next_page_token|next_page_token} - * to determine if there are more instances left to be queried. - * @param {string} [request.pageToken] - * Optional. The value of - * {@link protos.google.cloud.gkerecommender.v1.FetchProfilesResponse.next_page_token|next_page_token} - * received from a previous `FetchProfilesRequest` call. - * Provide this to retrieve the subsequent page in a multi-page list of - * results. When paginating, all other parameters provided to - * `FetchProfilesRequest` 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.gkerecommender.v1.Profile|Profile}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `fetchProfilesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Fetches available profiles. A profile contains performance metrics and + * cost information for a specific model server setup. Profiles can be + * filtered by parameters. If no filters are provided, all profiles are + * returned. + * + * Profiles display a single value per performance metric based on the + * provided performance requirements. If no requirements are given, the + * metrics represent the inflection point. See [Run best practice inference + * with GKE Inference Quickstart + * recipes](https://cloud.google.com/kubernetes-engine/docs/how-to/machine-learning/inference/inference-quickstart#how) + * for details. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} [request.model] + * Optional. The model to filter profiles by. Open-source models follow the + * Huggingface Hub `owner/model_name` format. If not provided, all models are + * returned. Use + * {@link protos.google.cloud.gkerecommender.v1.GkeInferenceQuickstart.FetchModels|GkeInferenceQuickstart.FetchModels} + * to find available models. + * @param {string} [request.modelServer] + * Optional. The model server to filter profiles by. If not provided, all + * model servers are returned. Use + * {@link protos.google.cloud.gkerecommender.v1.GkeInferenceQuickstart.FetchModelServers|GkeInferenceQuickstart.FetchModelServers} + * to find available model servers for a given model. + * @param {string} [request.modelServerVersion] + * Optional. The model server version to filter profiles by. If not provided, + * all model server versions are returned. Use + * {@link protos.google.cloud.gkerecommender.v1.GkeInferenceQuickstart.FetchModelServerVersions|GkeInferenceQuickstart.FetchModelServerVersions} + * to find available versions for a given model and server. + * @param {google.cloud.gkerecommender.v1.PerformanceRequirements} [request.performanceRequirements] + * Optional. The performance requirements to filter profiles. Profiles that do + * not meet these requirements are filtered out. If not provided, all profiles + * are returned. + * @param {number} [request.pageSize] + * Optional. The target number of results to return in a single response. If + * not specified, a default value will be chosen by the service. Note that the + * response may include a partial list and a caller should only rely on the + * response's + * {@link protos.google.cloud.gkerecommender.v1.FetchProfilesResponse.next_page_token|next_page_token} + * to determine if there are more instances left to be queried. + * @param {string} [request.pageToken] + * Optional. The value of + * {@link protos.google.cloud.gkerecommender.v1.FetchProfilesResponse.next_page_token|next_page_token} + * received from a previous `FetchProfilesRequest` call. + * Provide this to retrieve the subsequent page in a multi-page list of + * results. When paginating, all other parameters provided to + * `FetchProfilesRequest` 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.gkerecommender.v1.Profile|Profile}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `fetchProfilesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ fetchProfiles( - request?: protos.google.cloud.gkerecommender.v1.IFetchProfilesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gkerecommender.v1.IProfile[], - protos.google.cloud.gkerecommender.v1.IFetchProfilesRequest|null, - protos.google.cloud.gkerecommender.v1.IFetchProfilesResponse - ]>; + request?: protos.google.cloud.gkerecommender.v1.IFetchProfilesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gkerecommender.v1.IProfile[], + protos.google.cloud.gkerecommender.v1.IFetchProfilesRequest | null, + protos.google.cloud.gkerecommender.v1.IFetchProfilesResponse, + ] + >; fetchProfiles( - request: protos.google.cloud.gkerecommender.v1.IFetchProfilesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.gkerecommender.v1.IFetchProfilesRequest, - protos.google.cloud.gkerecommender.v1.IFetchProfilesResponse|null|undefined, - protos.google.cloud.gkerecommender.v1.IProfile>): void; + request: protos.google.cloud.gkerecommender.v1.IFetchProfilesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.gkerecommender.v1.IFetchProfilesRequest, + | protos.google.cloud.gkerecommender.v1.IFetchProfilesResponse + | null + | undefined, + protos.google.cloud.gkerecommender.v1.IProfile + >, + ): void; fetchProfiles( - request: protos.google.cloud.gkerecommender.v1.IFetchProfilesRequest, - callback: PaginationCallback< - protos.google.cloud.gkerecommender.v1.IFetchProfilesRequest, - protos.google.cloud.gkerecommender.v1.IFetchProfilesResponse|null|undefined, - protos.google.cloud.gkerecommender.v1.IProfile>): void; + request: protos.google.cloud.gkerecommender.v1.IFetchProfilesRequest, + callback: PaginationCallback< + protos.google.cloud.gkerecommender.v1.IFetchProfilesRequest, + | protos.google.cloud.gkerecommender.v1.IFetchProfilesResponse + | null + | undefined, + protos.google.cloud.gkerecommender.v1.IProfile + >, + ): void; fetchProfiles( - request?: protos.google.cloud.gkerecommender.v1.IFetchProfilesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< + request?: protos.google.cloud.gkerecommender.v1.IFetchProfilesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.gkerecommender.v1.IFetchProfilesRequest, - protos.google.cloud.gkerecommender.v1.IFetchProfilesResponse|null|undefined, - protos.google.cloud.gkerecommender.v1.IProfile>, - callback?: PaginationCallback< - protos.google.cloud.gkerecommender.v1.IFetchProfilesRequest, - protos.google.cloud.gkerecommender.v1.IFetchProfilesResponse|null|undefined, - protos.google.cloud.gkerecommender.v1.IProfile>): - Promise<[ - protos.google.cloud.gkerecommender.v1.IProfile[], - protos.google.cloud.gkerecommender.v1.IFetchProfilesRequest|null, - protos.google.cloud.gkerecommender.v1.IFetchProfilesResponse - ]>|void { + | protos.google.cloud.gkerecommender.v1.IFetchProfilesResponse + | null + | undefined, + protos.google.cloud.gkerecommender.v1.IProfile + >, + callback?: PaginationCallback< + protos.google.cloud.gkerecommender.v1.IFetchProfilesRequest, + | protos.google.cloud.gkerecommender.v1.IFetchProfilesResponse + | null + | undefined, + protos.google.cloud.gkerecommender.v1.IProfile + >, + ): Promise< + [ + protos.google.cloud.gkerecommender.v1.IProfile[], + protos.google.cloud.gkerecommender.v1.IFetchProfilesRequest | null, + protos.google.cloud.gkerecommender.v1.IFetchProfilesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === '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.gkerecommender.v1.IFetchProfilesRequest, - protos.google.cloud.gkerecommender.v1.IFetchProfilesResponse|null|undefined, - protos.google.cloud.gkerecommender.v1.IProfile>|undefined = callback + this.initialize().catch((err) => { + throw err; + }); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.gkerecommender.v1.IFetchProfilesRequest, + | protos.google.cloud.gkerecommender.v1.IFetchProfilesResponse + | null + | undefined, + protos.google.cloud.gkerecommender.v1.IProfile + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('fetchProfiles values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1332,154 +1617,160 @@ export class GkeInferenceQuickstartClient { this._log.info('fetchProfiles request %j', request); return this.innerApiCalls .fetchProfiles(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.gkerecommender.v1.IProfile[], - protos.google.cloud.gkerecommender.v1.IFetchProfilesRequest|null, - protos.google.cloud.gkerecommender.v1.IFetchProfilesResponse - ]) => { - this._log.info('fetchProfiles values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.gkerecommender.v1.IProfile[], + protos.google.cloud.gkerecommender.v1.IFetchProfilesRequest | null, + protos.google.cloud.gkerecommender.v1.IFetchProfilesResponse, + ]) => { + this._log.info('fetchProfiles values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `fetchProfiles`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} [request.model] - * Optional. The model to filter profiles by. Open-source models follow the - * Huggingface Hub `owner/model_name` format. If not provided, all models are - * returned. Use - * {@link protos.google.cloud.gkerecommender.v1.GkeInferenceQuickstart.FetchModels|GkeInferenceQuickstart.FetchModels} - * to find available models. - * @param {string} [request.modelServer] - * Optional. The model server to filter profiles by. If not provided, all - * model servers are returned. Use - * {@link protos.google.cloud.gkerecommender.v1.GkeInferenceQuickstart.FetchModelServers|GkeInferenceQuickstart.FetchModelServers} - * to find available model servers for a given model. - * @param {string} [request.modelServerVersion] - * Optional. The model server version to filter profiles by. If not provided, - * all model server versions are returned. Use - * {@link protos.google.cloud.gkerecommender.v1.GkeInferenceQuickstart.FetchModelServerVersions|GkeInferenceQuickstart.FetchModelServerVersions} - * to find available versions for a given model and server. - * @param {google.cloud.gkerecommender.v1.PerformanceRequirements} [request.performanceRequirements] - * Optional. The performance requirements to filter profiles. Profiles that do - * not meet these requirements are filtered out. If not provided, all profiles - * are returned. - * @param {number} [request.pageSize] - * Optional. The target number of results to return in a single response. If - * not specified, a default value will be chosen by the service. Note that the - * response may include a partial list and a caller should only rely on the - * response's - * {@link protos.google.cloud.gkerecommender.v1.FetchProfilesResponse.next_page_token|next_page_token} - * to determine if there are more instances left to be queried. - * @param {string} [request.pageToken] - * Optional. The value of - * {@link protos.google.cloud.gkerecommender.v1.FetchProfilesResponse.next_page_token|next_page_token} - * received from a previous `FetchProfilesRequest` call. - * Provide this to retrieve the subsequent page in a multi-page list of - * results. When paginating, all other parameters provided to - * `FetchProfilesRequest` 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.gkerecommender.v1.Profile|Profile} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `fetchProfilesAsync()` - * method described below for async iteration which you can stop as 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 `fetchProfiles`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} [request.model] + * Optional. The model to filter profiles by. Open-source models follow the + * Huggingface Hub `owner/model_name` format. If not provided, all models are + * returned. Use + * {@link protos.google.cloud.gkerecommender.v1.GkeInferenceQuickstart.FetchModels|GkeInferenceQuickstart.FetchModels} + * to find available models. + * @param {string} [request.modelServer] + * Optional. The model server to filter profiles by. If not provided, all + * model servers are returned. Use + * {@link protos.google.cloud.gkerecommender.v1.GkeInferenceQuickstart.FetchModelServers|GkeInferenceQuickstart.FetchModelServers} + * to find available model servers for a given model. + * @param {string} [request.modelServerVersion] + * Optional. The model server version to filter profiles by. If not provided, + * all model server versions are returned. Use + * {@link protos.google.cloud.gkerecommender.v1.GkeInferenceQuickstart.FetchModelServerVersions|GkeInferenceQuickstart.FetchModelServerVersions} + * to find available versions for a given model and server. + * @param {google.cloud.gkerecommender.v1.PerformanceRequirements} [request.performanceRequirements] + * Optional. The performance requirements to filter profiles. Profiles that do + * not meet these requirements are filtered out. If not provided, all profiles + * are returned. + * @param {number} [request.pageSize] + * Optional. The target number of results to return in a single response. If + * not specified, a default value will be chosen by the service. Note that the + * response may include a partial list and a caller should only rely on the + * response's + * {@link protos.google.cloud.gkerecommender.v1.FetchProfilesResponse.next_page_token|next_page_token} + * to determine if there are more instances left to be queried. + * @param {string} [request.pageToken] + * Optional. The value of + * {@link protos.google.cloud.gkerecommender.v1.FetchProfilesResponse.next_page_token|next_page_token} + * received from a previous `FetchProfilesRequest` call. + * Provide this to retrieve the subsequent page in a multi-page list of + * results. When paginating, all other parameters provided to + * `FetchProfilesRequest` 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.gkerecommender.v1.Profile|Profile} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `fetchProfilesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ fetchProfilesStream( - request?: protos.google.cloud.gkerecommender.v1.IFetchProfilesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.gkerecommender.v1.IFetchProfilesRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; const defaultCallSettings = this._defaults['fetchProfiles']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('fetchProfiles stream %j', request); return this.descriptors.page.fetchProfiles.createStream( this.innerApiCalls.fetchProfiles as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `fetchProfiles`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} [request.model] - * Optional. The model to filter profiles by. Open-source models follow the - * Huggingface Hub `owner/model_name` format. If not provided, all models are - * returned. Use - * {@link protos.google.cloud.gkerecommender.v1.GkeInferenceQuickstart.FetchModels|GkeInferenceQuickstart.FetchModels} - * to find available models. - * @param {string} [request.modelServer] - * Optional. The model server to filter profiles by. If not provided, all - * model servers are returned. Use - * {@link protos.google.cloud.gkerecommender.v1.GkeInferenceQuickstart.FetchModelServers|GkeInferenceQuickstart.FetchModelServers} - * to find available model servers for a given model. - * @param {string} [request.modelServerVersion] - * Optional. The model server version to filter profiles by. If not provided, - * all model server versions are returned. Use - * {@link protos.google.cloud.gkerecommender.v1.GkeInferenceQuickstart.FetchModelServerVersions|GkeInferenceQuickstart.FetchModelServerVersions} - * to find available versions for a given model and server. - * @param {google.cloud.gkerecommender.v1.PerformanceRequirements} [request.performanceRequirements] - * Optional. The performance requirements to filter profiles. Profiles that do - * not meet these requirements are filtered out. If not provided, all profiles - * are returned. - * @param {number} [request.pageSize] - * Optional. The target number of results to return in a single response. If - * not specified, a default value will be chosen by the service. Note that the - * response may include a partial list and a caller should only rely on the - * response's - * {@link protos.google.cloud.gkerecommender.v1.FetchProfilesResponse.next_page_token|next_page_token} - * to determine if there are more instances left to be queried. - * @param {string} [request.pageToken] - * Optional. The value of - * {@link protos.google.cloud.gkerecommender.v1.FetchProfilesResponse.next_page_token|next_page_token} - * received from a previous `FetchProfilesRequest` call. - * Provide this to retrieve the subsequent page in a multi-page list of - * results. When paginating, all other parameters provided to - * `FetchProfilesRequest` 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.gkerecommender.v1.Profile|Profile}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@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/gke_inference_quickstart.fetch_profiles.js - * region_tag:gkerecommender_v1_generated_GkeInferenceQuickstart_FetchProfiles_async - */ + /** + * Equivalent to `fetchProfiles`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} [request.model] + * Optional. The model to filter profiles by. Open-source models follow the + * Huggingface Hub `owner/model_name` format. If not provided, all models are + * returned. Use + * {@link protos.google.cloud.gkerecommender.v1.GkeInferenceQuickstart.FetchModels|GkeInferenceQuickstart.FetchModels} + * to find available models. + * @param {string} [request.modelServer] + * Optional. The model server to filter profiles by. If not provided, all + * model servers are returned. Use + * {@link protos.google.cloud.gkerecommender.v1.GkeInferenceQuickstart.FetchModelServers|GkeInferenceQuickstart.FetchModelServers} + * to find available model servers for a given model. + * @param {string} [request.modelServerVersion] + * Optional. The model server version to filter profiles by. If not provided, + * all model server versions are returned. Use + * {@link protos.google.cloud.gkerecommender.v1.GkeInferenceQuickstart.FetchModelServerVersions|GkeInferenceQuickstart.FetchModelServerVersions} + * to find available versions for a given model and server. + * @param {google.cloud.gkerecommender.v1.PerformanceRequirements} [request.performanceRequirements] + * Optional. The performance requirements to filter profiles. Profiles that do + * not meet these requirements are filtered out. If not provided, all profiles + * are returned. + * @param {number} [request.pageSize] + * Optional. The target number of results to return in a single response. If + * not specified, a default value will be chosen by the service. Note that the + * response may include a partial list and a caller should only rely on the + * response's + * {@link protos.google.cloud.gkerecommender.v1.FetchProfilesResponse.next_page_token|next_page_token} + * to determine if there are more instances left to be queried. + * @param {string} [request.pageToken] + * Optional. The value of + * {@link protos.google.cloud.gkerecommender.v1.FetchProfilesResponse.next_page_token|next_page_token} + * received from a previous `FetchProfilesRequest` call. + * Provide this to retrieve the subsequent page in a multi-page list of + * results. When paginating, all other parameters provided to + * `FetchProfilesRequest` 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.gkerecommender.v1.Profile|Profile}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@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/gke_inference_quickstart.fetch_profiles.js + * region_tag:gkerecommender_v1_generated_GkeInferenceQuickstart_FetchProfiles_async + */ fetchProfilesAsync( - request?: protos.google.cloud.gkerecommender.v1.IFetchProfilesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.gkerecommender.v1.IFetchProfilesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; const defaultCallSettings = this._defaults['fetchProfiles']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('fetchProfiles iterate %j', request); return this.descriptors.page.fetchProfiles.asyncIterate( this.innerApiCalls['fetchProfiles'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } @@ -1491,7 +1782,7 @@ export class GkeInferenceQuickstartClient { */ close(): Promise { if (this.gkeInferenceQuickstartStub && !this._terminated) { - return this.gkeInferenceQuickstartStub.then(stub => { + return this.gkeInferenceQuickstartStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); @@ -1499,4 +1790,4 @@ export class GkeInferenceQuickstartClient { } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-gkerecommender/src/v1/index.ts b/packages/google-cloud-gkerecommender/src/v1/index.ts index 31acf0067a4c..9861f315a352 100644 --- a/packages/google-cloud-gkerecommender/src/v1/index.ts +++ b/packages/google-cloud-gkerecommender/src/v1/index.ts @@ -16,4 +16,4 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {GkeInferenceQuickstartClient} from './gke_inference_quickstart_client'; +export { GkeInferenceQuickstartClient } from './gke_inference_quickstart_client'; diff --git a/packages/google-cloud-gkerecommender/system-test/fixtures/sample/src/index.ts b/packages/google-cloud-gkerecommender/system-test/fixtures/sample/src/index.ts index c63adc6a30f6..0e41bb474fce 100644 --- a/packages/google-cloud-gkerecommender/system-test/fixtures/sample/src/index.ts +++ b/packages/google-cloud-gkerecommender/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 {GkeInferenceQuickstartClient} from '@google-cloud/gkerecommender'; +import { GkeInferenceQuickstartClient } from '@google-cloud/gkerecommender'; // check that the client class type name can be used -function doStuffWithGkeInferenceQuickstartClient(client: GkeInferenceQuickstartClient) { +function doStuffWithGkeInferenceQuickstartClient( + client: GkeInferenceQuickstartClient, +) { client.close(); } diff --git a/packages/google-cloud-gkerecommender/system-test/install.ts b/packages/google-cloud-gkerecommender/system-test/install.ts index f66069aa3940..ccf167042d2e 100644 --- a/packages/google-cloud-gkerecommender/system-test/install.ts +++ b/packages/google-cloud-gkerecommender/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-gkerecommender/test/gapic_gke_inference_quickstart_v1.ts b/packages/google-cloud-gkerecommender/test/gapic_gke_inference_quickstart_v1.ts index a4376abc1e90..d5a1c8a3d0ca 100644 --- a/packages/google-cloud-gkerecommender/test/gapic_gke_inference_quickstart_v1.ts +++ b/packages/google-cloud-gkerecommender/test/gapic_gke_inference_quickstart_v1.ts @@ -19,1045 +19,1333 @@ 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 gkeinferencequickstartModule 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.GkeInferenceQuickstartClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'gkerecommender.googleapis.com'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = + new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'gkerecommender.googleapis.com'); + }); - it('has universeDomain', () => { - const client = new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); + it('has universeDomain', () => { + const client = + new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient(); + 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 = gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient.servicePath; - assert.strictEqual(servicePath, 'gkerecommender.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 = + gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient + .servicePath; + assert.strictEqual(servicePath, 'gkerecommender.googleapis.com'); + assert(stub.called); + stub.restore(); + }); - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'gkerecommender.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'gkerecommender.example.com'); + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient + .apiEndpoint; + assert.strictEqual(apiEndpoint, 'gkerecommender.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = + new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ + universeDomain: 'example.com', }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'gkerecommender.example.com'); + }); - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'gkerecommender.example.com'); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = + new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ + universe_domain: 'example.com', }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'gkerecommender.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 gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'gkerecommender.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 gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'gkerecommender.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 gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({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 gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'gkerecommender.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - it('has port', () => { - const port = gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient.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 gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual( + servicePath, + 'gkerecommender.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 gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient(); - assert(client); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('should create a client with gRPC fallback', () => { - const client = new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ - fallback: true, - }); - assert(client); + it('has port', () => { + const port = + gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = + new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = + new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ + fallback: true, }); + assert(client); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.gkeInferenceQuickstartStub, undefined); - await client.initialize(); - assert(client.gkeInferenceQuickstartStub); + it('has initialize method and supports deferred initialization', async () => { + const client = + new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + assert.strictEqual(client.gkeInferenceQuickstartStub, undefined); + await client.initialize(); + assert(client.gkeInferenceQuickstartStub); + }); - it('has close method for the initialized client', done => { - const client = new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.gkeInferenceQuickstartStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('has close method for the initialized client', (done) => { + const client = + new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.gkeInferenceQuickstartStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has close method for the non-initialized client', done => { - const client = new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.gkeInferenceQuickstartStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('has close method for the non-initialized client', (done) => { + const client = + new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + assert.strictEqual(client.gkeInferenceQuickstartStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; + }); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ - 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 gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ + 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 gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ - 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 gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ + 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('generateOptimizedManifest', () => { - it('invokes generateOptimizedManifest without error', async () => { - const client = new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkerecommender.v1.GenerateOptimizedManifestRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.gkerecommender.v1.GenerateOptimizedManifestResponse() - ); - client.innerApiCalls.generateOptimizedManifest = stubSimpleCall(expectedResponse); - const [response] = await client.generateOptimizedManifest(request); - assert.deepStrictEqual(response, expectedResponse); + describe('generateOptimizedManifest', () => { + it('invokes generateOptimizedManifest without error', async () => { + const client = + new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkerecommender.v1.GenerateOptimizedManifestRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.gkerecommender.v1.GenerateOptimizedManifestResponse(), + ); + client.innerApiCalls.generateOptimizedManifest = + stubSimpleCall(expectedResponse); + const [response] = await client.generateOptimizedManifest(request); + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes generateOptimizedManifest without error using callback', async () => { - const client = new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkerecommender.v1.GenerateOptimizedManifestRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.gkerecommender.v1.GenerateOptimizedManifestResponse() - ); - client.innerApiCalls.generateOptimizedManifest = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.generateOptimizedManifest( - request, - (err?: Error|null, result?: protos.google.cloud.gkerecommender.v1.IGenerateOptimizedManifestResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); + it('invokes generateOptimizedManifest without error using callback', async () => { + const client = + new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkerecommender.v1.GenerateOptimizedManifestRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.gkerecommender.v1.GenerateOptimizedManifestResponse(), + ); + client.innerApiCalls.generateOptimizedManifest = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.generateOptimizedManifest( + request, + ( + err?: Error | null, + result?: protos.google.cloud.gkerecommender.v1.IGenerateOptimizedManifestResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes generateOptimizedManifest with error', async () => { - const client = new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkerecommender.v1.GenerateOptimizedManifestRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.generateOptimizedManifest = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.generateOptimizedManifest(request), expectedError); + it('invokes generateOptimizedManifest with error', async () => { + const client = + new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkerecommender.v1.GenerateOptimizedManifestRequest(), + ); + const expectedError = new Error('expected'); + client.innerApiCalls.generateOptimizedManifest = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.generateOptimizedManifest(request), + expectedError, + ); + }); - it('invokes generateOptimizedManifest with closed client', async () => { - const client = new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkerecommender.v1.GenerateOptimizedManifestRequest() - ); - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.generateOptimizedManifest(request), expectedError); + it('invokes generateOptimizedManifest with closed client', async () => { + const client = + new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkerecommender.v1.GenerateOptimizedManifestRequest(), + ); + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.generateOptimizedManifest(request), + expectedError, + ); }); + }); - describe('fetchBenchmarkingData', () => { - it('invokes fetchBenchmarkingData without error', async () => { - const client = new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkerecommender.v1.FetchBenchmarkingDataRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.gkerecommender.v1.FetchBenchmarkingDataResponse() - ); - client.innerApiCalls.fetchBenchmarkingData = stubSimpleCall(expectedResponse); - const [response] = await client.fetchBenchmarkingData(request); - assert.deepStrictEqual(response, expectedResponse); + describe('fetchBenchmarkingData', () => { + it('invokes fetchBenchmarkingData without error', async () => { + const client = + new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkerecommender.v1.FetchBenchmarkingDataRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.gkerecommender.v1.FetchBenchmarkingDataResponse(), + ); + client.innerApiCalls.fetchBenchmarkingData = + stubSimpleCall(expectedResponse); + const [response] = await client.fetchBenchmarkingData(request); + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes fetchBenchmarkingData without error using callback', async () => { - const client = new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkerecommender.v1.FetchBenchmarkingDataRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.gkerecommender.v1.FetchBenchmarkingDataResponse() - ); - client.innerApiCalls.fetchBenchmarkingData = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.fetchBenchmarkingData( - request, - (err?: Error|null, result?: protos.google.cloud.gkerecommender.v1.IFetchBenchmarkingDataResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); + it('invokes fetchBenchmarkingData without error using callback', async () => { + const client = + new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkerecommender.v1.FetchBenchmarkingDataRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.gkerecommender.v1.FetchBenchmarkingDataResponse(), + ); + client.innerApiCalls.fetchBenchmarkingData = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.fetchBenchmarkingData( + request, + ( + err?: Error | null, + result?: protos.google.cloud.gkerecommender.v1.IFetchBenchmarkingDataResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes fetchBenchmarkingData with error', async () => { - const client = new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkerecommender.v1.FetchBenchmarkingDataRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.fetchBenchmarkingData = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.fetchBenchmarkingData(request), expectedError); + it('invokes fetchBenchmarkingData with error', async () => { + const client = + new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkerecommender.v1.FetchBenchmarkingDataRequest(), + ); + const expectedError = new Error('expected'); + client.innerApiCalls.fetchBenchmarkingData = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.fetchBenchmarkingData(request), + expectedError, + ); + }); - it('invokes fetchBenchmarkingData with closed client', async () => { - const client = new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkerecommender.v1.FetchBenchmarkingDataRequest() - ); - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.fetchBenchmarkingData(request), expectedError); + it('invokes fetchBenchmarkingData with closed client', async () => { + const client = + new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkerecommender.v1.FetchBenchmarkingDataRequest(), + ); + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.fetchBenchmarkingData(request), + expectedError, + ); }); + }); - describe('fetchModels', () => { - it('invokes fetchModels without error', async () => { - const client = new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkerecommender.v1.FetchModelsRequest() - );const expectedResponse = [new String(), new String(), new String()]; - client.innerApiCalls.fetchModels = stubSimpleCall(expectedResponse); - const [response] = await client.fetchModels(request); - assert.deepStrictEqual(response, expectedResponse); + describe('fetchModels', () => { + it('invokes fetchModels without error', async () => { + const client = + new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkerecommender.v1.FetchModelsRequest(), + ); + const expectedResponse = [new String(), new String(), new String()]; + client.innerApiCalls.fetchModels = stubSimpleCall(expectedResponse); + const [response] = await client.fetchModels(request); + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes fetchModels without error using callback', async () => { - const client = new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkerecommender.v1.FetchModelsRequest() - );const expectedResponse = [new String(), new String(), new String()]; - client.innerApiCalls.fetchModels = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.fetchModels( - request, - (err?: Error|null, result?: string[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); + it('invokes fetchModels without error using callback', async () => { + const client = + new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkerecommender.v1.FetchModelsRequest(), + ); + const expectedResponse = [new String(), new String(), new String()]; + client.innerApiCalls.fetchModels = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.fetchModels( + request, + (err?: Error | null, result?: string[] | null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes fetchModels with error', async () => { - const client = new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkerecommender.v1.FetchModelsRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.fetchModels = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.fetchModels(request), expectedError); + it('invokes fetchModels with error', async () => { + const client = + new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkerecommender.v1.FetchModelsRequest(), + ); + const expectedError = new Error('expected'); + client.innerApiCalls.fetchModels = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.fetchModels(request), expectedError); + }); - it('invokes fetchModelsStream without error', async () => { - const client = new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkerecommender.v1.FetchModelsRequest() - ); - const expectedResponse = [new String(), new String(), new String()]; - client.descriptors.page.fetchModels.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.fetchModelsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: string[] = []; - stream.on('data', (response: string) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.fetchModels.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.fetchModels, request)); + it('invokes fetchModelsStream without error', async () => { + const client = + new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkerecommender.v1.FetchModelsRequest(), + ); + const expectedResponse = [new String(), new String(), new String()]; + client.descriptors.page.fetchModels.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.fetchModelsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: string[] = []; + stream.on('data', (response: string) => { + responses.push(response); }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.fetchModels.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.fetchModels, request), + ); + }); - it('invokes fetchModelsStream with error', async () => { - const client = new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkerecommender.v1.FetchModelsRequest() - ); - const expectedError = new Error('expected'); - client.descriptors.page.fetchModels.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.fetchModelsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: string[] = []; - stream.on('data', (response: string) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.fetchModels.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.fetchModels, request)); + it('invokes fetchModelsStream with error', async () => { + const client = + new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkerecommender.v1.FetchModelsRequest(), + ); + const expectedError = new Error('expected'); + client.descriptors.page.fetchModels.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.fetchModelsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: string[] = []; + stream.on('data', (response: string) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.fetchModels.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.fetchModels, request), + ); + }); - it('uses async iteration with fetchModels without error', async () => { - const client = new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkerecommender.v1.FetchModelsRequest() - ); - const expectedResponse = [new String(), new String(), new String()]; - client.descriptors.page.fetchModels.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: string[] = []; - const iterable = client.fetchModelsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.fetchModels.asyncIterate as SinonStub) - .getCall(0).args[1], request); + it('uses async iteration with fetchModels without error', async () => { + const client = + new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkerecommender.v1.FetchModelsRequest(), + ); + const expectedResponse = [new String(), new String(), new String()]; + client.descriptors.page.fetchModels.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: string[] = []; + const iterable = client.fetchModelsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.fetchModels.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + }); - it('uses async iteration with fetchModels with error', async () => { - const client = new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkerecommender.v1.FetchModelsRequest() - ); - const expectedError = new Error('expected'); - client.descriptors.page.fetchModels.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.fetchModelsAsync(request); - await assert.rejects(async () => { - const responses: string[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.fetchModels.asyncIterate as SinonStub) - .getCall(0).args[1], request); + it('uses async iteration with fetchModels with error', async () => { + const client = + new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkerecommender.v1.FetchModelsRequest(), + ); + const expectedError = new Error('expected'); + client.descriptors.page.fetchModels.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError, + ); + const iterable = client.fetchModelsAsync(request); + await assert.rejects(async () => { + const responses: string[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.fetchModels.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); }); + }); - describe('fetchModelServers', () => { - it('invokes fetchModelServers without error', async () => { - const client = new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkerecommender.v1.FetchModelServersRequest() - );const expectedResponse = [new String(), new String(), new String()]; - client.innerApiCalls.fetchModelServers = stubSimpleCall(expectedResponse); - const [response] = await client.fetchModelServers(request); - assert.deepStrictEqual(response, expectedResponse); + describe('fetchModelServers', () => { + it('invokes fetchModelServers without error', async () => { + const client = + new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkerecommender.v1.FetchModelServersRequest(), + ); + const expectedResponse = [new String(), new String(), new String()]; + client.innerApiCalls.fetchModelServers = stubSimpleCall(expectedResponse); + const [response] = await client.fetchModelServers(request); + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes fetchModelServers without error using callback', async () => { - const client = new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkerecommender.v1.FetchModelServersRequest() - );const expectedResponse = [new String(), new String(), new String()]; - client.innerApiCalls.fetchModelServers = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.fetchModelServers( - request, - (err?: Error|null, result?: string[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); + it('invokes fetchModelServers without error using callback', async () => { + const client = + new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkerecommender.v1.FetchModelServersRequest(), + ); + const expectedResponse = [new String(), new String(), new String()]; + client.innerApiCalls.fetchModelServers = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.fetchModelServers( + request, + (err?: Error | null, result?: string[] | null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes fetchModelServers with error', async () => { - const client = new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkerecommender.v1.FetchModelServersRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.fetchModelServers = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.fetchModelServers(request), expectedError); + it('invokes fetchModelServers with error', async () => { + const client = + new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkerecommender.v1.FetchModelServersRequest(), + ); + const expectedError = new Error('expected'); + client.innerApiCalls.fetchModelServers = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.fetchModelServers(request), expectedError); + }); - it('invokes fetchModelServersStream without error', async () => { - const client = new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkerecommender.v1.FetchModelServersRequest() - ); - const expectedResponse = [new String(), new String(), new String()]; - client.descriptors.page.fetchModelServers.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.fetchModelServersStream(request); - const promise = new Promise((resolve, reject) => { - const responses: string[] = []; - stream.on('data', (response: string) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.fetchModelServers.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.fetchModelServers, request)); + it('invokes fetchModelServersStream without error', async () => { + const client = + new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkerecommender.v1.FetchModelServersRequest(), + ); + const expectedResponse = [new String(), new String(), new String()]; + client.descriptors.page.fetchModelServers.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.fetchModelServersStream(request); + const promise = new Promise((resolve, reject) => { + const responses: string[] = []; + stream.on('data', (response: string) => { + responses.push(response); }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.fetchModelServers.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.fetchModelServers, request), + ); + }); - it('invokes fetchModelServersStream with error', async () => { - const client = new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkerecommender.v1.FetchModelServersRequest() - ); - const expectedError = new Error('expected'); - client.descriptors.page.fetchModelServers.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.fetchModelServersStream(request); - const promise = new Promise((resolve, reject) => { - const responses: string[] = []; - stream.on('data', (response: string) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.fetchModelServers.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.fetchModelServers, request)); + it('invokes fetchModelServersStream with error', async () => { + const client = + new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkerecommender.v1.FetchModelServersRequest(), + ); + const expectedError = new Error('expected'); + client.descriptors.page.fetchModelServers.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.fetchModelServersStream(request); + const promise = new Promise((resolve, reject) => { + const responses: string[] = []; + stream.on('data', (response: string) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.fetchModelServers.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.fetchModelServers, request), + ); + }); - it('uses async iteration with fetchModelServers without error', async () => { - const client = new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkerecommender.v1.FetchModelServersRequest() - ); - const expectedResponse = [new String(), new String(), new String()]; - client.descriptors.page.fetchModelServers.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: string[] = []; - const iterable = client.fetchModelServersAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.fetchModelServers.asyncIterate as SinonStub) - .getCall(0).args[1], request); + it('uses async iteration with fetchModelServers without error', async () => { + const client = + new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkerecommender.v1.FetchModelServersRequest(), + ); + const expectedResponse = [new String(), new String(), new String()]; + client.descriptors.page.fetchModelServers.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: string[] = []; + const iterable = client.fetchModelServersAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.fetchModelServers.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); - it('uses async iteration with fetchModelServers with error', async () => { - const client = new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkerecommender.v1.FetchModelServersRequest() - ); - const expectedError = new Error('expected'); - client.descriptors.page.fetchModelServers.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.fetchModelServersAsync(request); - await assert.rejects(async () => { - const responses: string[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.fetchModelServers.asyncIterate as SinonStub) - .getCall(0).args[1], request); + it('uses async iteration with fetchModelServers with error', async () => { + const client = + new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkerecommender.v1.FetchModelServersRequest(), + ); + const expectedError = new Error('expected'); + client.descriptors.page.fetchModelServers.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.fetchModelServersAsync(request); + await assert.rejects(async () => { + const responses: string[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.fetchModelServers.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); }); + }); - describe('fetchModelServerVersions', () => { - it('invokes fetchModelServerVersions without error', async () => { - const client = new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkerecommender.v1.FetchModelServerVersionsRequest() - );const expectedResponse = [new String(), new String(), new String()]; - client.innerApiCalls.fetchModelServerVersions = stubSimpleCall(expectedResponse); - const [response] = await client.fetchModelServerVersions(request); - assert.deepStrictEqual(response, expectedResponse); + describe('fetchModelServerVersions', () => { + it('invokes fetchModelServerVersions without error', async () => { + const client = + new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkerecommender.v1.FetchModelServerVersionsRequest(), + ); + const expectedResponse = [new String(), new String(), new String()]; + client.innerApiCalls.fetchModelServerVersions = + stubSimpleCall(expectedResponse); + const [response] = await client.fetchModelServerVersions(request); + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes fetchModelServerVersions without error using callback', async () => { - const client = new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkerecommender.v1.FetchModelServerVersionsRequest() - );const expectedResponse = [new String(), new String(), new String()]; - client.innerApiCalls.fetchModelServerVersions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.fetchModelServerVersions( - request, - (err?: Error|null, result?: string[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); + it('invokes fetchModelServerVersions without error using callback', async () => { + const client = + new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkerecommender.v1.FetchModelServerVersionsRequest(), + ); + const expectedResponse = [new String(), new String(), new String()]; + client.innerApiCalls.fetchModelServerVersions = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.fetchModelServerVersions( + request, + (err?: Error | null, result?: string[] | null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes fetchModelServerVersions with error', async () => { - const client = new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkerecommender.v1.FetchModelServerVersionsRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.fetchModelServerVersions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.fetchModelServerVersions(request), expectedError); + it('invokes fetchModelServerVersions with error', async () => { + const client = + new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkerecommender.v1.FetchModelServerVersionsRequest(), + ); + const expectedError = new Error('expected'); + client.innerApiCalls.fetchModelServerVersions = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.fetchModelServerVersions(request), + expectedError, + ); + }); - it('invokes fetchModelServerVersionsStream without error', async () => { - const client = new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkerecommender.v1.FetchModelServerVersionsRequest() - ); - const expectedResponse = [new String(), new String(), new String()]; - client.descriptors.page.fetchModelServerVersions.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.fetchModelServerVersionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: string[] = []; - stream.on('data', (response: string) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.fetchModelServerVersions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.fetchModelServerVersions, request)); + it('invokes fetchModelServerVersionsStream without error', async () => { + const client = + new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkerecommender.v1.FetchModelServerVersionsRequest(), + ); + const expectedResponse = [new String(), new String(), new String()]; + client.descriptors.page.fetchModelServerVersions.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.fetchModelServerVersionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: string[] = []; + stream.on('data', (response: string) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + ( + client.descriptors.page.fetchModelServerVersions + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.fetchModelServerVersions, request), + ); + }); - it('invokes fetchModelServerVersionsStream with error', async () => { - const client = new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkerecommender.v1.FetchModelServerVersionsRequest() - ); - const expectedError = new Error('expected'); - client.descriptors.page.fetchModelServerVersions.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.fetchModelServerVersionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: string[] = []; - stream.on('data', (response: string) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.fetchModelServerVersions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.fetchModelServerVersions, request)); + it('invokes fetchModelServerVersionsStream with error', async () => { + const client = + new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkerecommender.v1.FetchModelServerVersionsRequest(), + ); + const expectedError = new Error('expected'); + client.descriptors.page.fetchModelServerVersions.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.fetchModelServerVersionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: string[] = []; + stream.on('data', (response: string) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + ( + client.descriptors.page.fetchModelServerVersions + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.fetchModelServerVersions, request), + ); + }); - it('uses async iteration with fetchModelServerVersions without error', async () => { - const client = new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkerecommender.v1.FetchModelServerVersionsRequest() - ); - const expectedResponse = [new String(), new String(), new String()]; - client.descriptors.page.fetchModelServerVersions.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: string[] = []; - const iterable = client.fetchModelServerVersionsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.fetchModelServerVersions.asyncIterate as SinonStub) - .getCall(0).args[1], request); + it('uses async iteration with fetchModelServerVersions without error', async () => { + const client = + new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkerecommender.v1.FetchModelServerVersionsRequest(), + ); + const expectedResponse = [new String(), new String(), new String()]; + client.descriptors.page.fetchModelServerVersions.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: string[] = []; + const iterable = client.fetchModelServerVersionsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.fetchModelServerVersions + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); - it('uses async iteration with fetchModelServerVersions with error', async () => { - const client = new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkerecommender.v1.FetchModelServerVersionsRequest() - ); - const expectedError = new Error('expected'); - client.descriptors.page.fetchModelServerVersions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.fetchModelServerVersionsAsync(request); - await assert.rejects(async () => { - const responses: string[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.fetchModelServerVersions.asyncIterate as SinonStub) - .getCall(0).args[1], request); + it('uses async iteration with fetchModelServerVersions with error', async () => { + const client = + new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkerecommender.v1.FetchModelServerVersionsRequest(), + ); + const expectedError = new Error('expected'); + client.descriptors.page.fetchModelServerVersions.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.fetchModelServerVersionsAsync(request); + await assert.rejects(async () => { + const responses: string[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.fetchModelServerVersions + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); }); + }); - describe('fetchProfiles', () => { - it('invokes fetchProfiles without error', async () => { - const client = new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkerecommender.v1.FetchProfilesRequest() - );const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkerecommender.v1.Profile()), - generateSampleMessage(new protos.google.cloud.gkerecommender.v1.Profile()), - generateSampleMessage(new protos.google.cloud.gkerecommender.v1.Profile()), - ]; - client.innerApiCalls.fetchProfiles = stubSimpleCall(expectedResponse); - const [response] = await client.fetchProfiles(request); - assert.deepStrictEqual(response, expectedResponse); + describe('fetchProfiles', () => { + it('invokes fetchProfiles without error', async () => { + const client = + new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkerecommender.v1.FetchProfilesRequest(), + ); + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.gkerecommender.v1.Profile(), + ), + generateSampleMessage( + new protos.google.cloud.gkerecommender.v1.Profile(), + ), + generateSampleMessage( + new protos.google.cloud.gkerecommender.v1.Profile(), + ), + ]; + client.innerApiCalls.fetchProfiles = stubSimpleCall(expectedResponse); + const [response] = await client.fetchProfiles(request); + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes fetchProfiles without error using callback', async () => { - const client = new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkerecommender.v1.FetchProfilesRequest() - );const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkerecommender.v1.Profile()), - generateSampleMessage(new protos.google.cloud.gkerecommender.v1.Profile()), - generateSampleMessage(new protos.google.cloud.gkerecommender.v1.Profile()), - ]; - client.innerApiCalls.fetchProfiles = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.fetchProfiles( - request, - (err?: Error|null, result?: protos.google.cloud.gkerecommender.v1.IProfile[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); + it('invokes fetchProfiles without error using callback', async () => { + const client = + new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkerecommender.v1.FetchProfilesRequest(), + ); + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.gkerecommender.v1.Profile(), + ), + generateSampleMessage( + new protos.google.cloud.gkerecommender.v1.Profile(), + ), + generateSampleMessage( + new protos.google.cloud.gkerecommender.v1.Profile(), + ), + ]; + client.innerApiCalls.fetchProfiles = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.fetchProfiles( + request, + ( + err?: Error | null, + result?: protos.google.cloud.gkerecommender.v1.IProfile[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes fetchProfiles with error', async () => { - const client = new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkerecommender.v1.FetchProfilesRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.fetchProfiles = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.fetchProfiles(request), expectedError); + it('invokes fetchProfiles with error', async () => { + const client = + new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkerecommender.v1.FetchProfilesRequest(), + ); + const expectedError = new Error('expected'); + client.innerApiCalls.fetchProfiles = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.fetchProfiles(request), expectedError); + }); - it('invokes fetchProfilesStream without error', async () => { - const client = new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkerecommender.v1.FetchProfilesRequest() - ); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkerecommender.v1.Profile()), - generateSampleMessage(new protos.google.cloud.gkerecommender.v1.Profile()), - generateSampleMessage(new protos.google.cloud.gkerecommender.v1.Profile()), - ]; - client.descriptors.page.fetchProfiles.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.fetchProfilesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.gkerecommender.v1.Profile[] = []; - stream.on('data', (response: protos.google.cloud.gkerecommender.v1.Profile) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.fetchProfiles.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.fetchProfiles, request)); + it('invokes fetchProfilesStream without error', async () => { + const client = + new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkerecommender.v1.FetchProfilesRequest(), + ); + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.gkerecommender.v1.Profile(), + ), + generateSampleMessage( + new protos.google.cloud.gkerecommender.v1.Profile(), + ), + generateSampleMessage( + new protos.google.cloud.gkerecommender.v1.Profile(), + ), + ]; + client.descriptors.page.fetchProfiles.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.fetchProfilesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.gkerecommender.v1.Profile[] = []; + stream.on( + 'data', + (response: protos.google.cloud.gkerecommender.v1.Profile) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.fetchProfiles.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.fetchProfiles, request), + ); + }); - it('invokes fetchProfilesStream with error', async () => { - const client = new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkerecommender.v1.FetchProfilesRequest() - ); - const expectedError = new Error('expected'); - client.descriptors.page.fetchProfiles.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.fetchProfilesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.gkerecommender.v1.Profile[] = []; - stream.on('data', (response: protos.google.cloud.gkerecommender.v1.Profile) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.fetchProfiles.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.fetchProfiles, request)); + it('invokes fetchProfilesStream with error', async () => { + const client = + new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkerecommender.v1.FetchProfilesRequest(), + ); + const expectedError = new Error('expected'); + client.descriptors.page.fetchProfiles.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.fetchProfilesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.gkerecommender.v1.Profile[] = []; + stream.on( + 'data', + (response: protos.google.cloud.gkerecommender.v1.Profile) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.fetchProfiles.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.fetchProfiles, request), + ); + }); - it('uses async iteration with fetchProfiles without error', async () => { - const client = new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkerecommender.v1.FetchProfilesRequest() - ); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gkerecommender.v1.Profile()), - generateSampleMessage(new protos.google.cloud.gkerecommender.v1.Profile()), - generateSampleMessage(new protos.google.cloud.gkerecommender.v1.Profile()), - ]; - client.descriptors.page.fetchProfiles.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.gkerecommender.v1.IProfile[] = []; - const iterable = client.fetchProfilesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.fetchProfiles.asyncIterate as SinonStub) - .getCall(0).args[1], request); + it('uses async iteration with fetchProfiles without error', async () => { + const client = + new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkerecommender.v1.FetchProfilesRequest(), + ); + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.gkerecommender.v1.Profile(), + ), + generateSampleMessage( + new protos.google.cloud.gkerecommender.v1.Profile(), + ), + generateSampleMessage( + new protos.google.cloud.gkerecommender.v1.Profile(), + ), + ]; + client.descriptors.page.fetchProfiles.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.gkerecommender.v1.IProfile[] = []; + const iterable = client.fetchProfilesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.fetchProfiles.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); - it('uses async iteration with fetchProfiles with error', async () => { - const client = new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gkerecommender.v1.FetchProfilesRequest() - ); - const expectedError = new Error('expected'); - client.descriptors.page.fetchProfiles.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.fetchProfilesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.gkerecommender.v1.IProfile[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.fetchProfiles.asyncIterate as SinonStub) - .getCall(0).args[1], request); + it('uses async iteration with fetchProfiles with error', async () => { + const client = + new gkeinferencequickstartModule.v1.GkeInferenceQuickstartClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gkerecommender.v1.FetchProfilesRequest(), + ); + const expectedError = new Error('expected'); + client.descriptors.page.fetchProfiles.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.fetchProfilesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.gkerecommender.v1.IProfile[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.fetchProfiles.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); }); + }); }); diff --git a/packages/google-cloud-gkerecommender/webpack.config.js b/packages/google-cloud-gkerecommender/webpack.config.js index 339c57a7fd76..ce3ed13533d4 100644 --- a/packages/google-cloud-gkerecommender/webpack.config.js +++ b/packages/google-cloud-gkerecommender/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-gsuiteaddons/.eslintignore b/packages/google-cloud-gsuiteaddons/.eslintignore new file mode 100644 index 000000000000..cfc348ec4d11 --- /dev/null +++ b/packages/google-cloud-gsuiteaddons/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/packages/google-cloud-gsuiteaddons/.eslintrc.json b/packages/google-cloud-gsuiteaddons/.eslintrc.json new file mode 100644 index 000000000000..3e8d97ccb390 --- /dev/null +++ b/packages/google-cloud-gsuiteaddons/.eslintrc.json @@ -0,0 +1,4 @@ +{ + "extends": "./node_modules/gts", + "root": true +} diff --git a/packages/google-cloud-gsuiteaddons/README.md b/packages/google-cloud-gsuiteaddons/README.md index a5137989db48..d158eaaa7155 100644 --- a/packages/google-cloud-gsuiteaddons/README.md +++ b/packages/google-cloud-gsuiteaddons/README.md @@ -101,7 +101,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-gsuiteaddons/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`) @@ -111,7 +111,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-gsuiteaddons/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-gsuiteaddons/protos/protos.d.ts b/packages/google-cloud-gsuiteaddons/protos/protos.d.ts index ec9189331dd4..dd5b4d1b5727 100644 --- a/packages/google-cloud-gsuiteaddons/protos/protos.d.ts +++ b/packages/google-cloud-gsuiteaddons/protos/protos.d.ts @@ -2914,6 +2914,9 @@ export namespace google { /** CommonLanguageSettings destinations */ destinations?: (google.api.ClientLibraryDestination[]|null); + + /** CommonLanguageSettings selectiveGapicGeneration */ + selectiveGapicGeneration?: (google.api.ISelectiveGapicGeneration|null); } /** Represents a CommonLanguageSettings. */ @@ -2931,6 +2934,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 @@ -3631,6 +3637,9 @@ export namespace google { /** PythonSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** PythonSettings experimentalFeatures */ + experimentalFeatures?: (google.api.PythonSettings.IExperimentalFeatures|null); } /** Represents a PythonSettings. */ @@ -3645,6 +3654,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 @@ -3723,6 +3735,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 { @@ -4049,6 +4173,9 @@ export namespace google { /** GoSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** GoSettings renamedServices */ + renamedServices?: ({ [k: string]: string }|null); } /** Represents a GoSettings. */ @@ -4063,6 +4190,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 @@ -4387,6 +4517,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, @@ -4755,6 +4988,7 @@ export namespace google { /** Edition enum. */ enum Edition { EDITION_UNKNOWN = 0, + EDITION_LEGACY = 900, EDITION_PROTO2 = 998, EDITION_PROTO3 = 999, EDITION_2023 = 1000, @@ -4785,6 +5019,9 @@ export namespace google { /** FileDescriptorProto weakDependency */ weakDependency?: (number[]|null); + /** FileDescriptorProto optionDependency */ + optionDependency?: (string[]|null); + /** FileDescriptorProto messageType */ messageType?: (google.protobuf.IDescriptorProto[]|null); @@ -4834,6 +5071,9 @@ export namespace google { /** FileDescriptorProto weakDependency. */ public weakDependency: number[]; + /** FileDescriptorProto optionDependency. */ + public optionDependency: string[]; + /** FileDescriptorProto messageType. */ public messageType: google.protobuf.IDescriptorProto[]; @@ -4968,6 +5208,9 @@ export namespace google { /** DescriptorProto reservedName */ reservedName?: (string[]|null); + + /** DescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents a DescriptorProto. */ @@ -5009,6 +5252,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 @@ -5856,6 +6102,9 @@ export namespace google { /** EnumDescriptorProto reservedName */ reservedName?: (string[]|null); + + /** EnumDescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents an EnumDescriptorProto. */ @@ -5882,6 +6131,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 @@ -6816,6 +7068,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); @@ -6871,6 +7126,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[]; @@ -7091,6 +7349,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. */ @@ -7329,6 +7702,9 @@ export namespace google { /** EnumValueOptions debugRedact */ debugRedact?: (boolean|null); + /** EnumValueOptions featureSupport */ + featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** EnumValueOptions uninterpretedOption */ uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); } @@ -7351,6 +7727,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[]; @@ -7940,6 +8319,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. */ @@ -7969,6 +8354,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 @@ -8091,6 +8482,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. */ @@ -8210,8 +8711,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. */ @@ -8226,8 +8730,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. @@ -8760,6 +9267,13 @@ export namespace google { } } + /** SymbolVisibility enum. */ + enum SymbolVisibility { + VISIBILITY_UNSET = 0, + VISIBILITY_LOCAL = 1, + VISIBILITY_EXPORT = 2 + } + /** Properties of a DoubleValue. */ interface IDoubleValue { diff --git a/packages/google-cloud-gsuiteaddons/protos/protos.js b/packages/google-cloud-gsuiteaddons/protos/protos.js index 44680ac51759..199923b4f41f 100644 --- a/packages/google-cloud-gsuiteaddons/protos/protos.js +++ b/packages/google-cloud-gsuiteaddons/protos/protos.js @@ -7133,6 +7133,7 @@ * @interface ICommonLanguageSettings * @property {string|null} [referenceDocsUri] CommonLanguageSettings referenceDocsUri * @property {Array.|null} [destinations] CommonLanguageSettings destinations + * @property {google.api.ISelectiveGapicGeneration|null} [selectiveGapicGeneration] CommonLanguageSettings selectiveGapicGeneration */ /** @@ -7167,6 +7168,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 @@ -7199,6 +7208,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; }; @@ -7250,6 +7261,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; @@ -7301,6 +7316,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; }; @@ -7343,6 +7363,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; }; @@ -7361,8 +7386,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) { @@ -7370,6 +7397,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; }; @@ -9192,6 +9221,7 @@ * @memberof google.api * @interface IPythonSettings * @property {google.api.ICommonLanguageSettings|null} [common] PythonSettings common + * @property {google.api.PythonSettings.IExperimentalFeatures|null} [experimentalFeatures] PythonSettings experimentalFeatures */ /** @@ -9217,6 +9247,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 @@ -9243,6 +9281,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; }; @@ -9283,6 +9323,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; @@ -9323,6 +9367,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; }; @@ -9343,6 +9392,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; }; @@ -9359,10 +9413,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; }; @@ -9392,6 +9450,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; })(); @@ -10268,6 +10578,7 @@ * @memberof google.api * @interface IGoSettings * @property {google.api.ICommonLanguageSettings|null} [common] GoSettings common + * @property {Object.|null} [renamedServices] GoSettings renamedServices */ /** @@ -10279,6 +10590,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) @@ -10293,6 +10605,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 @@ -10319,6 +10639,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; }; @@ -10349,7 +10672,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) @@ -10359,6 +10682,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; @@ -10399,6 +10745,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; }; @@ -10419,6 +10773,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; }; @@ -10435,10 +10796,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; }; @@ -11077,30 +11446,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; })(); api.ResourceDescriptor = (function() { @@ -12034,6 +12648,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 @@ -12048,6 +12663,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; @@ -12072,6 +12688,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 @@ -12094,6 +12711,7 @@ this.dependency = []; this.publicDependency = []; this.weakDependency = []; + this.optionDependency = []; this.messageType = []; this.enumType = []; this.service = []; @@ -12144,6 +12762,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 @@ -12265,6 +12891,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; }; @@ -12337,6 +12966,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 = []; @@ -12439,6 +13074,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"; @@ -12493,6 +13135,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -12545,6 +13188,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"); @@ -12608,6 +13258,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -12673,6 +13327,7 @@ object.extension = []; object.publicDependency = []; object.weakDependency = []; + object.optionDependency = []; } if (options.defaults) { object.name = ""; @@ -12729,6 +13384,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; }; @@ -12777,6 +13437,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 */ /** @@ -12882,6 +13543,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 @@ -12934,6 +13603,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; }; @@ -13026,6 +13697,10 @@ message.reservedName.push(reader.string()); break; } + case 11: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -13139,6 +13814,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; }; @@ -13238,6 +13922,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; }; @@ -13267,6 +13971,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; @@ -13312,6 +14017,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; }; @@ -15356,6 +16063,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 */ /** @@ -15416,6 +16124,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 @@ -15453,6 +16169,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; }; @@ -15515,6 +16233,10 @@ message.reservedName.push(reader.string()); break; } + case 6: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -15583,6 +16305,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; }; @@ -15632,6 +16363,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; }; @@ -15656,6 +16407,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; @@ -15676,6 +16428,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; }; @@ -17994,6 +18748,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 @@ -18114,6 +18869,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 @@ -18188,6 +18951,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(); @@ -18289,6 +19054,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 = []; @@ -18424,6 +19193,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"; @@ -18612,6 +19386,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"); @@ -18709,6 +19488,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")) @@ -18741,6 +19521,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) @@ -19013,6 +19795,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -19054,103 +19837,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; @@ -19745,6 +21014,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 */ @@ -19788,6 +21058,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 @@ -19826,6 +21104,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(); @@ -19877,6 +21157,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 = []; @@ -19929,6 +21213,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"; @@ -19962,6 +21251,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"); @@ -19994,6 +21288,7 @@ object.deprecated = false; object.features = null; object.debugRedact = false; + object.featureSupport = null; } if (message.deprecated != null && message.hasOwnProperty("deprecated")) object.deprecated = message.deprecated; @@ -20001,6 +21296,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) @@ -21440,6 +22737,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 */ /** @@ -21505,6 +22804,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 @@ -21541,6 +22856,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; }; @@ -21601,6 +22920,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; @@ -21691,6 +23018,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; }; @@ -21830,6 +23177,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; }; @@ -21853,6 +23248,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; @@ -21866,6 +23263,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; }; @@ -21993,6 +23394,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; })(); @@ -22177,6 +23791,7 @@ default: return "minimumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -22194,6 +23809,7 @@ default: return "maximumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -22242,6 +23858,10 @@ case 0: message.minimumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.minimumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.minimumEdition = 998; @@ -22294,6 +23914,10 @@ case 0: message.maximumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.maximumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.maximumEdition = 998; @@ -22402,7 +24026,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 */ /** @@ -22429,12 +24054,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. @@ -22460,10 +24093,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; }; @@ -22504,8 +24139,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: @@ -22548,6 +24187,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -22560,10 +24200,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; }; @@ -22591,6 +24236,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -22632,10 +24281,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; }; @@ -22654,13 +24308,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; }; @@ -23875,6 +25532,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.DoubleValue = (function() { /** diff --git a/packages/google-cloud-gsuiteaddons/protos/protos.json b/packages/google-cloud-gsuiteaddons/protos/protos.json index 1fdfdc4b814d..4cd80241f77b 100644 --- a/packages/google-cloud-gsuiteaddons/protos/protos.json +++ b/packages/google-cloud-gsuiteaddons/protos/protos.json @@ -513,8 +513,7 @@ "java_multiple_files": true, "java_outer_classname": "ResourceProto", "java_package": "com.google.api", - "objc_class_prefix": "GAPI", - "cc_enable_arenas": true + "objc_class_prefix": "GAPI" }, "nested": { "fieldBehavior": { @@ -660,6 +659,10 @@ "rule": "repeated", "type": "ClientLibraryDestination", "id": 2 + }, + "selectiveGapicGeneration": { + "type": "SelectiveGapicGeneration", + "id": 3 } } }, @@ -800,6 +803,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 + } + } } } }, @@ -857,6 +882,11 @@ "common": { "type": "CommonLanguageSettings", "id": 1 + }, + "renamedServices": { + "keyType": "string", + "type": "string", + "id": 2 } } }, @@ -918,6 +948,19 @@ "PACKAGE_MANAGER": 20 } }, + "SelectiveGapicGeneration": { + "fields": { + "methods": { + "rule": "repeated", + "type": "string", + "id": 1 + }, + "generateOmittedAsInternal": { + "type": "bool", + "id": 2 + } + } + }, "LaunchStage": { "values": { "LAUNCH_STAGE_UNSPECIFIED": 0, @@ -1028,12 +1071,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, @@ -1072,6 +1122,11 @@ "type": "int32", "id": 11 }, + "optionDependency": { + "rule": "repeated", + "type": "string", + "id": 15 + }, "messageType": { "rule": "repeated", "type": "DescriptorProto", @@ -1160,6 +1215,10 @@ "rule": "repeated", "type": "string", "id": 10 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 11 } }, "nested": { @@ -1385,6 +1444,10 @@ "rule": "repeated", "type": "string", "id": 5 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 6 } }, "nested": { @@ -1435,7 +1498,14 @@ "type": "ServiceOptions", "id": 3 } - } + }, + "reserved": [ + [ + 4, + 4 + ], + "stream" + ] }, "MethodDescriptorProto": { "edition": "proto2", @@ -1599,6 +1669,7 @@ 42, 42 ], + "php_generic_services", [ 38, 38 @@ -1734,7 +1805,8 @@ "type": "bool", "id": 10, "options": { - "default": false + "default": false, + "deprecated": true } }, "debugRedact": { @@ -1762,6 +1834,10 @@ "type": "FeatureSet", "id": 21 }, + "featureSupport": { + "type": "FeatureSupport", + "id": 22 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -1831,6 +1907,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 + } + } } } }, @@ -1919,6 +2015,10 @@ "default": false } }, + "featureSupport": { + "type": "FieldOptions.FeatureSupport", + "id": 4 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -2061,6 +2161,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_2023", "edition_defaults.value": "EXPLICIT" } @@ -2071,6 +2172,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "OPEN" } @@ -2081,6 +2183,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "PACKED" } @@ -2091,6 +2194,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "VERIFY" } @@ -2101,7 +2205,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" } }, @@ -2111,27 +2216,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, @@ -2176,7 +2292,13 @@ "UTF8_VALIDATION_UNKNOWN": 0, "VERIFY": 2, "NONE": 3 - } + }, + "reserved": [ + [ + 1, + 1 + ] + ] }, "MessageEncoding": { "values": { @@ -2191,6 +2313,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 + } + } + } } } }, @@ -2218,11 +2367,26 @@ "type": "Edition", "id": 3 }, - "features": { + "overridableFeatures": { "type": "FeatureSet", - "id": 2 + "id": 4 + }, + "fixedFeatures": { + "type": "FeatureSet", + "id": 5 } - } + }, + "reserved": [ + [ + 1, + 1 + ], + [ + 2, + 2 + ], + "features" + ] } } }, @@ -2235,6 +2399,12 @@ "id": 1 } }, + "extensions": [ + [ + 536000000, + 536000000 + ] + ], "nested": { "Location": { "fields": { @@ -2320,6 +2490,14 @@ } } }, + "SymbolVisibility": { + "edition": "proto2", + "values": { + "VISIBILITY_UNSET": 0, + "VISIBILITY_LOCAL": 1, + "VISIBILITY_EXPORT": 2 + } + }, "DoubleValue": { "fields": { "value": { diff --git a/packages/google-cloud-gsuiteaddons/samples/generated/v1/snippet_metadata_google.cloud.gsuiteaddons.v1.json b/packages/google-cloud-gsuiteaddons/samples/generated/v1/snippet_metadata_google.cloud.gsuiteaddons.v1.json index 5e8d5d13180f..027ba5bc6885 100644 --- a/packages/google-cloud-gsuiteaddons/samples/generated/v1/snippet_metadata_google.cloud.gsuiteaddons.v1.json +++ b/packages/google-cloud-gsuiteaddons/samples/generated/v1/snippet_metadata_google.cloud.gsuiteaddons.v1.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-gsuiteaddons", - "version": "2.2.1", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-gsuiteaddons/src/v1/g_suite_add_ons_client.ts b/packages/google-cloud-gsuiteaddons/src/v1/g_suite_add_ons_client.ts index aa28746e7ad5..ca9773fefed9 100644 --- a/packages/google-cloud-gsuiteaddons/src/v1/g_suite_add_ons_client.ts +++ b/packages/google-cloud-gsuiteaddons/src/v1/g_suite_add_ons_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 @@ -71,7 +78,7 @@ export class GSuiteAddOnsClient { 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('gsuiteaddons'); @@ -84,9 +91,9 @@ export class GSuiteAddOnsClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - gSuiteAddOnsStub?: Promise<{[name: string]: Function}>; + innerApiCalls: { [name: string]: Function }; + pathTemplates: { [name: string]: gax.PathTemplate }; + gSuiteAddOnsStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of GSuiteAddOnsClient. @@ -127,21 +134,42 @@ export class GSuiteAddOnsClient { * const client = new GSuiteAddOnsClient({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 GSuiteAddOnsClient; - 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 = 'gsuiteaddons.' + 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; @@ -166,7 +194,7 @@ export class GSuiteAddOnsClient { 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; @@ -180,10 +208,7 @@ export class GSuiteAddOnsClient { } // 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 { @@ -205,16 +230,16 @@ export class GSuiteAddOnsClient { // Create useful helper objects for these. this.pathTemplates = { authorizationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/authorization' + 'projects/{project}/authorization', ), deploymentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/deployments/{deployment}' + 'projects/{project}/deployments/{deployment}', ), installStatusPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/deployments/{deployment}/installStatus' + 'projects/{project}/deployments/{deployment}/installStatus', ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' + 'projects/{project}', ), }; @@ -222,14 +247,20 @@ export class GSuiteAddOnsClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listDeployments: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'deployments') + listDeployments: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'deployments', + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.gsuiteaddons.v1.GSuiteAddOns', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.gsuiteaddons.v1.GSuiteAddOns', + 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 @@ -260,37 +291,50 @@ export class GSuiteAddOnsClient { // Put together the "service stub" for // google.cloud.gsuiteaddons.v1.GSuiteAddOns. this.gSuiteAddOnsStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.gsuiteaddons.v1.GSuiteAddOns') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.gsuiteaddons.v1.GSuiteAddOns', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.gsuiteaddons.v1.GSuiteAddOns, - 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 gSuiteAddOnsStubMethods = - ['getAuthorization', 'createDeployment', 'replaceDeployment', 'getDeployment', 'listDeployments', 'deleteDeployment', 'installDeployment', 'uninstallDeployment', 'getInstallStatus']; + const gSuiteAddOnsStubMethods = [ + 'getAuthorization', + 'createDeployment', + 'replaceDeployment', + 'getDeployment', + 'listDeployments', + 'deleteDeployment', + 'installDeployment', + 'uninstallDeployment', + 'getInstallStatus', + ]; for (const methodName of gSuiteAddOnsStubMethods) { const callPromise = this.gSuiteAddOnsStub.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; @@ -305,8 +349,14 @@ export class GSuiteAddOnsClient { * @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 'gsuiteaddons.googleapis.com'; } @@ -317,8 +367,14 @@ export class GSuiteAddOnsClient { * @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 'gsuiteaddons.googleapis.com'; } @@ -349,9 +405,7 @@ export class GSuiteAddOnsClient { * @returns {string[]} List of default scopes. */ static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; + return ['https://www.googleapis.com/auth/cloud-platform']; } getProjectId(): Promise; @@ -360,8 +414,9 @@ export class GSuiteAddOnsClient { * Return the project ID used by this class. * @returns {Promise} A promise that resolves to string containing the project ID. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback, + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -372,876 +427,1248 @@ export class GSuiteAddOnsClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Gets the authorization information for deployments in a given project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the project for which to get the Google Workspace add-ons - * authorization information. - * - * Example: `projects/my_project/authorization`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.gsuiteaddons.v1.Authorization|Authorization}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/g_suite_add_ons.get_authorization.js - * region_tag:gsuiteaddons_v1_generated_GSuiteAddOns_GetAuthorization_async - */ + /** + * Gets the authorization information for deployments in a given project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the project for which to get the Google Workspace add-ons + * authorization information. + * + * Example: `projects/my_project/authorization`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.gsuiteaddons.v1.Authorization|Authorization}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/g_suite_add_ons.get_authorization.js + * region_tag:gsuiteaddons_v1_generated_GSuiteAddOns_GetAuthorization_async + */ getAuthorization( - request?: protos.google.cloud.gsuiteaddons.v1.IGetAuthorizationRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gsuiteaddons.v1.IAuthorization, - protos.google.cloud.gsuiteaddons.v1.IGetAuthorizationRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gsuiteaddons.v1.IGetAuthorizationRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gsuiteaddons.v1.IAuthorization, + protos.google.cloud.gsuiteaddons.v1.IGetAuthorizationRequest | undefined, + {} | undefined, + ] + >; getAuthorization( - request: protos.google.cloud.gsuiteaddons.v1.IGetAuthorizationRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.gsuiteaddons.v1.IAuthorization, - protos.google.cloud.gsuiteaddons.v1.IGetAuthorizationRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gsuiteaddons.v1.IGetAuthorizationRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.gsuiteaddons.v1.IAuthorization, + | protos.google.cloud.gsuiteaddons.v1.IGetAuthorizationRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getAuthorization( - request: protos.google.cloud.gsuiteaddons.v1.IGetAuthorizationRequest, - callback: Callback< - protos.google.cloud.gsuiteaddons.v1.IAuthorization, - protos.google.cloud.gsuiteaddons.v1.IGetAuthorizationRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gsuiteaddons.v1.IGetAuthorizationRequest, + callback: Callback< + protos.google.cloud.gsuiteaddons.v1.IAuthorization, + | protos.google.cloud.gsuiteaddons.v1.IGetAuthorizationRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getAuthorization( - request?: protos.google.cloud.gsuiteaddons.v1.IGetAuthorizationRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.gsuiteaddons.v1.IAuthorization, - protos.google.cloud.gsuiteaddons.v1.IGetAuthorizationRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.gsuiteaddons.v1.IGetAuthorizationRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.gsuiteaddons.v1.IAuthorization, - protos.google.cloud.gsuiteaddons.v1.IGetAuthorizationRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.gsuiteaddons.v1.IAuthorization, - protos.google.cloud.gsuiteaddons.v1.IGetAuthorizationRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.gsuiteaddons.v1.IGetAuthorizationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.gsuiteaddons.v1.IAuthorization, + | protos.google.cloud.gsuiteaddons.v1.IGetAuthorizationRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.gsuiteaddons.v1.IAuthorization, + protos.google.cloud.gsuiteaddons.v1.IGetAuthorizationRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getAuthorization request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.gsuiteaddons.v1.IAuthorization, - protos.google.cloud.gsuiteaddons.v1.IGetAuthorizationRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.gsuiteaddons.v1.IAuthorization, + | protos.google.cloud.gsuiteaddons.v1.IGetAuthorizationRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getAuthorization response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getAuthorization(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.gsuiteaddons.v1.IAuthorization, - protos.google.cloud.gsuiteaddons.v1.IGetAuthorizationRequest|undefined, - {}|undefined - ]) => { - this._log.info('getAuthorization response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getAuthorization(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.gsuiteaddons.v1.IAuthorization, + ( + | protos.google.cloud.gsuiteaddons.v1.IGetAuthorizationRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getAuthorization response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 deployment with the specified name and configuration. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Name of the project in which to create the deployment. - * - * Example: `projects/my_project`. - * @param {string} request.deploymentId - * Required. The id to use for this deployment. The full name of the created - * resource will be `projects//deployments/`. - * @param {google.cloud.gsuiteaddons.v1.Deployment} request.deployment - * Required. The deployment to create (deployment.name cannot be 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.gsuiteaddons.v1.Deployment|Deployment}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/g_suite_add_ons.create_deployment.js - * region_tag:gsuiteaddons_v1_generated_GSuiteAddOns_CreateDeployment_async - */ + /** + * Creates a deployment with the specified name and configuration. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Name of the project in which to create the deployment. + * + * Example: `projects/my_project`. + * @param {string} request.deploymentId + * Required. The id to use for this deployment. The full name of the created + * resource will be `projects//deployments/`. + * @param {google.cloud.gsuiteaddons.v1.Deployment} request.deployment + * Required. The deployment to create (deployment.name cannot be 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.gsuiteaddons.v1.Deployment|Deployment}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/g_suite_add_ons.create_deployment.js + * region_tag:gsuiteaddons_v1_generated_GSuiteAddOns_CreateDeployment_async + */ createDeployment( - request?: protos.google.cloud.gsuiteaddons.v1.ICreateDeploymentRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gsuiteaddons.v1.IDeployment, - protos.google.cloud.gsuiteaddons.v1.ICreateDeploymentRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gsuiteaddons.v1.ICreateDeploymentRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gsuiteaddons.v1.IDeployment, + protos.google.cloud.gsuiteaddons.v1.ICreateDeploymentRequest | undefined, + {} | undefined, + ] + >; createDeployment( - request: protos.google.cloud.gsuiteaddons.v1.ICreateDeploymentRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.gsuiteaddons.v1.IDeployment, - protos.google.cloud.gsuiteaddons.v1.ICreateDeploymentRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gsuiteaddons.v1.ICreateDeploymentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.gsuiteaddons.v1.IDeployment, + | protos.google.cloud.gsuiteaddons.v1.ICreateDeploymentRequest + | null + | undefined, + {} | null | undefined + >, + ): void; createDeployment( - request: protos.google.cloud.gsuiteaddons.v1.ICreateDeploymentRequest, - callback: Callback< - protos.google.cloud.gsuiteaddons.v1.IDeployment, - protos.google.cloud.gsuiteaddons.v1.ICreateDeploymentRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gsuiteaddons.v1.ICreateDeploymentRequest, + callback: Callback< + protos.google.cloud.gsuiteaddons.v1.IDeployment, + | protos.google.cloud.gsuiteaddons.v1.ICreateDeploymentRequest + | null + | undefined, + {} | null | undefined + >, + ): void; createDeployment( - request?: protos.google.cloud.gsuiteaddons.v1.ICreateDeploymentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.gsuiteaddons.v1.IDeployment, - protos.google.cloud.gsuiteaddons.v1.ICreateDeploymentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.gsuiteaddons.v1.ICreateDeploymentRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.gsuiteaddons.v1.IDeployment, - protos.google.cloud.gsuiteaddons.v1.ICreateDeploymentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.gsuiteaddons.v1.IDeployment, - protos.google.cloud.gsuiteaddons.v1.ICreateDeploymentRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.gsuiteaddons.v1.ICreateDeploymentRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.gsuiteaddons.v1.IDeployment, + | protos.google.cloud.gsuiteaddons.v1.ICreateDeploymentRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.gsuiteaddons.v1.IDeployment, + protos.google.cloud.gsuiteaddons.v1.ICreateDeploymentRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.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('createDeployment request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.gsuiteaddons.v1.IDeployment, - protos.google.cloud.gsuiteaddons.v1.ICreateDeploymentRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.gsuiteaddons.v1.IDeployment, + | protos.google.cloud.gsuiteaddons.v1.ICreateDeploymentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('createDeployment response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.createDeployment(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.gsuiteaddons.v1.IDeployment, - protos.google.cloud.gsuiteaddons.v1.ICreateDeploymentRequest|undefined, - {}|undefined - ]) => { - this._log.info('createDeployment response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .createDeployment(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.gsuiteaddons.v1.IDeployment, + ( + | protos.google.cloud.gsuiteaddons.v1.ICreateDeploymentRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('createDeployment response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 or replaces a deployment with the specified name. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.gsuiteaddons.v1.Deployment} request.deployment - * Required. The deployment to create or replace. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.gsuiteaddons.v1.Deployment|Deployment}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/g_suite_add_ons.replace_deployment.js - * region_tag:gsuiteaddons_v1_generated_GSuiteAddOns_ReplaceDeployment_async - */ + /** + * Creates or replaces a deployment with the specified name. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.gsuiteaddons.v1.Deployment} request.deployment + * Required. The deployment to create or replace. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.gsuiteaddons.v1.Deployment|Deployment}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/g_suite_add_ons.replace_deployment.js + * region_tag:gsuiteaddons_v1_generated_GSuiteAddOns_ReplaceDeployment_async + */ replaceDeployment( - request?: protos.google.cloud.gsuiteaddons.v1.IReplaceDeploymentRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gsuiteaddons.v1.IDeployment, - protos.google.cloud.gsuiteaddons.v1.IReplaceDeploymentRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gsuiteaddons.v1.IReplaceDeploymentRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gsuiteaddons.v1.IDeployment, + protos.google.cloud.gsuiteaddons.v1.IReplaceDeploymentRequest | undefined, + {} | undefined, + ] + >; replaceDeployment( - request: protos.google.cloud.gsuiteaddons.v1.IReplaceDeploymentRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.gsuiteaddons.v1.IDeployment, - protos.google.cloud.gsuiteaddons.v1.IReplaceDeploymentRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gsuiteaddons.v1.IReplaceDeploymentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.gsuiteaddons.v1.IDeployment, + | protos.google.cloud.gsuiteaddons.v1.IReplaceDeploymentRequest + | null + | undefined, + {} | null | undefined + >, + ): void; replaceDeployment( - request: protos.google.cloud.gsuiteaddons.v1.IReplaceDeploymentRequest, - callback: Callback< - protos.google.cloud.gsuiteaddons.v1.IDeployment, - protos.google.cloud.gsuiteaddons.v1.IReplaceDeploymentRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gsuiteaddons.v1.IReplaceDeploymentRequest, + callback: Callback< + protos.google.cloud.gsuiteaddons.v1.IDeployment, + | protos.google.cloud.gsuiteaddons.v1.IReplaceDeploymentRequest + | null + | undefined, + {} | null | undefined + >, + ): void; replaceDeployment( - request?: protos.google.cloud.gsuiteaddons.v1.IReplaceDeploymentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.gsuiteaddons.v1.IDeployment, - protos.google.cloud.gsuiteaddons.v1.IReplaceDeploymentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.gsuiteaddons.v1.IReplaceDeploymentRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.gsuiteaddons.v1.IDeployment, - protos.google.cloud.gsuiteaddons.v1.IReplaceDeploymentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.gsuiteaddons.v1.IDeployment, - protos.google.cloud.gsuiteaddons.v1.IReplaceDeploymentRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.gsuiteaddons.v1.IReplaceDeploymentRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.gsuiteaddons.v1.IDeployment, + | protos.google.cloud.gsuiteaddons.v1.IReplaceDeploymentRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.gsuiteaddons.v1.IDeployment, + protos.google.cloud.gsuiteaddons.v1.IReplaceDeploymentRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'deployment.name': request.deployment!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'deployment.name': request.deployment!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('replaceDeployment request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.gsuiteaddons.v1.IDeployment, - protos.google.cloud.gsuiteaddons.v1.IReplaceDeploymentRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.gsuiteaddons.v1.IDeployment, + | protos.google.cloud.gsuiteaddons.v1.IReplaceDeploymentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('replaceDeployment response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.replaceDeployment(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.gsuiteaddons.v1.IDeployment, - protos.google.cloud.gsuiteaddons.v1.IReplaceDeploymentRequest|undefined, - {}|undefined - ]) => { - this._log.info('replaceDeployment response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .replaceDeployment(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.gsuiteaddons.v1.IDeployment, + ( + | protos.google.cloud.gsuiteaddons.v1.IReplaceDeploymentRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('replaceDeployment response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 deployment with the specified name. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The full resource name of the deployment to get. - * - * Example: `projects/my_project/deployments/my_deployment`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.gsuiteaddons.v1.Deployment|Deployment}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/g_suite_add_ons.get_deployment.js - * region_tag:gsuiteaddons_v1_generated_GSuiteAddOns_GetDeployment_async - */ + /** + * Gets the deployment with the specified name. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The full resource name of the deployment to get. + * + * Example: `projects/my_project/deployments/my_deployment`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.gsuiteaddons.v1.Deployment|Deployment}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/g_suite_add_ons.get_deployment.js + * region_tag:gsuiteaddons_v1_generated_GSuiteAddOns_GetDeployment_async + */ getDeployment( - request?: protos.google.cloud.gsuiteaddons.v1.IGetDeploymentRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gsuiteaddons.v1.IDeployment, - protos.google.cloud.gsuiteaddons.v1.IGetDeploymentRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gsuiteaddons.v1.IGetDeploymentRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gsuiteaddons.v1.IDeployment, + protos.google.cloud.gsuiteaddons.v1.IGetDeploymentRequest | undefined, + {} | undefined, + ] + >; getDeployment( - request: protos.google.cloud.gsuiteaddons.v1.IGetDeploymentRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.gsuiteaddons.v1.IDeployment, - protos.google.cloud.gsuiteaddons.v1.IGetDeploymentRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gsuiteaddons.v1.IGetDeploymentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.gsuiteaddons.v1.IDeployment, + | protos.google.cloud.gsuiteaddons.v1.IGetDeploymentRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getDeployment( - request: protos.google.cloud.gsuiteaddons.v1.IGetDeploymentRequest, - callback: Callback< - protos.google.cloud.gsuiteaddons.v1.IDeployment, - protos.google.cloud.gsuiteaddons.v1.IGetDeploymentRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gsuiteaddons.v1.IGetDeploymentRequest, + callback: Callback< + protos.google.cloud.gsuiteaddons.v1.IDeployment, + | protos.google.cloud.gsuiteaddons.v1.IGetDeploymentRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getDeployment( - request?: protos.google.cloud.gsuiteaddons.v1.IGetDeploymentRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.gsuiteaddons.v1.IGetDeploymentRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.gsuiteaddons.v1.IDeployment, - protos.google.cloud.gsuiteaddons.v1.IGetDeploymentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.gsuiteaddons.v1.IDeployment, - protos.google.cloud.gsuiteaddons.v1.IGetDeploymentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.gsuiteaddons.v1.IDeployment, - protos.google.cloud.gsuiteaddons.v1.IGetDeploymentRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.gsuiteaddons.v1.IGetDeploymentRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.gsuiteaddons.v1.IDeployment, + | protos.google.cloud.gsuiteaddons.v1.IGetDeploymentRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.gsuiteaddons.v1.IDeployment, + protos.google.cloud.gsuiteaddons.v1.IGetDeploymentRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getDeployment request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.gsuiteaddons.v1.IDeployment, - protos.google.cloud.gsuiteaddons.v1.IGetDeploymentRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.gsuiteaddons.v1.IDeployment, + | protos.google.cloud.gsuiteaddons.v1.IGetDeploymentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getDeployment response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getDeployment(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.gsuiteaddons.v1.IDeployment, - protos.google.cloud.gsuiteaddons.v1.IGetDeploymentRequest|undefined, - {}|undefined - ]) => { - this._log.info('getDeployment response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getDeployment(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.gsuiteaddons.v1.IDeployment, + protos.google.cloud.gsuiteaddons.v1.IGetDeploymentRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getDeployment response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 deployment with the given name. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The full resource name of the deployment to delete. - * - * Example: `projects/my_project/deployments/my_deployment`. - * @param {string} request.etag - * The etag of the deployment to delete. - * If this is provided, it must match the server's 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.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/g_suite_add_ons.delete_deployment.js - * region_tag:gsuiteaddons_v1_generated_GSuiteAddOns_DeleteDeployment_async - */ + /** + * Deletes the deployment with the given name. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The full resource name of the deployment to delete. + * + * Example: `projects/my_project/deployments/my_deployment`. + * @param {string} request.etag + * The etag of the deployment to delete. + * If this is provided, it must match the server's 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.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/g_suite_add_ons.delete_deployment.js + * region_tag:gsuiteaddons_v1_generated_GSuiteAddOns_DeleteDeployment_async + */ deleteDeployment( - request?: protos.google.cloud.gsuiteaddons.v1.IDeleteDeploymentRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.gsuiteaddons.v1.IDeleteDeploymentRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gsuiteaddons.v1.IDeleteDeploymentRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.gsuiteaddons.v1.IDeleteDeploymentRequest | undefined, + {} | undefined, + ] + >; deleteDeployment( - request: protos.google.cloud.gsuiteaddons.v1.IDeleteDeploymentRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.gsuiteaddons.v1.IDeleteDeploymentRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gsuiteaddons.v1.IDeleteDeploymentRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.gsuiteaddons.v1.IDeleteDeploymentRequest + | null + | undefined, + {} | null | undefined + >, + ): void; deleteDeployment( - request: protos.google.cloud.gsuiteaddons.v1.IDeleteDeploymentRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.gsuiteaddons.v1.IDeleteDeploymentRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gsuiteaddons.v1.IDeleteDeploymentRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.gsuiteaddons.v1.IDeleteDeploymentRequest + | null + | undefined, + {} | null | undefined + >, + ): void; deleteDeployment( - request?: protos.google.cloud.gsuiteaddons.v1.IDeleteDeploymentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.gsuiteaddons.v1.IDeleteDeploymentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.gsuiteaddons.v1.IDeleteDeploymentRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.protobuf.IEmpty, - protos.google.cloud.gsuiteaddons.v1.IDeleteDeploymentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.gsuiteaddons.v1.IDeleteDeploymentRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.gsuiteaddons.v1.IDeleteDeploymentRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.gsuiteaddons.v1.IDeleteDeploymentRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.gsuiteaddons.v1.IDeleteDeploymentRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('deleteDeployment request %j', request); - const wrappedCallback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.gsuiteaddons.v1.IDeleteDeploymentRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.gsuiteaddons.v1.IDeleteDeploymentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('deleteDeployment response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.deleteDeployment(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.protobuf.IEmpty, - protos.google.cloud.gsuiteaddons.v1.IDeleteDeploymentRequest|undefined, - {}|undefined - ]) => { - this._log.info('deleteDeployment response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .deleteDeployment(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.gsuiteaddons.v1.IDeleteDeploymentRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('deleteDeployment response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Installs a deployment in developer mode. - * See: - * https://developers.google.com/gsuite/add-ons/how-tos/testing-gsuite-addons. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The full resource name of the deployment to install. - * - * Example: `projects/my_project/deployments/my_deployment`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for 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/g_suite_add_ons.install_deployment.js - * region_tag:gsuiteaddons_v1_generated_GSuiteAddOns_InstallDeployment_async - */ + /** + * Installs a deployment in developer mode. + * See: + * https://developers.google.com/gsuite/add-ons/how-tos/testing-gsuite-addons. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The full resource name of the deployment to install. + * + * Example: `projects/my_project/deployments/my_deployment`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for 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/g_suite_add_ons.install_deployment.js + * region_tag:gsuiteaddons_v1_generated_GSuiteAddOns_InstallDeployment_async + */ installDeployment( - request?: protos.google.cloud.gsuiteaddons.v1.IInstallDeploymentRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.gsuiteaddons.v1.IInstallDeploymentRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gsuiteaddons.v1.IInstallDeploymentRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.gsuiteaddons.v1.IInstallDeploymentRequest | undefined, + {} | undefined, + ] + >; installDeployment( - request: protos.google.cloud.gsuiteaddons.v1.IInstallDeploymentRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.gsuiteaddons.v1.IInstallDeploymentRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gsuiteaddons.v1.IInstallDeploymentRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.gsuiteaddons.v1.IInstallDeploymentRequest + | null + | undefined, + {} | null | undefined + >, + ): void; installDeployment( - request: protos.google.cloud.gsuiteaddons.v1.IInstallDeploymentRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.gsuiteaddons.v1.IInstallDeploymentRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gsuiteaddons.v1.IInstallDeploymentRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.gsuiteaddons.v1.IInstallDeploymentRequest + | null + | undefined, + {} | null | undefined + >, + ): void; installDeployment( - request?: protos.google.cloud.gsuiteaddons.v1.IInstallDeploymentRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.gsuiteaddons.v1.IInstallDeploymentRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.protobuf.IEmpty, - protos.google.cloud.gsuiteaddons.v1.IInstallDeploymentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.gsuiteaddons.v1.IInstallDeploymentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.gsuiteaddons.v1.IInstallDeploymentRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.gsuiteaddons.v1.IInstallDeploymentRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.gsuiteaddons.v1.IInstallDeploymentRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.gsuiteaddons.v1.IInstallDeploymentRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('installDeployment request %j', request); - const wrappedCallback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.gsuiteaddons.v1.IInstallDeploymentRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.gsuiteaddons.v1.IInstallDeploymentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('installDeployment response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.installDeployment(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.protobuf.IEmpty, - protos.google.cloud.gsuiteaddons.v1.IInstallDeploymentRequest|undefined, - {}|undefined - ]) => { - this._log.info('installDeployment response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .installDeployment(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.gsuiteaddons.v1.IInstallDeploymentRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('installDeployment response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Uninstalls a developer mode deployment. - * See: - * https://developers.google.com/gsuite/add-ons/how-tos/testing-gsuite-addons. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The full resource name of the deployment to install. - * - * Example: `projects/my_project/deployments/my_deployment`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for 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/g_suite_add_ons.uninstall_deployment.js - * region_tag:gsuiteaddons_v1_generated_GSuiteAddOns_UninstallDeployment_async - */ + /** + * Uninstalls a developer mode deployment. + * See: + * https://developers.google.com/gsuite/add-ons/how-tos/testing-gsuite-addons. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The full resource name of the deployment to install. + * + * Example: `projects/my_project/deployments/my_deployment`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for 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/g_suite_add_ons.uninstall_deployment.js + * region_tag:gsuiteaddons_v1_generated_GSuiteAddOns_UninstallDeployment_async + */ uninstallDeployment( - request?: protos.google.cloud.gsuiteaddons.v1.IUninstallDeploymentRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.gsuiteaddons.v1.IUninstallDeploymentRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gsuiteaddons.v1.IUninstallDeploymentRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.gsuiteaddons.v1.IUninstallDeploymentRequest + | undefined + ), + {} | undefined, + ] + >; uninstallDeployment( - request: protos.google.cloud.gsuiteaddons.v1.IUninstallDeploymentRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.gsuiteaddons.v1.IUninstallDeploymentRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gsuiteaddons.v1.IUninstallDeploymentRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.gsuiteaddons.v1.IUninstallDeploymentRequest + | null + | undefined, + {} | null | undefined + >, + ): void; uninstallDeployment( - request: protos.google.cloud.gsuiteaddons.v1.IUninstallDeploymentRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.gsuiteaddons.v1.IUninstallDeploymentRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gsuiteaddons.v1.IUninstallDeploymentRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.gsuiteaddons.v1.IUninstallDeploymentRequest + | null + | undefined, + {} | null | undefined + >, + ): void; uninstallDeployment( - request?: protos.google.cloud.gsuiteaddons.v1.IUninstallDeploymentRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.gsuiteaddons.v1.IUninstallDeploymentRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.protobuf.IEmpty, - protos.google.cloud.gsuiteaddons.v1.IUninstallDeploymentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.gsuiteaddons.v1.IUninstallDeploymentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.gsuiteaddons.v1.IUninstallDeploymentRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.gsuiteaddons.v1.IUninstallDeploymentRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.gsuiteaddons.v1.IUninstallDeploymentRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.gsuiteaddons.v1.IUninstallDeploymentRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('uninstallDeployment request %j', request); - const wrappedCallback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.gsuiteaddons.v1.IUninstallDeploymentRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.gsuiteaddons.v1.IUninstallDeploymentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('uninstallDeployment response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.uninstallDeployment(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.protobuf.IEmpty, - protos.google.cloud.gsuiteaddons.v1.IUninstallDeploymentRequest|undefined, - {}|undefined - ]) => { - this._log.info('uninstallDeployment response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .uninstallDeployment(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.gsuiteaddons.v1.IUninstallDeploymentRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('uninstallDeployment response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Fetches the install status of a developer mode deployment. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The full resource name of the deployment. - * - * Example: `projects/my_project/deployments/my_deployment/installStatus`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.gsuiteaddons.v1.InstallStatus|InstallStatus}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/g_suite_add_ons.get_install_status.js - * region_tag:gsuiteaddons_v1_generated_GSuiteAddOns_GetInstallStatus_async - */ + /** + * Fetches the install status of a developer mode deployment. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The full resource name of the deployment. + * + * Example: `projects/my_project/deployments/my_deployment/installStatus`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.gsuiteaddons.v1.InstallStatus|InstallStatus}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/g_suite_add_ons.get_install_status.js + * region_tag:gsuiteaddons_v1_generated_GSuiteAddOns_GetInstallStatus_async + */ getInstallStatus( - request?: protos.google.cloud.gsuiteaddons.v1.IGetInstallStatusRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gsuiteaddons.v1.IInstallStatus, - protos.google.cloud.gsuiteaddons.v1.IGetInstallStatusRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.gsuiteaddons.v1.IGetInstallStatusRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gsuiteaddons.v1.IInstallStatus, + protos.google.cloud.gsuiteaddons.v1.IGetInstallStatusRequest | undefined, + {} | undefined, + ] + >; getInstallStatus( - request: protos.google.cloud.gsuiteaddons.v1.IGetInstallStatusRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.gsuiteaddons.v1.IInstallStatus, - protos.google.cloud.gsuiteaddons.v1.IGetInstallStatusRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gsuiteaddons.v1.IGetInstallStatusRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.gsuiteaddons.v1.IInstallStatus, + | protos.google.cloud.gsuiteaddons.v1.IGetInstallStatusRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getInstallStatus( - request: protos.google.cloud.gsuiteaddons.v1.IGetInstallStatusRequest, - callback: Callback< - protos.google.cloud.gsuiteaddons.v1.IInstallStatus, - protos.google.cloud.gsuiteaddons.v1.IGetInstallStatusRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.gsuiteaddons.v1.IGetInstallStatusRequest, + callback: Callback< + protos.google.cloud.gsuiteaddons.v1.IInstallStatus, + | protos.google.cloud.gsuiteaddons.v1.IGetInstallStatusRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getInstallStatus( - request?: protos.google.cloud.gsuiteaddons.v1.IGetInstallStatusRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.gsuiteaddons.v1.IInstallStatus, - protos.google.cloud.gsuiteaddons.v1.IGetInstallStatusRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.gsuiteaddons.v1.IGetInstallStatusRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.gsuiteaddons.v1.IInstallStatus, - protos.google.cloud.gsuiteaddons.v1.IGetInstallStatusRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.gsuiteaddons.v1.IInstallStatus, - protos.google.cloud.gsuiteaddons.v1.IGetInstallStatusRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.gsuiteaddons.v1.IGetInstallStatusRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.gsuiteaddons.v1.IInstallStatus, + | protos.google.cloud.gsuiteaddons.v1.IGetInstallStatusRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.gsuiteaddons.v1.IInstallStatus, + protos.google.cloud.gsuiteaddons.v1.IGetInstallStatusRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getInstallStatus request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.gsuiteaddons.v1.IInstallStatus, - protos.google.cloud.gsuiteaddons.v1.IGetInstallStatusRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.gsuiteaddons.v1.IInstallStatus, + | protos.google.cloud.gsuiteaddons.v1.IGetInstallStatusRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getInstallStatus response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getInstallStatus(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.gsuiteaddons.v1.IInstallStatus, - protos.google.cloud.gsuiteaddons.v1.IGetInstallStatusRequest|undefined, - {}|undefined - ]) => { - this._log.info('getInstallStatus response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getInstallStatus(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.gsuiteaddons.v1.IInstallStatus, + ( + | protos.google.cloud.gsuiteaddons.v1.IGetInstallStatusRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getInstallStatus response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 deployments in a particular project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Name of the project in which to create the deployment. - * - * Example: `projects/my_project`. - * @param {number} request.pageSize - * The maximum number of deployments to return. The service may return fewer - * than this value. - * If unspecified, at most 1000 deployments 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 `ListDeployments` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListDeployments` 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.gsuiteaddons.v1.Deployment|Deployment}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listDeploymentsAsync()` - * method described below for async iteration which you can stop as 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 deployments in a particular project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Name of the project in which to create the deployment. + * + * Example: `projects/my_project`. + * @param {number} request.pageSize + * The maximum number of deployments to return. The service may return fewer + * than this value. + * If unspecified, at most 1000 deployments 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 `ListDeployments` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListDeployments` 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.gsuiteaddons.v1.Deployment|Deployment}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listDeploymentsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listDeployments( - request?: protos.google.cloud.gsuiteaddons.v1.IListDeploymentsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.gsuiteaddons.v1.IDeployment[], - protos.google.cloud.gsuiteaddons.v1.IListDeploymentsRequest|null, - protos.google.cloud.gsuiteaddons.v1.IListDeploymentsResponse - ]>; + request?: protos.google.cloud.gsuiteaddons.v1.IListDeploymentsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.gsuiteaddons.v1.IDeployment[], + protos.google.cloud.gsuiteaddons.v1.IListDeploymentsRequest | null, + protos.google.cloud.gsuiteaddons.v1.IListDeploymentsResponse, + ] + >; listDeployments( - request: protos.google.cloud.gsuiteaddons.v1.IListDeploymentsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.gsuiteaddons.v1.IListDeploymentsRequest, - protos.google.cloud.gsuiteaddons.v1.IListDeploymentsResponse|null|undefined, - protos.google.cloud.gsuiteaddons.v1.IDeployment>): void; + request: protos.google.cloud.gsuiteaddons.v1.IListDeploymentsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.gsuiteaddons.v1.IListDeploymentsRequest, + | protos.google.cloud.gsuiteaddons.v1.IListDeploymentsResponse + | null + | undefined, + protos.google.cloud.gsuiteaddons.v1.IDeployment + >, + ): void; listDeployments( - request: protos.google.cloud.gsuiteaddons.v1.IListDeploymentsRequest, - callback: PaginationCallback< - protos.google.cloud.gsuiteaddons.v1.IListDeploymentsRequest, - protos.google.cloud.gsuiteaddons.v1.IListDeploymentsResponse|null|undefined, - protos.google.cloud.gsuiteaddons.v1.IDeployment>): void; + request: protos.google.cloud.gsuiteaddons.v1.IListDeploymentsRequest, + callback: PaginationCallback< + protos.google.cloud.gsuiteaddons.v1.IListDeploymentsRequest, + | protos.google.cloud.gsuiteaddons.v1.IListDeploymentsResponse + | null + | undefined, + protos.google.cloud.gsuiteaddons.v1.IDeployment + >, + ): void; listDeployments( - request?: protos.google.cloud.gsuiteaddons.v1.IListDeploymentsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.gsuiteaddons.v1.IListDeploymentsRequest, - protos.google.cloud.gsuiteaddons.v1.IListDeploymentsResponse|null|undefined, - protos.google.cloud.gsuiteaddons.v1.IDeployment>, - callback?: PaginationCallback< + request?: protos.google.cloud.gsuiteaddons.v1.IListDeploymentsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.gsuiteaddons.v1.IListDeploymentsRequest, - protos.google.cloud.gsuiteaddons.v1.IListDeploymentsResponse|null|undefined, - protos.google.cloud.gsuiteaddons.v1.IDeployment>): - Promise<[ - protos.google.cloud.gsuiteaddons.v1.IDeployment[], - protos.google.cloud.gsuiteaddons.v1.IListDeploymentsRequest|null, - protos.google.cloud.gsuiteaddons.v1.IListDeploymentsResponse - ]>|void { + | protos.google.cloud.gsuiteaddons.v1.IListDeploymentsResponse + | null + | undefined, + protos.google.cloud.gsuiteaddons.v1.IDeployment + >, + callback?: PaginationCallback< + protos.google.cloud.gsuiteaddons.v1.IListDeploymentsRequest, + | protos.google.cloud.gsuiteaddons.v1.IListDeploymentsResponse + | null + | undefined, + protos.google.cloud.gsuiteaddons.v1.IDeployment + >, + ): Promise< + [ + protos.google.cloud.gsuiteaddons.v1.IDeployment[], + protos.google.cloud.gsuiteaddons.v1.IListDeploymentsRequest | null, + protos.google.cloud.gsuiteaddons.v1.IListDeploymentsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-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.gsuiteaddons.v1.IListDeploymentsRequest, - protos.google.cloud.gsuiteaddons.v1.IListDeploymentsResponse|null|undefined, - protos.google.cloud.gsuiteaddons.v1.IDeployment>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.gsuiteaddons.v1.IListDeploymentsRequest, + | protos.google.cloud.gsuiteaddons.v1.IListDeploymentsResponse + | null + | undefined, + protos.google.cloud.gsuiteaddons.v1.IDeployment + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listDeployments values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1250,124 +1677,128 @@ export class GSuiteAddOnsClient { this._log.info('listDeployments request %j', request); return this.innerApiCalls .listDeployments(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.gsuiteaddons.v1.IDeployment[], - protos.google.cloud.gsuiteaddons.v1.IListDeploymentsRequest|null, - protos.google.cloud.gsuiteaddons.v1.IListDeploymentsResponse - ]) => { - this._log.info('listDeployments values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.gsuiteaddons.v1.IDeployment[], + protos.google.cloud.gsuiteaddons.v1.IListDeploymentsRequest | null, + protos.google.cloud.gsuiteaddons.v1.IListDeploymentsResponse, + ]) => { + this._log.info('listDeployments values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listDeployments`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Name of the project in which to create the deployment. - * - * Example: `projects/my_project`. - * @param {number} request.pageSize - * The maximum number of deployments to return. The service may return fewer - * than this value. - * If unspecified, at most 1000 deployments 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 `ListDeployments` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListDeployments` 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.gsuiteaddons.v1.Deployment|Deployment} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listDeploymentsAsync()` - * method described below for async iteration which you can stop as 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 `listDeployments`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Name of the project in which to create the deployment. + * + * Example: `projects/my_project`. + * @param {number} request.pageSize + * The maximum number of deployments to return. The service may return fewer + * than this value. + * If unspecified, at most 1000 deployments 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 `ListDeployments` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListDeployments` 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.gsuiteaddons.v1.Deployment|Deployment} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listDeploymentsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listDeploymentsStream( - request?: protos.google.cloud.gsuiteaddons.v1.IListDeploymentsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.gsuiteaddons.v1.IListDeploymentsRequest, + 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['listDeployments']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listDeployments stream %j', request); return this.descriptors.page.listDeployments.createStream( this.innerApiCalls.listDeployments as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listDeployments`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Name of the project in which to create the deployment. - * - * Example: `projects/my_project`. - * @param {number} request.pageSize - * The maximum number of deployments to return. The service may return fewer - * than this value. - * If unspecified, at most 1000 deployments 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 `ListDeployments` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListDeployments` 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.gsuiteaddons.v1.Deployment|Deployment}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@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/g_suite_add_ons.list_deployments.js - * region_tag:gsuiteaddons_v1_generated_GSuiteAddOns_ListDeployments_async - */ + /** + * Equivalent to `listDeployments`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Name of the project in which to create the deployment. + * + * Example: `projects/my_project`. + * @param {number} request.pageSize + * The maximum number of deployments to return. The service may return fewer + * than this value. + * If unspecified, at most 1000 deployments 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 `ListDeployments` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListDeployments` 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.gsuiteaddons.v1.Deployment|Deployment}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@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/g_suite_add_ons.list_deployments.js + * region_tag:gsuiteaddons_v1_generated_GSuiteAddOns_ListDeployments_async + */ listDeploymentsAsync( - request?: protos.google.cloud.gsuiteaddons.v1.IListDeploymentsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.gsuiteaddons.v1.IListDeploymentsRequest, + 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['listDeployments']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listDeployments iterate %j', request); return this.descriptors.page.listDeployments.asyncIterate( this.innerApiCalls['listDeployments'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } // -------------------- @@ -1380,7 +1811,7 @@ export class GSuiteAddOnsClient { * @param {string} project * @returns {string} Resource name string. */ - authorizationPath(project:string) { + authorizationPath(project: string) { return this.pathTemplates.authorizationPathTemplate.render({ project: project, }); @@ -1394,7 +1825,8 @@ export class GSuiteAddOnsClient { * @returns {string} A string representing the project. */ matchProjectFromAuthorizationName(authorizationName: string) { - return this.pathTemplates.authorizationPathTemplate.match(authorizationName).project; + return this.pathTemplates.authorizationPathTemplate.match(authorizationName) + .project; } /** @@ -1404,7 +1836,7 @@ export class GSuiteAddOnsClient { * @param {string} deployment * @returns {string} Resource name string. */ - deploymentPath(project:string,deployment:string) { + deploymentPath(project: string, deployment: string) { return this.pathTemplates.deploymentPathTemplate.render({ project: project, deployment: deployment, @@ -1419,7 +1851,8 @@ export class GSuiteAddOnsClient { * @returns {string} A string representing the project. */ matchProjectFromDeploymentName(deploymentName: string) { - return this.pathTemplates.deploymentPathTemplate.match(deploymentName).project; + return this.pathTemplates.deploymentPathTemplate.match(deploymentName) + .project; } /** @@ -1430,7 +1863,8 @@ export class GSuiteAddOnsClient { * @returns {string} A string representing the deployment. */ matchDeploymentFromDeploymentName(deploymentName: string) { - return this.pathTemplates.deploymentPathTemplate.match(deploymentName).deployment; + return this.pathTemplates.deploymentPathTemplate.match(deploymentName) + .deployment; } /** @@ -1440,7 +1874,7 @@ export class GSuiteAddOnsClient { * @param {string} deployment * @returns {string} Resource name string. */ - installStatusPath(project:string,deployment:string) { + installStatusPath(project: string, deployment: string) { return this.pathTemplates.installStatusPathTemplate.render({ project: project, deployment: deployment, @@ -1455,7 +1889,8 @@ export class GSuiteAddOnsClient { * @returns {string} A string representing the project. */ matchProjectFromInstallStatusName(installStatusName: string) { - return this.pathTemplates.installStatusPathTemplate.match(installStatusName).project; + return this.pathTemplates.installStatusPathTemplate.match(installStatusName) + .project; } /** @@ -1466,7 +1901,8 @@ export class GSuiteAddOnsClient { * @returns {string} A string representing the deployment. */ matchDeploymentFromInstallStatusName(installStatusName: string) { - return this.pathTemplates.installStatusPathTemplate.match(installStatusName).deployment; + return this.pathTemplates.installStatusPathTemplate.match(installStatusName) + .deployment; } /** @@ -1475,7 +1911,7 @@ export class GSuiteAddOnsClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -1500,7 +1936,7 @@ export class GSuiteAddOnsClient { */ close(): Promise { if (this.gSuiteAddOnsStub && !this._terminated) { - return this.gSuiteAddOnsStub.then(stub => { + return this.gSuiteAddOnsStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); @@ -1508,4 +1944,4 @@ export class GSuiteAddOnsClient { } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-gsuiteaddons/src/v1/index.ts b/packages/google-cloud-gsuiteaddons/src/v1/index.ts index b8ff1c934387..3009eefa910e 100644 --- a/packages/google-cloud-gsuiteaddons/src/v1/index.ts +++ b/packages/google-cloud-gsuiteaddons/src/v1/index.ts @@ -16,4 +16,4 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {GSuiteAddOnsClient} from './g_suite_add_ons_client'; +export { GSuiteAddOnsClient } from './g_suite_add_ons_client'; diff --git a/packages/google-cloud-gsuiteaddons/system-test/fixtures/sample/src/index.ts b/packages/google-cloud-gsuiteaddons/system-test/fixtures/sample/src/index.ts index ab1627d451a7..e7eaa08752f2 100644 --- a/packages/google-cloud-gsuiteaddons/system-test/fixtures/sample/src/index.ts +++ b/packages/google-cloud-gsuiteaddons/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 {GSuiteAddOnsClient} from '@google-cloud/gsuiteaddons'; +import { GSuiteAddOnsClient } from '@google-cloud/gsuiteaddons'; // check that the client class type name can be used function doStuffWithGSuiteAddOnsClient(client: GSuiteAddOnsClient) { diff --git a/packages/google-cloud-gsuiteaddons/system-test/install.ts b/packages/google-cloud-gsuiteaddons/system-test/install.ts index f66069aa3940..ccf167042d2e 100644 --- a/packages/google-cloud-gsuiteaddons/system-test/install.ts +++ b/packages/google-cloud-gsuiteaddons/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-gsuiteaddons/test/gapic_g_suite_add_ons_v1.ts b/packages/google-cloud-gsuiteaddons/test/gapic_g_suite_add_ons_v1.ts index 48cf5b54949f..525e61022cea 100644 --- a/packages/google-cloud-gsuiteaddons/test/gapic_g_suite_add_ons_v1.ts +++ b/packages/google-cloud-gsuiteaddons/test/gapic_g_suite_add_ons_v1.ts @@ -19,1495 +19,1869 @@ 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 gsuiteaddonsModule 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.GSuiteAddOnsClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'gsuiteaddons.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient(); - 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 = gsuiteaddonsModule.v1.GSuiteAddOnsClient.servicePath; - assert.strictEqual(servicePath, 'gsuiteaddons.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = gsuiteaddonsModule.v1.GSuiteAddOnsClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'gsuiteaddons.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'gsuiteaddons.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'gsuiteaddons.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 gsuiteaddonsModule.v1.GSuiteAddOnsClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'gsuiteaddons.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 gsuiteaddonsModule.v1.GSuiteAddOnsClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'gsuiteaddons.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 gsuiteaddonsModule.v1.GSuiteAddOnsClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); - - it('has port', () => { - const port = gsuiteaddonsModule.v1.GSuiteAddOnsClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient(); - assert(client); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'gsuiteaddons.googleapis.com'); + }); - it('should create a client with gRPC fallback', () => { - const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ - fallback: true, - }); - assert(client); - }); + it('has universeDomain', () => { + const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.gSuiteAddOnsStub, undefined); - await client.initialize(); - assert(client.gSuiteAddOnsStub); - }); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + gsuiteaddonsModule.v1.GSuiteAddOnsClient.servicePath; + assert.strictEqual(servicePath, 'gsuiteaddons.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + gsuiteaddonsModule.v1.GSuiteAddOnsClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'gsuiteaddons.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'gsuiteaddons.example.com'); + }); - it('has close method for the initialized client', done => { - const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.gSuiteAddOnsStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'gsuiteaddons.example.com'); + }); - it('has close method for the non-initialized client', done => { - const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.gSuiteAddOnsStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'gsuiteaddons.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + it('value configured in code has priority over environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual( + servicePath, + 'gsuiteaddons.configured.example.com', + ); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); }); - describe('getAuthorization', () => { - it('invokes getAuthorization without error', async () => { - const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gsuiteaddons.v1.GetAuthorizationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gsuiteaddons.v1.GetAuthorizationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.gsuiteaddons.v1.Authorization() - ); - client.innerApiCalls.getAuthorization = stubSimpleCall(expectedResponse); - const [response] = await client.getAuthorization(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getAuthorization as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getAuthorization as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has port', () => { + const port = gsuiteaddonsModule.v1.GSuiteAddOnsClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('invokes getAuthorization without error using callback', async () => { - const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gsuiteaddons.v1.GetAuthorizationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gsuiteaddons.v1.GetAuthorizationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.gsuiteaddons.v1.Authorization() - ); - client.innerApiCalls.getAuthorization = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getAuthorization( - request, - (err?: Error|null, result?: protos.google.cloud.gsuiteaddons.v1.IAuthorization|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getAuthorization as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getAuthorization 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 gsuiteaddonsModule.v1.GSuiteAddOnsClient(); + assert(client); + }); - it('invokes getAuthorization with error', async () => { - const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gsuiteaddons.v1.GetAuthorizationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gsuiteaddons.v1.GetAuthorizationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getAuthorization = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getAuthorization(request), expectedError); - const actualRequest = (client.innerApiCalls.getAuthorization as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getAuthorization 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 gsuiteaddonsModule.v1.GSuiteAddOnsClient({ + fallback: true, + }); + assert(client); + }); - it('invokes getAuthorization with closed client', async () => { - const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gsuiteaddons.v1.GetAuthorizationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gsuiteaddons.v1.GetAuthorizationRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getAuthorization(request), expectedError); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.gSuiteAddOnsStub, undefined); + await client.initialize(); + assert(client.gSuiteAddOnsStub); }); - describe('createDeployment', () => { - it('invokes createDeployment without error', async () => { - const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gsuiteaddons.v1.CreateDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gsuiteaddons.v1.CreateDeploymentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.gsuiteaddons.v1.Deployment() - ); - client.innerApiCalls.createDeployment = stubSimpleCall(expectedResponse); - const [response] = await client.createDeployment(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createDeployment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDeployment 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 gsuiteaddonsModule.v1.GSuiteAddOnsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.gSuiteAddOnsStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes createDeployment without error using callback', async () => { - const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gsuiteaddons.v1.CreateDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gsuiteaddons.v1.CreateDeploymentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.gsuiteaddons.v1.Deployment() - ); - client.innerApiCalls.createDeployment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createDeployment( - request, - (err?: Error|null, result?: protos.google.cloud.gsuiteaddons.v1.IDeployment|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createDeployment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDeployment 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 gsuiteaddonsModule.v1.GSuiteAddOnsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.gSuiteAddOnsStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes createDeployment with error', async () => { - const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gsuiteaddons.v1.CreateDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gsuiteaddons.v1.CreateDeploymentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createDeployment = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createDeployment(request), expectedError); - const actualRequest = (client.innerApiCalls.createDeployment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDeployment 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 gsuiteaddonsModule.v1.GSuiteAddOnsClient({ + 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 createDeployment with closed client', async () => { - const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gsuiteaddons.v1.CreateDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gsuiteaddons.v1.CreateDeploymentRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.createDeployment(request), expectedError); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ + 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('getAuthorization', () => { + it('invokes getAuthorization without error', async () => { + const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.GetAuthorizationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gsuiteaddons.v1.GetAuthorizationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.Authorization(), + ); + client.innerApiCalls.getAuthorization = stubSimpleCall(expectedResponse); + const [response] = await client.getAuthorization(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getAuthorization as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getAuthorization as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('replaceDeployment', () => { - it('invokes replaceDeployment without error', async () => { - const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gsuiteaddons.v1.ReplaceDeploymentRequest() - ); - request.deployment ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gsuiteaddons.v1.ReplaceDeploymentRequest', ['deployment', 'name']); - request.deployment.name = defaultValue1; - const expectedHeaderRequestParams = `deployment.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.gsuiteaddons.v1.Deployment() - ); - client.innerApiCalls.replaceDeployment = stubSimpleCall(expectedResponse); - const [response] = await client.replaceDeployment(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.replaceDeployment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.replaceDeployment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getAuthorization without error using callback', async () => { + const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.GetAuthorizationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gsuiteaddons.v1.GetAuthorizationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.Authorization(), + ); + client.innerApiCalls.getAuthorization = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getAuthorization( + request, + ( + err?: Error | null, + result?: protos.google.cloud.gsuiteaddons.v1.IAuthorization | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getAuthorization as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getAuthorization as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes replaceDeployment without error using callback', async () => { - const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gsuiteaddons.v1.ReplaceDeploymentRequest() - ); - request.deployment ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gsuiteaddons.v1.ReplaceDeploymentRequest', ['deployment', 'name']); - request.deployment.name = defaultValue1; - const expectedHeaderRequestParams = `deployment.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.gsuiteaddons.v1.Deployment() - ); - client.innerApiCalls.replaceDeployment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.replaceDeployment( - request, - (err?: Error|null, result?: protos.google.cloud.gsuiteaddons.v1.IDeployment|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.replaceDeployment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.replaceDeployment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getAuthorization with error', async () => { + const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.GetAuthorizationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gsuiteaddons.v1.GetAuthorizationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getAuthorization = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getAuthorization(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getAuthorization as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getAuthorization as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes replaceDeployment with error', async () => { - const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gsuiteaddons.v1.ReplaceDeploymentRequest() - ); - request.deployment ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gsuiteaddons.v1.ReplaceDeploymentRequest', ['deployment', 'name']); - request.deployment.name = defaultValue1; - const expectedHeaderRequestParams = `deployment.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.replaceDeployment = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.replaceDeployment(request), expectedError); - const actualRequest = (client.innerApiCalls.replaceDeployment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.replaceDeployment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getAuthorization with closed client', async () => { + const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.GetAuthorizationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gsuiteaddons.v1.GetAuthorizationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getAuthorization(request), expectedError); + }); + }); + + describe('createDeployment', () => { + it('invokes createDeployment without error', async () => { + const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.CreateDeploymentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gsuiteaddons.v1.CreateDeploymentRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.Deployment(), + ); + client.innerApiCalls.createDeployment = stubSimpleCall(expectedResponse); + const [response] = await client.createDeployment(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createDeployment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createDeployment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes replaceDeployment with closed client', async () => { - const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gsuiteaddons.v1.ReplaceDeploymentRequest() - ); - request.deployment ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gsuiteaddons.v1.ReplaceDeploymentRequest', ['deployment', 'name']); - request.deployment.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.replaceDeployment(request), expectedError); - }); + it('invokes createDeployment without error using callback', async () => { + const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.CreateDeploymentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gsuiteaddons.v1.CreateDeploymentRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.Deployment(), + ); + client.innerApiCalls.createDeployment = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createDeployment( + request, + ( + err?: Error | null, + result?: protos.google.cloud.gsuiteaddons.v1.IDeployment | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createDeployment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createDeployment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getDeployment', () => { - it('invokes getDeployment without error', async () => { - const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gsuiteaddons.v1.GetDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gsuiteaddons.v1.GetDeploymentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.gsuiteaddons.v1.Deployment() - ); - client.innerApiCalls.getDeployment = stubSimpleCall(expectedResponse); - const [response] = await client.getDeployment(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getDeployment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDeployment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createDeployment with error', async () => { + const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.CreateDeploymentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gsuiteaddons.v1.CreateDeploymentRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createDeployment = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.createDeployment(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createDeployment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createDeployment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getDeployment without error using callback', async () => { - const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gsuiteaddons.v1.GetDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gsuiteaddons.v1.GetDeploymentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.gsuiteaddons.v1.Deployment() - ); - client.innerApiCalls.getDeployment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getDeployment( - request, - (err?: Error|null, result?: protos.google.cloud.gsuiteaddons.v1.IDeployment|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getDeployment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDeployment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createDeployment with closed client', async () => { + const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.CreateDeploymentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gsuiteaddons.v1.CreateDeploymentRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.createDeployment(request), expectedError); + }); + }); + + describe('replaceDeployment', () => { + it('invokes replaceDeployment without error', async () => { + const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.ReplaceDeploymentRequest(), + ); + request.deployment ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gsuiteaddons.v1.ReplaceDeploymentRequest', + ['deployment', 'name'], + ); + request.deployment.name = defaultValue1; + const expectedHeaderRequestParams = `deployment.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.Deployment(), + ); + client.innerApiCalls.replaceDeployment = stubSimpleCall(expectedResponse); + const [response] = await client.replaceDeployment(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.replaceDeployment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.replaceDeployment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getDeployment with error', async () => { - const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gsuiteaddons.v1.GetDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gsuiteaddons.v1.GetDeploymentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getDeployment = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getDeployment(request), expectedError); - const actualRequest = (client.innerApiCalls.getDeployment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDeployment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes replaceDeployment without error using callback', async () => { + const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.ReplaceDeploymentRequest(), + ); + request.deployment ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gsuiteaddons.v1.ReplaceDeploymentRequest', + ['deployment', 'name'], + ); + request.deployment.name = defaultValue1; + const expectedHeaderRequestParams = `deployment.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.Deployment(), + ); + client.innerApiCalls.replaceDeployment = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.replaceDeployment( + request, + ( + err?: Error | null, + result?: protos.google.cloud.gsuiteaddons.v1.IDeployment | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.replaceDeployment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.replaceDeployment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getDeployment with closed client', async () => { - const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gsuiteaddons.v1.GetDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gsuiteaddons.v1.GetDeploymentRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getDeployment(request), expectedError); - }); + it('invokes replaceDeployment with error', async () => { + const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.ReplaceDeploymentRequest(), + ); + request.deployment ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gsuiteaddons.v1.ReplaceDeploymentRequest', + ['deployment', 'name'], + ); + request.deployment.name = defaultValue1; + const expectedHeaderRequestParams = `deployment.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.replaceDeployment = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.replaceDeployment(request), expectedError); + const actualRequest = ( + client.innerApiCalls.replaceDeployment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.replaceDeployment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteDeployment', () => { - it('invokes deleteDeployment without error', async () => { - const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gsuiteaddons.v1.DeleteDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gsuiteaddons.v1.DeleteDeploymentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteDeployment = stubSimpleCall(expectedResponse); - const [response] = await client.deleteDeployment(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteDeployment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteDeployment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes replaceDeployment with closed client', async () => { + const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.ReplaceDeploymentRequest(), + ); + request.deployment ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gsuiteaddons.v1.ReplaceDeploymentRequest', + ['deployment', 'name'], + ); + request.deployment.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.replaceDeployment(request), expectedError); + }); + }); + + describe('getDeployment', () => { + it('invokes getDeployment without error', async () => { + const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.GetDeploymentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gsuiteaddons.v1.GetDeploymentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.Deployment(), + ); + client.innerApiCalls.getDeployment = stubSimpleCall(expectedResponse); + const [response] = await client.getDeployment(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getDeployment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDeployment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteDeployment without error using callback', async () => { - const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gsuiteaddons.v1.DeleteDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gsuiteaddons.v1.DeleteDeploymentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteDeployment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteDeployment( - 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.deleteDeployment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteDeployment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getDeployment without error using callback', async () => { + const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.GetDeploymentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gsuiteaddons.v1.GetDeploymentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.Deployment(), + ); + client.innerApiCalls.getDeployment = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getDeployment( + request, + ( + err?: Error | null, + result?: protos.google.cloud.gsuiteaddons.v1.IDeployment | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getDeployment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDeployment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteDeployment with error', async () => { - const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gsuiteaddons.v1.DeleteDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gsuiteaddons.v1.DeleteDeploymentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteDeployment = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteDeployment(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteDeployment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteDeployment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getDeployment with error', async () => { + const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.GetDeploymentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gsuiteaddons.v1.GetDeploymentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getDeployment = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getDeployment(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getDeployment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDeployment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteDeployment with closed client', async () => { - const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gsuiteaddons.v1.DeleteDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gsuiteaddons.v1.DeleteDeploymentRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.deleteDeployment(request), expectedError); - }); + it('invokes getDeployment with closed client', async () => { + const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.GetDeploymentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gsuiteaddons.v1.GetDeploymentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getDeployment(request), expectedError); + }); + }); + + describe('deleteDeployment', () => { + it('invokes deleteDeployment without error', async () => { + const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.DeleteDeploymentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gsuiteaddons.v1.DeleteDeploymentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteDeployment = stubSimpleCall(expectedResponse); + const [response] = await client.deleteDeployment(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteDeployment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteDeployment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('installDeployment', () => { - it('invokes installDeployment without error', async () => { - const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gsuiteaddons.v1.InstallDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gsuiteaddons.v1.InstallDeploymentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.installDeployment = stubSimpleCall(expectedResponse); - const [response] = await client.installDeployment(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.installDeployment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.installDeployment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteDeployment without error using callback', async () => { + const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.DeleteDeploymentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gsuiteaddons.v1.DeleteDeploymentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteDeployment = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteDeployment( + 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.deleteDeployment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteDeployment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes installDeployment without error using callback', async () => { - const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gsuiteaddons.v1.InstallDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gsuiteaddons.v1.InstallDeploymentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.installDeployment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.installDeployment( - 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.installDeployment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.installDeployment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteDeployment with error', async () => { + const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.DeleteDeploymentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gsuiteaddons.v1.DeleteDeploymentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteDeployment = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteDeployment(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteDeployment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteDeployment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes installDeployment with error', async () => { - const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gsuiteaddons.v1.InstallDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gsuiteaddons.v1.InstallDeploymentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.installDeployment = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.installDeployment(request), expectedError); - const actualRequest = (client.innerApiCalls.installDeployment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.installDeployment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteDeployment with closed client', async () => { + const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.DeleteDeploymentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gsuiteaddons.v1.DeleteDeploymentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.deleteDeployment(request), expectedError); + }); + }); + + describe('installDeployment', () => { + it('invokes installDeployment without error', async () => { + const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.InstallDeploymentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gsuiteaddons.v1.InstallDeploymentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.installDeployment = stubSimpleCall(expectedResponse); + const [response] = await client.installDeployment(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.installDeployment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.installDeployment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes installDeployment with closed client', async () => { - const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gsuiteaddons.v1.InstallDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gsuiteaddons.v1.InstallDeploymentRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.installDeployment(request), expectedError); - }); + it('invokes installDeployment without error using callback', async () => { + const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.InstallDeploymentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gsuiteaddons.v1.InstallDeploymentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.installDeployment = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.installDeployment( + 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.installDeployment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.installDeployment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('uninstallDeployment', () => { - it('invokes uninstallDeployment without error', async () => { - const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gsuiteaddons.v1.UninstallDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gsuiteaddons.v1.UninstallDeploymentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.uninstallDeployment = stubSimpleCall(expectedResponse); - const [response] = await client.uninstallDeployment(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.uninstallDeployment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.uninstallDeployment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes installDeployment with error', async () => { + const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.InstallDeploymentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gsuiteaddons.v1.InstallDeploymentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.installDeployment = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.installDeployment(request), expectedError); + const actualRequest = ( + client.innerApiCalls.installDeployment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.installDeployment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes uninstallDeployment without error using callback', async () => { - const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gsuiteaddons.v1.UninstallDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gsuiteaddons.v1.UninstallDeploymentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.uninstallDeployment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.uninstallDeployment( - 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.uninstallDeployment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.uninstallDeployment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes installDeployment with closed client', async () => { + const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.InstallDeploymentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gsuiteaddons.v1.InstallDeploymentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.installDeployment(request), expectedError); + }); + }); + + describe('uninstallDeployment', () => { + it('invokes uninstallDeployment without error', async () => { + const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.UninstallDeploymentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gsuiteaddons.v1.UninstallDeploymentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.uninstallDeployment = + stubSimpleCall(expectedResponse); + const [response] = await client.uninstallDeployment(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.uninstallDeployment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.uninstallDeployment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes uninstallDeployment with error', async () => { - const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gsuiteaddons.v1.UninstallDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gsuiteaddons.v1.UninstallDeploymentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.uninstallDeployment = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.uninstallDeployment(request), expectedError); - const actualRequest = (client.innerApiCalls.uninstallDeployment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.uninstallDeployment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes uninstallDeployment without error using callback', async () => { + const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.UninstallDeploymentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gsuiteaddons.v1.UninstallDeploymentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.uninstallDeployment = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.uninstallDeployment( + 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.uninstallDeployment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.uninstallDeployment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes uninstallDeployment with closed client', async () => { - const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gsuiteaddons.v1.UninstallDeploymentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gsuiteaddons.v1.UninstallDeploymentRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.uninstallDeployment(request), expectedError); - }); + it('invokes uninstallDeployment with error', async () => { + const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.UninstallDeploymentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gsuiteaddons.v1.UninstallDeploymentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.uninstallDeployment = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.uninstallDeployment(request), expectedError); + const actualRequest = ( + client.innerApiCalls.uninstallDeployment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.uninstallDeployment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getInstallStatus', () => { - it('invokes getInstallStatus without error', async () => { - const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gsuiteaddons.v1.GetInstallStatusRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gsuiteaddons.v1.GetInstallStatusRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.gsuiteaddons.v1.InstallStatus() - ); - client.innerApiCalls.getInstallStatus = stubSimpleCall(expectedResponse); - const [response] = await client.getInstallStatus(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getInstallStatus as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstallStatus as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes uninstallDeployment with closed client', async () => { + const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.UninstallDeploymentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gsuiteaddons.v1.UninstallDeploymentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.uninstallDeployment(request), expectedError); + }); + }); + + describe('getInstallStatus', () => { + it('invokes getInstallStatus without error', async () => { + const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.GetInstallStatusRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gsuiteaddons.v1.GetInstallStatusRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.InstallStatus(), + ); + client.innerApiCalls.getInstallStatus = stubSimpleCall(expectedResponse); + const [response] = await client.getInstallStatus(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getInstallStatus as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getInstallStatus as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getInstallStatus without error using callback', async () => { - const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gsuiteaddons.v1.GetInstallStatusRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gsuiteaddons.v1.GetInstallStatusRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.gsuiteaddons.v1.InstallStatus() - ); - client.innerApiCalls.getInstallStatus = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getInstallStatus( - request, - (err?: Error|null, result?: protos.google.cloud.gsuiteaddons.v1.IInstallStatus|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getInstallStatus as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstallStatus as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getInstallStatus without error using callback', async () => { + const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.GetInstallStatusRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gsuiteaddons.v1.GetInstallStatusRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.InstallStatus(), + ); + client.innerApiCalls.getInstallStatus = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getInstallStatus( + request, + ( + err?: Error | null, + result?: protos.google.cloud.gsuiteaddons.v1.IInstallStatus | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getInstallStatus as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getInstallStatus as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getInstallStatus with error', async () => { - const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gsuiteaddons.v1.GetInstallStatusRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gsuiteaddons.v1.GetInstallStatusRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getInstallStatus = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getInstallStatus(request), expectedError); - const actualRequest = (client.innerApiCalls.getInstallStatus as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstallStatus as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getInstallStatus with error', async () => { + const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.GetInstallStatusRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gsuiteaddons.v1.GetInstallStatusRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getInstallStatus = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getInstallStatus(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getInstallStatus as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getInstallStatus as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getInstallStatus with closed client', async () => { - const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gsuiteaddons.v1.GetInstallStatusRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gsuiteaddons.v1.GetInstallStatusRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getInstallStatus(request), expectedError); - }); + it('invokes getInstallStatus with closed client', async () => { + const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.GetInstallStatusRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gsuiteaddons.v1.GetInstallStatusRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getInstallStatus(request), expectedError); + }); + }); + + describe('listDeployments', () => { + it('invokes listDeployments without error', async () => { + const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.ListDeploymentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gsuiteaddons.v1.ListDeploymentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.Deployment(), + ), + generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.Deployment(), + ), + generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.Deployment(), + ), + ]; + client.innerApiCalls.listDeployments = stubSimpleCall(expectedResponse); + const [response] = await client.listDeployments(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listDeployments as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDeployments as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listDeployments', () => { - it('invokes listDeployments without error', async () => { - const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gsuiteaddons.v1.ListDeploymentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gsuiteaddons.v1.ListDeploymentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gsuiteaddons.v1.Deployment()), - generateSampleMessage(new protos.google.cloud.gsuiteaddons.v1.Deployment()), - generateSampleMessage(new protos.google.cloud.gsuiteaddons.v1.Deployment()), - ]; - client.innerApiCalls.listDeployments = stubSimpleCall(expectedResponse); - const [response] = await client.listDeployments(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listDeployments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDeployments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listDeployments without error using callback', async () => { + const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.ListDeploymentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gsuiteaddons.v1.ListDeploymentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.Deployment(), + ), + generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.Deployment(), + ), + generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.Deployment(), + ), + ]; + client.innerApiCalls.listDeployments = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listDeployments( + request, + ( + err?: Error | null, + result?: protos.google.cloud.gsuiteaddons.v1.IDeployment[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listDeployments as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDeployments as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listDeployments without error using callback', async () => { - const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gsuiteaddons.v1.ListDeploymentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gsuiteaddons.v1.ListDeploymentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gsuiteaddons.v1.Deployment()), - generateSampleMessage(new protos.google.cloud.gsuiteaddons.v1.Deployment()), - generateSampleMessage(new protos.google.cloud.gsuiteaddons.v1.Deployment()), - ]; - client.innerApiCalls.listDeployments = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listDeployments( - request, - (err?: Error|null, result?: protos.google.cloud.gsuiteaddons.v1.IDeployment[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listDeployments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDeployments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listDeployments with error', async () => { + const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.ListDeploymentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gsuiteaddons.v1.ListDeploymentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listDeployments = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listDeployments(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listDeployments as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDeployments as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listDeployments with error', async () => { - const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gsuiteaddons.v1.ListDeploymentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gsuiteaddons.v1.ListDeploymentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listDeployments = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listDeployments(request), expectedError); - const actualRequest = (client.innerApiCalls.listDeployments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDeployments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes listDeploymentsStream without error', async () => { + const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.ListDeploymentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gsuiteaddons.v1.ListDeploymentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.Deployment(), + ), + generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.Deployment(), + ), + generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.Deployment(), + ), + ]; + client.descriptors.page.listDeployments.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listDeploymentsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.gsuiteaddons.v1.Deployment[] = []; + stream.on( + 'data', + (response: protos.google.cloud.gsuiteaddons.v1.Deployment) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('invokes listDeploymentsStream without error', async () => { - const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gsuiteaddons.v1.ListDeploymentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gsuiteaddons.v1.ListDeploymentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gsuiteaddons.v1.Deployment()), - generateSampleMessage(new protos.google.cloud.gsuiteaddons.v1.Deployment()), - generateSampleMessage(new protos.google.cloud.gsuiteaddons.v1.Deployment()), - ]; - client.descriptors.page.listDeployments.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listDeploymentsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.gsuiteaddons.v1.Deployment[] = []; - stream.on('data', (response: protos.google.cloud.gsuiteaddons.v1.Deployment) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listDeployments.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listDeployments, request)); - assert( - (client.descriptors.page.listDeployments.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.listDeployments.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listDeployments, request), + ); + assert( + (client.descriptors.page.listDeployments.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listDeploymentsStream with error', async () => { - const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gsuiteaddons.v1.ListDeploymentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gsuiteaddons.v1.ListDeploymentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listDeployments.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listDeploymentsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.gsuiteaddons.v1.Deployment[] = []; - stream.on('data', (response: protos.google.cloud.gsuiteaddons.v1.Deployment) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listDeployments.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listDeployments, request)); - assert( - (client.descriptors.page.listDeployments.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); + it('invokes listDeploymentsStream with error', async () => { + const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.ListDeploymentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gsuiteaddons.v1.ListDeploymentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listDeployments.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listDeploymentsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.gsuiteaddons.v1.Deployment[] = []; + stream.on( + 'data', + (response: protos.google.cloud.gsuiteaddons.v1.Deployment) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('uses async iteration with listDeployments without error', async () => { - const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gsuiteaddons.v1.ListDeploymentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gsuiteaddons.v1.ListDeploymentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.gsuiteaddons.v1.Deployment()), - generateSampleMessage(new protos.google.cloud.gsuiteaddons.v1.Deployment()), - generateSampleMessage(new protos.google.cloud.gsuiteaddons.v1.Deployment()), - ]; - client.descriptors.page.listDeployments.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.gsuiteaddons.v1.IDeployment[] = []; - const iterable = client.listDeploymentsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listDeployments.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listDeployments.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.listDeployments.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listDeployments, request), + ); + assert( + (client.descriptors.page.listDeployments.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listDeployments with error', async () => { - const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.gsuiteaddons.v1.ListDeploymentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.gsuiteaddons.v1.ListDeploymentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listDeployments.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listDeploymentsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.gsuiteaddons.v1.IDeployment[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listDeployments.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listDeployments.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listDeployments without error', async () => { + const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.ListDeploymentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gsuiteaddons.v1.ListDeploymentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.Deployment(), + ), + generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.Deployment(), + ), + generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.Deployment(), + ), + ]; + client.descriptors.page.listDeployments.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.gsuiteaddons.v1.IDeployment[] = []; + const iterable = client.listDeploymentsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listDeployments.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listDeployments.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); }); - describe('Path templates', () => { - - describe('authorization', async () => { - const fakePath = "/rendered/path/authorization"; - const expectedParameters = { - project: "projectValue", - }; - const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.authorizationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.authorizationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('authorizationPath', () => { - const result = client.authorizationPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.authorizationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAuthorizationName', () => { - const result = client.matchProjectFromAuthorizationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.authorizationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('uses async iteration with listDeployments with error', async () => { + const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.gsuiteaddons.v1.ListDeploymentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.gsuiteaddons.v1.ListDeploymentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listDeployments.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listDeploymentsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.gsuiteaddons.v1.IDeployment[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listDeployments.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listDeployments.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('Path templates', () => { + describe('authorization', async () => { + const fakePath = '/rendered/path/authorization'; + const expectedParameters = { + project: 'projectValue', + }; + const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.authorizationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.authorizationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('authorizationPath', () => { + const result = client.authorizationPath('projectValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.authorizationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromAuthorizationName', () => { + const result = client.matchProjectFromAuthorizationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.authorizationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('deployment', async () => { - const fakePath = "/rendered/path/deployment"; - const expectedParameters = { - project: "projectValue", - deployment: "deploymentValue", - }; - const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.deploymentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.deploymentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('deploymentPath', () => { - const result = client.deploymentPath("projectValue", "deploymentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.deploymentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromDeploymentName', () => { - const result = client.matchProjectFromDeploymentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.deploymentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDeploymentFromDeploymentName', () => { - const result = client.matchDeploymentFromDeploymentName(fakePath); - assert.strictEqual(result, "deploymentValue"); - assert((client.pathTemplates.deploymentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('deployment', async () => { + const fakePath = '/rendered/path/deployment'; + const expectedParameters = { + project: 'projectValue', + deployment: 'deploymentValue', + }; + const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.deploymentPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.deploymentPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('deploymentPath', () => { + const result = client.deploymentPath('projectValue', 'deploymentValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.deploymentPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromDeploymentName', () => { + const result = client.matchProjectFromDeploymentName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.deploymentPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchDeploymentFromDeploymentName', () => { + const result = client.matchDeploymentFromDeploymentName(fakePath); + assert.strictEqual(result, 'deploymentValue'); + assert( + (client.pathTemplates.deploymentPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('installStatus', async () => { - const fakePath = "/rendered/path/installStatus"; - const expectedParameters = { - project: "projectValue", - deployment: "deploymentValue", - }; - const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.installStatusPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.installStatusPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('installStatusPath', () => { - const result = client.installStatusPath("projectValue", "deploymentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.installStatusPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromInstallStatusName', () => { - const result = client.matchProjectFromInstallStatusName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.installStatusPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDeploymentFromInstallStatusName', () => { - const result = client.matchDeploymentFromInstallStatusName(fakePath); - assert.strictEqual(result, "deploymentValue"); - assert((client.pathTemplates.installStatusPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('installStatus', async () => { + const fakePath = '/rendered/path/installStatus'; + const expectedParameters = { + project: 'projectValue', + deployment: 'deploymentValue', + }; + const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.installStatusPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.installStatusPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('installStatusPath', () => { + const result = client.installStatusPath( + 'projectValue', + 'deploymentValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.installStatusPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromInstallStatusName', () => { + const result = client.matchProjectFromInstallStatusName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.installStatusPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchDeploymentFromInstallStatusName', () => { + const result = client.matchDeploymentFromInstallStatusName(fakePath); + assert.strictEqual(result, 'deploymentValue'); + assert( + (client.pathTemplates.installStatusPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('project', async () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new gsuiteaddonsModule.v1.GSuiteAddOnsClient({ - 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 gsuiteaddonsModule.v1.GSuiteAddOnsClient({ + 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-gsuiteaddons/webpack.config.js b/packages/google-cloud-gsuiteaddons/webpack.config.js index c35c996dd053..b973152f8079 100644 --- a/packages/google-cloud-gsuiteaddons/webpack.config.js +++ b/packages/google-cloud-gsuiteaddons/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-hypercomputecluster/.eslintignore b/packages/google-cloud-hypercomputecluster/.eslintignore new file mode 100644 index 000000000000..cfc348ec4d11 --- /dev/null +++ b/packages/google-cloud-hypercomputecluster/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/packages/google-cloud-hypercomputecluster/.eslintrc.json b/packages/google-cloud-hypercomputecluster/.eslintrc.json new file mode 100644 index 000000000000..3e8d97ccb390 --- /dev/null +++ b/packages/google-cloud-hypercomputecluster/.eslintrc.json @@ -0,0 +1,4 @@ +{ + "extends": "./node_modules/gts", + "root": true +} diff --git a/packages/google-cloud-hypercomputecluster/README.md b/packages/google-cloud-hypercomputecluster/README.md index aefdb5f07cd4..4cccbb177548 100644 --- a/packages/google-cloud-hypercomputecluster/README.md +++ b/packages/google-cloud-hypercomputecluster/README.md @@ -130,7 +130,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-hypercomputecluster/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`) @@ -140,7 +140,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-hypercomputecluster/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-hypercomputecluster/protos/protos.d.ts b/packages/google-cloud-hypercomputecluster/protos/protos.d.ts index e2004506e55f..2a68bad3c4a1 100644 --- a/packages/google-cloud-hypercomputecluster/protos/protos.d.ts +++ b/packages/google-cloud-hypercomputecluster/protos/protos.d.ts @@ -26827,6 +26827,9 @@ export namespace google { /** CommonLanguageSettings destinations */ destinations?: (google.api.ClientLibraryDestination[]|null); + + /** CommonLanguageSettings selectiveGapicGeneration */ + selectiveGapicGeneration?: (google.api.ISelectiveGapicGeneration|null); } /** Represents a CommonLanguageSettings. */ @@ -26844,6 +26847,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 @@ -27544,6 +27550,9 @@ export namespace google { /** PythonSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** PythonSettings experimentalFeatures */ + experimentalFeatures?: (google.api.PythonSettings.IExperimentalFeatures|null); } /** Represents a PythonSettings. */ @@ -27558,6 +27567,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 @@ -27636,6 +27648,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 { @@ -27962,6 +28086,9 @@ export namespace google { /** GoSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** GoSettings renamedServices */ + renamedServices?: ({ [k: string]: string }|null); } /** Represents a GoSettings. */ @@ -27976,6 +28103,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 @@ -28300,6 +28430,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, @@ -28330,6 +28563,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. */ @@ -28344,6 +28580,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 @@ -28434,6 +28673,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 { @@ -28790,6 +29126,7 @@ export namespace google { /** Edition enum. */ enum Edition { EDITION_UNKNOWN = 0, + EDITION_LEGACY = 900, EDITION_PROTO2 = 998, EDITION_PROTO3 = 999, EDITION_2023 = 1000, @@ -28820,6 +29157,9 @@ export namespace google { /** FileDescriptorProto weakDependency */ weakDependency?: (number[]|null); + /** FileDescriptorProto optionDependency */ + optionDependency?: (string[]|null); + /** FileDescriptorProto messageType */ messageType?: (google.protobuf.IDescriptorProto[]|null); @@ -28869,6 +29209,9 @@ export namespace google { /** FileDescriptorProto weakDependency. */ public weakDependency: number[]; + /** FileDescriptorProto optionDependency. */ + public optionDependency: string[]; + /** FileDescriptorProto messageType. */ public messageType: google.protobuf.IDescriptorProto[]; @@ -29003,6 +29346,9 @@ export namespace google { /** DescriptorProto reservedName */ reservedName?: (string[]|null); + + /** DescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents a DescriptorProto. */ @@ -29044,6 +29390,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 @@ -29891,6 +30240,9 @@ export namespace google { /** EnumDescriptorProto reservedName */ reservedName?: (string[]|null); + + /** EnumDescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents an EnumDescriptorProto. */ @@ -29917,6 +30269,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 @@ -30851,6 +31206,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); @@ -30909,6 +31267,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[]; @@ -31129,6 +31490,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. */ @@ -31367,6 +31843,9 @@ export namespace google { /** EnumValueOptions debugRedact */ debugRedact?: (boolean|null); + /** EnumValueOptions featureSupport */ + featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** EnumValueOptions uninterpretedOption */ uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); } @@ -31389,6 +31868,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[]; @@ -31981,6 +32463,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. */ @@ -32010,6 +32498,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 @@ -32132,6 +32626,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. */ @@ -32251,8 +32855,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. */ @@ -32267,8 +32874,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. @@ -32801,6 +33411,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-hypercomputecluster/protos/protos.js b/packages/google-cloud-hypercomputecluster/protos/protos.js index 63e3428982c2..25c16f5b54b7 100644 --- a/packages/google-cloud-hypercomputecluster/protos/protos.js +++ b/packages/google-cloud-hypercomputecluster/protos/protos.js @@ -66655,6 +66655,7 @@ * @interface ICommonLanguageSettings * @property {string|null} [referenceDocsUri] CommonLanguageSettings referenceDocsUri * @property {Array.|null} [destinations] CommonLanguageSettings destinations + * @property {google.api.ISelectiveGapicGeneration|null} [selectiveGapicGeneration] CommonLanguageSettings selectiveGapicGeneration */ /** @@ -66689,6 +66690,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 @@ -66721,6 +66730,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; }; @@ -66772,6 +66783,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; @@ -66823,6 +66838,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; }; @@ -66865,6 +66885,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; }; @@ -66883,8 +66908,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) { @@ -66892,6 +66919,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; }; @@ -68714,6 +68743,7 @@ * @memberof google.api * @interface IPythonSettings * @property {google.api.ICommonLanguageSettings|null} [common] PythonSettings common + * @property {google.api.PythonSettings.IExperimentalFeatures|null} [experimentalFeatures] PythonSettings experimentalFeatures */ /** @@ -68739,6 +68769,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 @@ -68765,6 +68803,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; }; @@ -68805,6 +68845,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; @@ -68845,6 +68889,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; }; @@ -68865,6 +68914,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; }; @@ -68881,10 +68935,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; }; @@ -68914,6 +68972,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; })(); @@ -69790,6 +70100,7 @@ * @memberof google.api * @interface IGoSettings * @property {google.api.ICommonLanguageSettings|null} [common] GoSettings common + * @property {Object.|null} [renamedServices] GoSettings renamedServices */ /** @@ -69801,6 +70112,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) @@ -69815,6 +70127,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 @@ -69841,6 +70161,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; }; @@ -69871,7 +70194,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) @@ -69881,6 +70204,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; @@ -69921,6 +70267,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; }; @@ -69941,6 +70295,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; }; @@ -69957,10 +70318,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; }; @@ -70599,29 +70968,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; })(); @@ -70660,6 +71274,7 @@ * @memberof google.api * @interface IFieldInfo * @property {google.api.FieldInfo.Format|null} [format] FieldInfo format + * @property {Array.|null} [referencedTypes] FieldInfo referencedTypes */ /** @@ -70671,6 +71286,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) @@ -70685,6 +71301,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 @@ -70711,6 +71335,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; }; @@ -70751,6 +71378,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; @@ -70797,6 +71430,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; }; @@ -70840,6 +71482,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; }; @@ -70856,10 +71508,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; }; @@ -70912,32 +71571,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) @@ -70945,48 +71596,261 @@ } /** - * ResourceDescriptor type. - * @member {string} type - * @memberof google.api.ResourceDescriptor + * TypeReference typeName. + * @member {string} typeName + * @memberof google.api.TypeReference * @instance */ - ResourceDescriptor.prototype.type = ""; + TypeReference.prototype.typeName = ""; /** - * ResourceDescriptor pattern. - * @member {Array.} pattern - * @memberof google.api.ResourceDescriptor - * @instance + * Creates a new TypeReference instance using the specified properties. + * @function create + * @memberof google.api.TypeReference + * @static + * @param {google.api.ITypeReference=} [properties] Properties to set + * @returns {google.api.TypeReference} TypeReference instance */ - ResourceDescriptor.prototype.pattern = $util.emptyArray; + TypeReference.create = function create(properties) { + return new TypeReference(properties); + }; /** - * ResourceDescriptor nameField. - * @member {string} nameField - * @memberof google.api.ResourceDescriptor - * @instance + * Encodes the specified TypeReference message. Does not implicitly {@link google.api.TypeReference.verify|verify} messages. + * @function encode + * @memberof google.api.TypeReference + * @static + * @param {google.api.ITypeReference} message TypeReference message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer */ - ResourceDescriptor.prototype.nameField = ""; + TypeReference.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.typeName != null && Object.hasOwnProperty.call(message, "typeName")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.typeName); + return writer; + }; /** - * ResourceDescriptor history. - * @member {google.api.ResourceDescriptor.History} history - * @memberof google.api.ResourceDescriptor - * @instance + * Encodes the specified TypeReference message, length delimited. Does not implicitly {@link google.api.TypeReference.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.TypeReference + * @static + * @param {google.api.ITypeReference} message TypeReference message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer */ - ResourceDescriptor.prototype.history = 0; + TypeReference.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; /** - * ResourceDescriptor plural. - * @member {string} plural - * @memberof google.api.ResourceDescriptor - * @instance + * Decodes a TypeReference message from the specified reader or buffer. + * @function decode + * @memberof google.api.TypeReference + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.TypeReference} TypeReference + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing */ - ResourceDescriptor.prototype.plural = ""; - - /** - * ResourceDescriptor singular. - * @member {string} singular + TypeReference.decode = function decode(reader, length, error) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.TypeReference(); + while (reader.pos < end) { + var tag = reader.uint32(); + if (tag === error) + break; + switch (tag >>> 3) { + case 1: { + message.typeName = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a TypeReference message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.TypeReference + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.TypeReference} TypeReference + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TypeReference.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a TypeReference message. + * @function verify + * @memberof google.api.TypeReference + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + TypeReference.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.typeName != null && message.hasOwnProperty("typeName")) + if (!$util.isString(message.typeName)) + return "typeName: string expected"; + return null; + }; + + /** + * Creates a TypeReference message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.TypeReference + * @static + * @param {Object.} object Plain object + * @returns {google.api.TypeReference} TypeReference + */ + TypeReference.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.TypeReference) + return object; + var message = new $root.google.api.TypeReference(); + if (object.typeName != null) + message.typeName = String(object.typeName); + return message; + }; + + /** + * Creates a plain object from a TypeReference message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.TypeReference + * @static + * @param {google.api.TypeReference} message TypeReference + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + TypeReference.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.typeName = ""; + if (message.typeName != null && message.hasOwnProperty("typeName")) + object.typeName = message.typeName; + return object; + }; + + /** + * Converts this TypeReference to JSON. + * @function toJSON + * @memberof google.api.TypeReference + * @instance + * @returns {Object.} JSON object + */ + TypeReference.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for TypeReference + * @function getTypeUrl + * @memberof google.api.TypeReference + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + TypeReference.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.TypeReference"; + }; + + return TypeReference; + })(); + + api.ResourceDescriptor = (function() { + + /** + * Properties of a ResourceDescriptor. + * @memberof google.api + * @interface IResourceDescriptor + * @property {string|null} [type] ResourceDescriptor type + * @property {Array.|null} [pattern] ResourceDescriptor pattern + * @property {string|null} [nameField] ResourceDescriptor nameField + * @property {google.api.ResourceDescriptor.History|null} [history] ResourceDescriptor history + * @property {string|null} [plural] ResourceDescriptor plural + * @property {string|null} [singular] ResourceDescriptor singular + * @property {Array.|null} [style] ResourceDescriptor style + */ + + /** + * Constructs a new ResourceDescriptor. + * @memberof google.api + * @classdesc Represents a ResourceDescriptor. + * @implements IResourceDescriptor + * @constructor + * @param {google.api.IResourceDescriptor=} [properties] Properties to set + */ + function ResourceDescriptor(properties) { + this.pattern = []; + this.style = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ResourceDescriptor type. + * @member {string} type + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.type = ""; + + /** + * ResourceDescriptor pattern. + * @member {Array.} pattern + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.pattern = $util.emptyArray; + + /** + * ResourceDescriptor nameField. + * @member {string} nameField + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.nameField = ""; + + /** + * ResourceDescriptor history. + * @member {google.api.ResourceDescriptor.History} history + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.history = 0; + + /** + * ResourceDescriptor plural. + * @member {string} plural + * @memberof google.api.ResourceDescriptor + * @instance + */ + ResourceDescriptor.prototype.plural = ""; + + /** + * ResourceDescriptor singular. + * @member {string} singular * @memberof google.api.ResourceDescriptor * @instance */ @@ -71843,6 +72707,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 @@ -71857,6 +72722,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; @@ -71881,6 +72747,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 @@ -71903,6 +72770,7 @@ this.dependency = []; this.publicDependency = []; this.weakDependency = []; + this.optionDependency = []; this.messageType = []; this.enumType = []; this.service = []; @@ -71953,6 +72821,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 @@ -72074,6 +72950,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; }; @@ -72146,6 +73025,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 = []; @@ -72248,6 +73133,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"; @@ -72302,6 +73194,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -72354,6 +73247,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"); @@ -72417,6 +73317,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -72482,6 +73386,7 @@ object.extension = []; object.publicDependency = []; object.weakDependency = []; + object.optionDependency = []; } if (options.defaults) { object.name = ""; @@ -72538,6 +73443,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; }; @@ -72586,6 +73496,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 */ /** @@ -72691,6 +73602,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 @@ -72743,6 +73662,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; }; @@ -72835,6 +73756,10 @@ message.reservedName.push(reader.string()); break; } + case 11: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -72948,6 +73873,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; }; @@ -73047,6 +73981,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; }; @@ -73076,6 +74030,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; @@ -73121,6 +74076,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; }; @@ -75165,6 +76122,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 */ /** @@ -75225,6 +76183,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 @@ -75262,6 +76228,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; }; @@ -75324,6 +76292,10 @@ message.reservedName.push(reader.string()); break; } + case 6: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -75392,6 +76364,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; }; @@ -75441,6 +76422,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; }; @@ -75465,6 +76466,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; @@ -75485,6 +76487,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; }; @@ -77803,6 +78807,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 @@ -77924,6 +78929,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 @@ -78006,6 +79019,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(); @@ -78109,6 +79124,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 = []; @@ -78248,6 +79267,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"; @@ -78441,6 +79465,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"); @@ -78543,6 +79572,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; } @@ -78576,6 +79606,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) @@ -78850,6 +79882,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -78891,103 +79924,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; @@ -79582,6 +81101,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 */ @@ -79625,6 +81145,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 @@ -79663,6 +81191,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(); @@ -79714,6 +81244,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 = []; @@ -79766,6 +81300,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"; @@ -79799,6 +81338,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"); @@ -79831,6 +81375,7 @@ object.deprecated = false; object.features = null; object.debugRedact = false; + object.featureSupport = null; } if (message.deprecated != null && message.hasOwnProperty("deprecated")) object.deprecated = message.deprecated; @@ -79838,6 +81383,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) @@ -81305,6 +82852,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 */ /** @@ -81370,6 +82919,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 @@ -81406,6 +82971,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; }; @@ -81466,6 +83035,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; @@ -81556,6 +83133,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; }; @@ -81695,6 +83292,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; }; @@ -81718,6 +83363,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; @@ -81731,6 +83378,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; }; @@ -81858,6 +83509,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; })(); @@ -82042,6 +83906,7 @@ default: return "minimumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -82059,6 +83924,7 @@ default: return "maximumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -82107,6 +83973,10 @@ case 0: message.minimumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.minimumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.minimumEdition = 998; @@ -82159,6 +84029,10 @@ case 0: message.maximumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.maximumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.maximumEdition = 998; @@ -82267,7 +84141,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 */ /** @@ -82294,12 +84169,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. @@ -82325,10 +84208,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; }; @@ -82369,8 +84254,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: @@ -82413,6 +84302,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -82425,10 +84315,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; }; @@ -82456,6 +84351,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -82497,10 +84396,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; }; @@ -82519,13 +84423,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; }; @@ -83740,6 +85647,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-hypercomputecluster/protos/protos.json b/packages/google-cloud-hypercomputecluster/protos/protos.json index 735aa088d8c2..5e66ed030770 100644 --- a/packages/google-cloud-hypercomputecluster/protos/protos.json +++ b/packages/google-cloud-hypercomputecluster/protos/protos.json @@ -7318,8 +7318,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": { @@ -7443,6 +7442,10 @@ "rule": "repeated", "type": "ClientLibraryDestination", "id": 2 + }, + "selectiveGapicGeneration": { + "type": "SelectiveGapicGeneration", + "id": 3 } } }, @@ -7583,6 +7586,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 + } + } } } }, @@ -7640,6 +7665,11 @@ "common": { "type": "CommonLanguageSettings", "id": 1 + }, + "renamedServices": { + "keyType": "string", + "type": "string", + "id": 2 } } }, @@ -7701,6 +7731,19 @@ "PACKAGE_MANAGER": 20 } }, + "SelectiveGapicGeneration": { + "fields": { + "methods": { + "rule": "repeated", + "type": "string", + "id": 1 + }, + "generateOmittedAsInternal": { + "type": "bool", + "id": 2 + } + } + }, "LaunchStage": { "values": { "LAUNCH_STAGE_UNSPECIFIED": 0, @@ -7745,6 +7788,11 @@ "format": { "type": "Format", "id": 1 + }, + "referencedTypes": { + "rule": "repeated", + "type": "TypeReference", + "id": 2 } }, "nested": { @@ -7759,6 +7807,14 @@ } } }, + "TypeReference": { + "fields": { + "typeName": { + "type": "string", + "id": 1 + } + } + }, "resourceReference": { "type": "google.api.ResourceReference", "id": 1055, @@ -7857,12 +7913,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, @@ -7901,6 +7964,11 @@ "type": "int32", "id": 11 }, + "optionDependency": { + "rule": "repeated", + "type": "string", + "id": 15 + }, "messageType": { "rule": "repeated", "type": "DescriptorProto", @@ -7989,6 +8057,10 @@ "rule": "repeated", "type": "string", "id": 10 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 11 } }, "nested": { @@ -8214,6 +8286,10 @@ "rule": "repeated", "type": "string", "id": 5 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 6 } }, "nested": { @@ -8264,7 +8340,14 @@ "type": "ServiceOptions", "id": 3 } - } + }, + "reserved": [ + [ + 4, + 4 + ], + "stream" + ] }, "MethodDescriptorProto": { "edition": "proto2", @@ -8428,6 +8511,7 @@ 42, 42 ], + "php_generic_services", [ 38, 38 @@ -8563,7 +8647,8 @@ "type": "bool", "id": 10, "options": { - "default": false + "default": false, + "deprecated": true } }, "debugRedact": { @@ -8591,6 +8676,10 @@ "type": "FeatureSet", "id": 21 }, + "featureSupport": { + "type": "FeatureSupport", + "id": 22 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -8660,6 +8749,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 + } + } } } }, @@ -8748,6 +8857,10 @@ "default": false } }, + "featureSupport": { + "type": "FieldOptions.FeatureSupport", + "id": 4 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -8890,6 +9003,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_2023", "edition_defaults.value": "EXPLICIT" } @@ -8900,6 +9014,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "OPEN" } @@ -8910,6 +9025,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "PACKED" } @@ -8920,6 +9036,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "VERIFY" } @@ -8930,7 +9047,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" } }, @@ -8940,27 +9058,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, @@ -9005,7 +9134,13 @@ "UTF8_VALIDATION_UNKNOWN": 0, "VERIFY": 2, "NONE": 3 - } + }, + "reserved": [ + [ + 1, + 1 + ] + ] }, "MessageEncoding": { "values": { @@ -9020,6 +9155,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 + } + } + } } } }, @@ -9047,11 +9209,26 @@ "type": "Edition", "id": 3 }, - "features": { + "overridableFeatures": { "type": "FeatureSet", - "id": 2 + "id": 4 + }, + "fixedFeatures": { + "type": "FeatureSet", + "id": 5 } - } + }, + "reserved": [ + [ + 1, + 1 + ], + [ + 2, + 2 + ], + "features" + ] } } }, @@ -9064,6 +9241,12 @@ "id": 1 } }, + "extensions": [ + [ + 536000000, + 536000000 + ] + ], "nested": { "Location": { "fields": { @@ -9149,6 +9332,14 @@ } } }, + "SymbolVisibility": { + "edition": "proto2", + "values": { + "VISIBILITY_UNSET": 0, + "VISIBILITY_LOCAL": 1, + "VISIBILITY_EXPORT": 2 + } + }, "Duration": { "fields": { "seconds": { @@ -9207,6 +9398,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-hypercomputecluster/samples/generated/v1/snippet_metadata_google.cloud.hypercomputecluster.v1.json b/packages/google-cloud-hypercomputecluster/samples/generated/v1/snippet_metadata_google.cloud.hypercomputecluster.v1.json index 301d6229359f..75d36ca24084 100644 --- a/packages/google-cloud-hypercomputecluster/samples/generated/v1/snippet_metadata_google.cloud.hypercomputecluster.v1.json +++ b/packages/google-cloud-hypercomputecluster/samples/generated/v1/snippet_metadata_google.cloud.hypercomputecluster.v1.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-hypercomputecluster", - "version": "0.2.0", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-hypercomputecluster/samples/generated/v1alpha/snippet_metadata_google.cloud.hypercomputecluster.v1alpha.json b/packages/google-cloud-hypercomputecluster/samples/generated/v1alpha/snippet_metadata_google.cloud.hypercomputecluster.v1alpha.json index 0de6b0627664..a33cc9b8846c 100644 --- a/packages/google-cloud-hypercomputecluster/samples/generated/v1alpha/snippet_metadata_google.cloud.hypercomputecluster.v1alpha.json +++ b/packages/google-cloud-hypercomputecluster/samples/generated/v1alpha/snippet_metadata_google.cloud.hypercomputecluster.v1alpha.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-hypercomputecluster", - "version": "0.2.0", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-hypercomputecluster/samples/generated/v1beta/snippet_metadata_google.cloud.hypercomputecluster.v1beta.json b/packages/google-cloud-hypercomputecluster/samples/generated/v1beta/snippet_metadata_google.cloud.hypercomputecluster.v1beta.json index 58512a0172ed..b9bdbb564283 100644 --- a/packages/google-cloud-hypercomputecluster/samples/generated/v1beta/snippet_metadata_google.cloud.hypercomputecluster.v1beta.json +++ b/packages/google-cloud-hypercomputecluster/samples/generated/v1beta/snippet_metadata_google.cloud.hypercomputecluster.v1beta.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-hypercomputecluster", - "version": "0.2.0", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-hypercomputecluster/src/v1/hypercompute_cluster_client.ts b/packages/google-cloud-hypercomputecluster/src/v1/hypercompute_cluster_client.ts index 83df75c16566..e4b5a06db1dd 100644 --- a/packages/google-cloud-hypercomputecluster/src/v1/hypercompute_cluster_client.ts +++ b/packages/google-cloud-hypercomputecluster/src/v1/hypercompute_cluster_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 HypercomputeClusterClient { 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('hypercomputecluster'); @@ -57,11 +68,11 @@ export class HypercomputeClusterClient { 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; - hypercomputeClusterStub?: Promise<{[name: string]: Function}>; + hypercomputeClusterStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of HypercomputeClusterClient. @@ -102,21 +113,42 @@ export class HypercomputeClusterClient { * const client = new HypercomputeClusterClient({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 HypercomputeClusterClient; - 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 = 'hypercomputecluster.' + 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 HypercomputeClusterClient { 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 HypercomputeClusterClient { } 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,34 +213,34 @@ export class HypercomputeClusterClient { // Create useful helper objects for these. this.pathTemplates = { bucketPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/buckets/{bucket}' + 'projects/{project}/buckets/{bucket}', ), clusterPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/clusters/{cluster}' + 'projects/{project}/locations/{location}/clusters/{cluster}', ), computeInstancePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/zones/{zone}/instances/{instance}' + 'projects/{project}/zones/{zone}/instances/{instance}', ), diskTypePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/zones/{zone}/diskTypes/{disk_type}' + 'projects/{project}/zones/{zone}/diskTypes/{disk_type}', ), fileInstancePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/instances/{instance}' + 'projects/{project}/locations/{location}/instances/{instance}', ), locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' + 'projects/{project}/locations/{location}', ), networkPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/global/networks/{network}' + 'projects/{project}/global/networks/{network}', ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' + 'projects/{project}', ), reservationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/zones/{zone}/reservations/{reservation}' + 'projects/{project}/zones/{zone}/reservations/{reservation}', ), subnetworkPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/regions/{region}/subnetworks/{subnetwork}' + 'projects/{project}/regions/{region}/subnetworks/{subnetwork}', ), }; @@ -220,8 +248,11 @@ export class HypercomputeClusterClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listClusters: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'clusters') + listClusters: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'clusters', + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -230,45 +261,85 @@ export class HypercomputeClusterClient { // 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 createClusterResponse = protoFilesRoot.lookup( - '.google.cloud.hypercomputecluster.v1.Cluster') as gax.protobuf.Type; + '.google.cloud.hypercomputecluster.v1.Cluster', + ) as gax.protobuf.Type; const createClusterMetadata = protoFilesRoot.lookup( - '.google.cloud.hypercomputecluster.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.hypercomputecluster.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateClusterResponse = protoFilesRoot.lookup( - '.google.cloud.hypercomputecluster.v1.Cluster') as gax.protobuf.Type; + '.google.cloud.hypercomputecluster.v1.Cluster', + ) as gax.protobuf.Type; const updateClusterMetadata = protoFilesRoot.lookup( - '.google.cloud.hypercomputecluster.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.hypercomputecluster.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteClusterResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteClusterMetadata = protoFilesRoot.lookup( - '.google.cloud.hypercomputecluster.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.hypercomputecluster.v1.OperationMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { createCluster: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createClusterResponse.decode.bind(createClusterResponse), - createClusterMetadata.decode.bind(createClusterMetadata)), + createClusterMetadata.decode.bind(createClusterMetadata), + ), updateCluster: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateClusterResponse.decode.bind(updateClusterResponse), - updateClusterMetadata.decode.bind(updateClusterMetadata)), + updateClusterMetadata.decode.bind(updateClusterMetadata), + ), deleteCluster: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteClusterResponse.decode.bind(deleteClusterResponse), - deleteClusterMetadata.decode.bind(deleteClusterMetadata)) + deleteClusterMetadata.decode.bind(deleteClusterMetadata), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.hypercomputecluster.v1.HypercomputeCluster', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.hypercomputecluster.v1.HypercomputeCluster', + 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 @@ -299,28 +370,40 @@ export class HypercomputeClusterClient { // Put together the "service stub" for // google.cloud.hypercomputecluster.v1.HypercomputeCluster. this.hypercomputeClusterStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.hypercomputecluster.v1.HypercomputeCluster') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.hypercomputecluster.v1.HypercomputeCluster, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.hypercomputecluster.v1.HypercomputeCluster', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.hypercomputecluster.v1 + .HypercomputeCluster, + 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 hypercomputeClusterStubMethods = - ['listClusters', 'getCluster', 'createCluster', 'updateCluster', 'deleteCluster']; + const hypercomputeClusterStubMethods = [ + 'listClusters', + 'getCluster', + 'createCluster', + 'updateCluster', + 'deleteCluster', + ]; for (const methodName of hypercomputeClusterStubMethods) { const callPromise = this.hypercomputeClusterStub.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] || @@ -330,7 +413,7 @@ export class HypercomputeClusterClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -345,8 +428,14 @@ export class HypercomputeClusterClient { * @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 'hypercomputecluster.googleapis.com'; } @@ -357,8 +446,14 @@ export class HypercomputeClusterClient { * @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 'hypercomputecluster.googleapis.com'; } @@ -389,9 +484,7 @@ export class HypercomputeClusterClient { * @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; @@ -400,8 +493,9 @@ export class HypercomputeClusterClient { * 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; @@ -412,546 +506,800 @@ export class HypercomputeClusterClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Gets details of a single Cluster. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the cluster to retrieve, in the format - * `projects/{project}/locations/{location}/clusters/{cluster}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.hypercomputecluster.v1.Cluster|Cluster}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/hypercompute_cluster.get_cluster.js - * region_tag:hypercomputecluster_v1_generated_HypercomputeCluster_GetCluster_async - */ + /** + * Gets details of a single Cluster. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the cluster to retrieve, in the format + * `projects/{project}/locations/{location}/clusters/{cluster}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.hypercomputecluster.v1.Cluster|Cluster}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/hypercompute_cluster.get_cluster.js + * region_tag:hypercomputecluster_v1_generated_HypercomputeCluster_GetCluster_async + */ getCluster( - request?: protos.google.cloud.hypercomputecluster.v1.IGetClusterRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.hypercomputecluster.v1.ICluster, - protos.google.cloud.hypercomputecluster.v1.IGetClusterRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.hypercomputecluster.v1.IGetClusterRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.hypercomputecluster.v1.ICluster, + protos.google.cloud.hypercomputecluster.v1.IGetClusterRequest | undefined, + {} | undefined, + ] + >; getCluster( - request: protos.google.cloud.hypercomputecluster.v1.IGetClusterRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.hypercomputecluster.v1.ICluster, - protos.google.cloud.hypercomputecluster.v1.IGetClusterRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.hypercomputecluster.v1.IGetClusterRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.hypercomputecluster.v1.ICluster, + | protos.google.cloud.hypercomputecluster.v1.IGetClusterRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getCluster( - request: protos.google.cloud.hypercomputecluster.v1.IGetClusterRequest, - callback: Callback< - protos.google.cloud.hypercomputecluster.v1.ICluster, - protos.google.cloud.hypercomputecluster.v1.IGetClusterRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.hypercomputecluster.v1.IGetClusterRequest, + callback: Callback< + protos.google.cloud.hypercomputecluster.v1.ICluster, + | protos.google.cloud.hypercomputecluster.v1.IGetClusterRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getCluster( - request?: protos.google.cloud.hypercomputecluster.v1.IGetClusterRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.hypercomputecluster.v1.ICluster, - protos.google.cloud.hypercomputecluster.v1.IGetClusterRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.hypercomputecluster.v1.IGetClusterRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.hypercomputecluster.v1.ICluster, - protos.google.cloud.hypercomputecluster.v1.IGetClusterRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.hypercomputecluster.v1.ICluster, - protos.google.cloud.hypercomputecluster.v1.IGetClusterRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.hypercomputecluster.v1.IGetClusterRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.hypercomputecluster.v1.ICluster, + | protos.google.cloud.hypercomputecluster.v1.IGetClusterRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.hypercomputecluster.v1.ICluster, + protos.google.cloud.hypercomputecluster.v1.IGetClusterRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getCluster request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.hypercomputecluster.v1.ICluster, - protos.google.cloud.hypercomputecluster.v1.IGetClusterRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.hypercomputecluster.v1.ICluster, + | protos.google.cloud.hypercomputecluster.v1.IGetClusterRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getCluster response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getCluster(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.hypercomputecluster.v1.ICluster, - protos.google.cloud.hypercomputecluster.v1.IGetClusterRequest|undefined, - {}|undefined - ]) => { - this._log.info('getCluster response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getCluster(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.hypercomputecluster.v1.ICluster, + ( + | protos.google.cloud.hypercomputecluster.v1.IGetClusterRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getCluster response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 Cluster in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent location in which the cluster should be created, in the - * format `projects/{project}/locations/{location}`. - * @param {string} request.clusterId - * Required. ID of the cluster to create. Must conform to - * [RFC-1034](https://datatracker.ietf.org/doc/html/rfc1034) (lower-case, - * alphanumeric, and at most 63 characters). - * @param {google.cloud.hypercomputecluster.v1.Cluster} request.cluster - * Required. Cluster to create. - * @param {string} [request.requestId] - * Optional. A unique identifier for this request. A random UUID is - * recommended. This request is idempotent if and only if `request_id` is - * provided. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/hypercompute_cluster.create_cluster.js - * region_tag:hypercomputecluster_v1_generated_HypercomputeCluster_CreateCluster_async - */ + /** + * Creates a new Cluster in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent location in which the cluster should be created, in the + * format `projects/{project}/locations/{location}`. + * @param {string} request.clusterId + * Required. ID of the cluster to create. Must conform to + * [RFC-1034](https://datatracker.ietf.org/doc/html/rfc1034) (lower-case, + * alphanumeric, and at most 63 characters). + * @param {google.cloud.hypercomputecluster.v1.Cluster} request.cluster + * Required. Cluster to create. + * @param {string} [request.requestId] + * Optional. A unique identifier for this request. A random UUID is + * recommended. This request is idempotent if and only if `request_id` is + * provided. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/hypercompute_cluster.create_cluster.js + * region_tag:hypercomputecluster_v1_generated_HypercomputeCluster_CreateCluster_async + */ createCluster( - request?: protos.google.cloud.hypercomputecluster.v1.ICreateClusterRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.hypercomputecluster.v1.ICreateClusterRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.hypercomputecluster.v1.ICluster, + protos.google.cloud.hypercomputecluster.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createCluster( - request: protos.google.cloud.hypercomputecluster.v1.ICreateClusterRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.hypercomputecluster.v1.ICreateClusterRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.hypercomputecluster.v1.ICluster, + protos.google.cloud.hypercomputecluster.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createCluster( - request: protos.google.cloud.hypercomputecluster.v1.ICreateClusterRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.hypercomputecluster.v1.ICreateClusterRequest, + callback: Callback< + LROperation< + protos.google.cloud.hypercomputecluster.v1.ICluster, + protos.google.cloud.hypercomputecluster.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createCluster( - request?: protos.google.cloud.hypercomputecluster.v1.ICreateClusterRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.hypercomputecluster.v1.ICreateClusterRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.hypercomputecluster.v1.ICluster, + protos.google.cloud.hypercomputecluster.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.hypercomputecluster.v1.ICluster, + protos.google.cloud.hypercomputecluster.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.hypercomputecluster.v1.ICluster, + protos.google.cloud.hypercomputecluster.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.hypercomputecluster.v1.ICluster, + protos.google.cloud.hypercomputecluster.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createCluster response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createCluster request %j', request); - return this.innerApiCalls.createCluster(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createCluster response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createCluster(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.hypercomputecluster.v1.ICluster, + protos.google.cloud.hypercomputecluster.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createCluster response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createCluster()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/hypercompute_cluster.create_cluster.js - * region_tag:hypercomputecluster_v1_generated_HypercomputeCluster_CreateCluster_async - */ - async checkCreateClusterProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createCluster()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/hypercompute_cluster.create_cluster.js + * region_tag:hypercomputecluster_v1_generated_HypercomputeCluster_CreateCluster_async + */ + async checkCreateClusterProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.hypercomputecluster.v1.Cluster, + protos.google.cloud.hypercomputecluster.v1.OperationMetadata + > + > { this._log.info('createCluster long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createCluster, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createCluster, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.hypercomputecluster.v1.Cluster, + protos.google.cloud.hypercomputecluster.v1.OperationMetadata + >; } -/** - * Updates the parameters of a single Cluster. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.hypercomputecluster.v1.Cluster} request.cluster - * Required. Cluster to update. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. Mask specifying which fields in the cluster to update. All paths - * must be specified explicitly - wildcards are not supported. At least one - * path must be provided. - * @param {string} [request.requestId] - * Optional. A unique identifier for this request. A random UUID is - * recommended. This request is idempotent if and only if `request_id` is - * provided. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/hypercompute_cluster.update_cluster.js - * region_tag:hypercomputecluster_v1_generated_HypercomputeCluster_UpdateCluster_async - */ + /** + * Updates the parameters of a single Cluster. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.hypercomputecluster.v1.Cluster} request.cluster + * Required. Cluster to update. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. Mask specifying which fields in the cluster to update. All paths + * must be specified explicitly - wildcards are not supported. At least one + * path must be provided. + * @param {string} [request.requestId] + * Optional. A unique identifier for this request. A random UUID is + * recommended. This request is idempotent if and only if `request_id` is + * provided. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/hypercompute_cluster.update_cluster.js + * region_tag:hypercomputecluster_v1_generated_HypercomputeCluster_UpdateCluster_async + */ updateCluster( - request?: protos.google.cloud.hypercomputecluster.v1.IUpdateClusterRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.hypercomputecluster.v1.IUpdateClusterRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.hypercomputecluster.v1.ICluster, + protos.google.cloud.hypercomputecluster.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateCluster( - request: protos.google.cloud.hypercomputecluster.v1.IUpdateClusterRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.hypercomputecluster.v1.IUpdateClusterRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.hypercomputecluster.v1.ICluster, + protos.google.cloud.hypercomputecluster.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateCluster( - request: protos.google.cloud.hypercomputecluster.v1.IUpdateClusterRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.hypercomputecluster.v1.IUpdateClusterRequest, + callback: Callback< + LROperation< + protos.google.cloud.hypercomputecluster.v1.ICluster, + protos.google.cloud.hypercomputecluster.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateCluster( - request?: protos.google.cloud.hypercomputecluster.v1.IUpdateClusterRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.hypercomputecluster.v1.IUpdateClusterRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.hypercomputecluster.v1.ICluster, + protos.google.cloud.hypercomputecluster.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.hypercomputecluster.v1.ICluster, + protos.google.cloud.hypercomputecluster.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.hypercomputecluster.v1.ICluster, + protos.google.cloud.hypercomputecluster.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({ - 'cluster.name': request.cluster!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'cluster.name': request.cluster!.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.hypercomputecluster.v1.ICluster, + protos.google.cloud.hypercomputecluster.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateCluster response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateCluster request %j', request); - return this.innerApiCalls.updateCluster(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateCluster response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateCluster(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.hypercomputecluster.v1.ICluster, + protos.google.cloud.hypercomputecluster.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateCluster response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateCluster()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/hypercompute_cluster.update_cluster.js - * region_tag:hypercomputecluster_v1_generated_HypercomputeCluster_UpdateCluster_async - */ - async checkUpdateClusterProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateCluster()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/hypercompute_cluster.update_cluster.js + * region_tag:hypercomputecluster_v1_generated_HypercomputeCluster_UpdateCluster_async + */ + async checkUpdateClusterProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.hypercomputecluster.v1.Cluster, + protos.google.cloud.hypercomputecluster.v1.OperationMetadata + > + > { this._log.info('updateCluster long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.updateCluster, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateCluster, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.hypercomputecluster.v1.Cluster, + protos.google.cloud.hypercomputecluster.v1.OperationMetadata + >; } -/** - * Deletes a single Cluster. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the cluster to delete, in the format - * `projects/{project}/locations/{location}/clusters/{cluster}`. - * @param {string} [request.requestId] - * Optional. A unique identifier for this request. A random UUID is - * recommended. This request is idempotent if and only if `request_id` is - * provided. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/hypercompute_cluster.delete_cluster.js - * region_tag:hypercomputecluster_v1_generated_HypercomputeCluster_DeleteCluster_async - */ + /** + * Deletes a single Cluster. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the cluster to delete, in the format + * `projects/{project}/locations/{location}/clusters/{cluster}`. + * @param {string} [request.requestId] + * Optional. A unique identifier for this request. A random UUID is + * recommended. This request is idempotent if and only if `request_id` is + * provided. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/hypercompute_cluster.delete_cluster.js + * region_tag:hypercomputecluster_v1_generated_HypercomputeCluster_DeleteCluster_async + */ deleteCluster( - request?: protos.google.cloud.hypercomputecluster.v1.IDeleteClusterRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.hypercomputecluster.v1.IDeleteClusterRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.hypercomputecluster.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteCluster( - request: protos.google.cloud.hypercomputecluster.v1.IDeleteClusterRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.hypercomputecluster.v1.IDeleteClusterRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.hypercomputecluster.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteCluster( - request: protos.google.cloud.hypercomputecluster.v1.IDeleteClusterRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.hypercomputecluster.v1.IDeleteClusterRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.hypercomputecluster.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteCluster( - request?: protos.google.cloud.hypercomputecluster.v1.IDeleteClusterRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.hypercomputecluster.v1.IDeleteClusterRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.hypercomputecluster.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.hypercomputecluster.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.hypercomputecluster.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.hypercomputecluster.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteCluster response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteCluster request %j', request); - return this.innerApiCalls.deleteCluster(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteCluster response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteCluster(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.hypercomputecluster.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteCluster response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteCluster()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/hypercompute_cluster.delete_cluster.js - * region_tag:hypercomputecluster_v1_generated_HypercomputeCluster_DeleteCluster_async - */ - async checkDeleteClusterProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteCluster()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/hypercompute_cluster.delete_cluster.js + * region_tag:hypercomputecluster_v1_generated_HypercomputeCluster_DeleteCluster_async + */ + async checkDeleteClusterProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.hypercomputecluster.v1.OperationMetadata + > + > { this._log.info('deleteCluster long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteCluster, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteCluster, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.hypercomputecluster.v1.OperationMetadata + >; } - /** - * Lists Clusters in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent location of the clusters to list, in the format - * `projects/{project}/locations/{location}`. - * @param {number} [request.pageSize] - * Optional. Maximum number of clusters to return. The service may return - * fewer than this value. - * @param {string} [request.pageToken] - * Optional. A page token received from a previous `ListClusters` call. - * Provide this to retrieve the subsequent page. When paginating, all other - * parameters provided to `ListClusters` must match the call that provided the - * page token. - * @param {string} [request.filter] - * Optional. [Filter](https://google.aip.dev/160) to apply to the returned - * results. - * @param {string} [request.orderBy] - * Optional. How to order the resulting clusters. Must be one of the following - * strings: - * - * * `name` - * * `name desc` - * * `create_time` - * * `create_time desc` - * - * If not specified, clusters will be returned in an arbitrary 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.hypercomputecluster.v1.Cluster|Cluster}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listClustersAsync()` - * method described below for async iteration which you can stop as 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 Clusters in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent location of the clusters to list, in the format + * `projects/{project}/locations/{location}`. + * @param {number} [request.pageSize] + * Optional. Maximum number of clusters to return. The service may return + * fewer than this value. + * @param {string} [request.pageToken] + * Optional. A page token received from a previous `ListClusters` call. + * Provide this to retrieve the subsequent page. When paginating, all other + * parameters provided to `ListClusters` must match the call that provided the + * page token. + * @param {string} [request.filter] + * Optional. [Filter](https://google.aip.dev/160) to apply to the returned + * results. + * @param {string} [request.orderBy] + * Optional. How to order the resulting clusters. Must be one of the following + * strings: + * + * * `name` + * * `name desc` + * * `create_time` + * * `create_time desc` + * + * If not specified, clusters will be returned in an arbitrary 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.hypercomputecluster.v1.Cluster|Cluster}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listClustersAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listClusters( - request?: protos.google.cloud.hypercomputecluster.v1.IListClustersRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.hypercomputecluster.v1.ICluster[], - protos.google.cloud.hypercomputecluster.v1.IListClustersRequest|null, - protos.google.cloud.hypercomputecluster.v1.IListClustersResponse - ]>; + request?: protos.google.cloud.hypercomputecluster.v1.IListClustersRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.hypercomputecluster.v1.ICluster[], + protos.google.cloud.hypercomputecluster.v1.IListClustersRequest | null, + protos.google.cloud.hypercomputecluster.v1.IListClustersResponse, + ] + >; listClusters( - request: protos.google.cloud.hypercomputecluster.v1.IListClustersRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.hypercomputecluster.v1.IListClustersRequest, - protos.google.cloud.hypercomputecluster.v1.IListClustersResponse|null|undefined, - protos.google.cloud.hypercomputecluster.v1.ICluster>): void; + request: protos.google.cloud.hypercomputecluster.v1.IListClustersRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.hypercomputecluster.v1.IListClustersRequest, + | protos.google.cloud.hypercomputecluster.v1.IListClustersResponse + | null + | undefined, + protos.google.cloud.hypercomputecluster.v1.ICluster + >, + ): void; listClusters( - request: protos.google.cloud.hypercomputecluster.v1.IListClustersRequest, - callback: PaginationCallback< - protos.google.cloud.hypercomputecluster.v1.IListClustersRequest, - protos.google.cloud.hypercomputecluster.v1.IListClustersResponse|null|undefined, - protos.google.cloud.hypercomputecluster.v1.ICluster>): void; + request: protos.google.cloud.hypercomputecluster.v1.IListClustersRequest, + callback: PaginationCallback< + protos.google.cloud.hypercomputecluster.v1.IListClustersRequest, + | protos.google.cloud.hypercomputecluster.v1.IListClustersResponse + | null + | undefined, + protos.google.cloud.hypercomputecluster.v1.ICluster + >, + ): void; listClusters( - request?: protos.google.cloud.hypercomputecluster.v1.IListClustersRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.hypercomputecluster.v1.IListClustersRequest, - protos.google.cloud.hypercomputecluster.v1.IListClustersResponse|null|undefined, - protos.google.cloud.hypercomputecluster.v1.ICluster>, - callback?: PaginationCallback< + request?: protos.google.cloud.hypercomputecluster.v1.IListClustersRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.hypercomputecluster.v1.IListClustersRequest, - protos.google.cloud.hypercomputecluster.v1.IListClustersResponse|null|undefined, - protos.google.cloud.hypercomputecluster.v1.ICluster>): - Promise<[ - protos.google.cloud.hypercomputecluster.v1.ICluster[], - protos.google.cloud.hypercomputecluster.v1.IListClustersRequest|null, - protos.google.cloud.hypercomputecluster.v1.IListClustersResponse - ]>|void { + | protos.google.cloud.hypercomputecluster.v1.IListClustersResponse + | null + | undefined, + protos.google.cloud.hypercomputecluster.v1.ICluster + >, + callback?: PaginationCallback< + protos.google.cloud.hypercomputecluster.v1.IListClustersRequest, + | protos.google.cloud.hypercomputecluster.v1.IListClustersResponse + | null + | undefined, + protos.google.cloud.hypercomputecluster.v1.ICluster + >, + ): Promise< + [ + protos.google.cloud.hypercomputecluster.v1.ICluster[], + protos.google.cloud.hypercomputecluster.v1.IListClustersRequest | null, + protos.google.cloud.hypercomputecluster.v1.IListClustersResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-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.hypercomputecluster.v1.IListClustersRequest, - protos.google.cloud.hypercomputecluster.v1.IListClustersResponse|null|undefined, - protos.google.cloud.hypercomputecluster.v1.ICluster>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.hypercomputecluster.v1.IListClustersRequest, + | protos.google.cloud.hypercomputecluster.v1.IListClustersResponse + | null + | undefined, + protos.google.cloud.hypercomputecluster.v1.ICluster + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listClusters values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -960,145 +1308,150 @@ export class HypercomputeClusterClient { this._log.info('listClusters request %j', request); return this.innerApiCalls .listClusters(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.hypercomputecluster.v1.ICluster[], - protos.google.cloud.hypercomputecluster.v1.IListClustersRequest|null, - protos.google.cloud.hypercomputecluster.v1.IListClustersResponse - ]) => { - this._log.info('listClusters values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.hypercomputecluster.v1.ICluster[], + protos.google.cloud.hypercomputecluster.v1.IListClustersRequest | null, + protos.google.cloud.hypercomputecluster.v1.IListClustersResponse, + ]) => { + this._log.info('listClusters values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listClusters`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent location of the clusters to list, in the format - * `projects/{project}/locations/{location}`. - * @param {number} [request.pageSize] - * Optional. Maximum number of clusters to return. The service may return - * fewer than this value. - * @param {string} [request.pageToken] - * Optional. A page token received from a previous `ListClusters` call. - * Provide this to retrieve the subsequent page. When paginating, all other - * parameters provided to `ListClusters` must match the call that provided the - * page token. - * @param {string} [request.filter] - * Optional. [Filter](https://google.aip.dev/160) to apply to the returned - * results. - * @param {string} [request.orderBy] - * Optional. How to order the resulting clusters. Must be one of the following - * strings: - * - * * `name` - * * `name desc` - * * `create_time` - * * `create_time desc` - * - * If not specified, clusters will be returned in an arbitrary 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.hypercomputecluster.v1.Cluster|Cluster} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listClustersAsync()` - * method described below for async iteration which you can stop as 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 `listClusters`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent location of the clusters to list, in the format + * `projects/{project}/locations/{location}`. + * @param {number} [request.pageSize] + * Optional. Maximum number of clusters to return. The service may return + * fewer than this value. + * @param {string} [request.pageToken] + * Optional. A page token received from a previous `ListClusters` call. + * Provide this to retrieve the subsequent page. When paginating, all other + * parameters provided to `ListClusters` must match the call that provided the + * page token. + * @param {string} [request.filter] + * Optional. [Filter](https://google.aip.dev/160) to apply to the returned + * results. + * @param {string} [request.orderBy] + * Optional. How to order the resulting clusters. Must be one of the following + * strings: + * + * * `name` + * * `name desc` + * * `create_time` + * * `create_time desc` + * + * If not specified, clusters will be returned in an arbitrary 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.hypercomputecluster.v1.Cluster|Cluster} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listClustersAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listClustersStream( - request?: protos.google.cloud.hypercomputecluster.v1.IListClustersRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.hypercomputecluster.v1.IListClustersRequest, + 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['listClusters']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listClusters stream %j', request); return this.descriptors.page.listClusters.createStream( this.innerApiCalls.listClusters as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listClusters`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used 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 location of the clusters to list, in the format - * `projects/{project}/locations/{location}`. - * @param {number} [request.pageSize] - * Optional. Maximum number of clusters to return. The service may return - * fewer than this value. - * @param {string} [request.pageToken] - * Optional. A page token received from a previous `ListClusters` call. - * Provide this to retrieve the subsequent page. When paginating, all other - * parameters provided to `ListClusters` must match the call that provided the - * page token. - * @param {string} [request.filter] - * Optional. [Filter](https://google.aip.dev/160) to apply to the returned - * results. - * @param {string} [request.orderBy] - * Optional. How to order the resulting clusters. Must be one of the following - * strings: - * - * * `name` - * * `name desc` - * * `create_time` - * * `create_time desc` - * - * If not specified, clusters will be returned in an arbitrary 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.hypercomputecluster.v1.Cluster|Cluster}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@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/hypercompute_cluster.list_clusters.js - * region_tag:hypercomputecluster_v1_generated_HypercomputeCluster_ListClusters_async - */ + /** + * Equivalent to `listClusters`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used 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 location of the clusters to list, in the format + * `projects/{project}/locations/{location}`. + * @param {number} [request.pageSize] + * Optional. Maximum number of clusters to return. The service may return + * fewer than this value. + * @param {string} [request.pageToken] + * Optional. A page token received from a previous `ListClusters` call. + * Provide this to retrieve the subsequent page. When paginating, all other + * parameters provided to `ListClusters` must match the call that provided the + * page token. + * @param {string} [request.filter] + * Optional. [Filter](https://google.aip.dev/160) to apply to the returned + * results. + * @param {string} [request.orderBy] + * Optional. How to order the resulting clusters. Must be one of the following + * strings: + * + * * `name` + * * `name desc` + * * `create_time` + * * `create_time desc` + * + * If not specified, clusters will be returned in an arbitrary 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.hypercomputecluster.v1.Cluster|Cluster}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@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/hypercompute_cluster.list_clusters.js + * region_tag:hypercomputecluster_v1_generated_HypercomputeCluster_ListClusters_async + */ listClustersAsync( - request?: protos.google.cloud.hypercomputecluster.v1.IListClustersRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.hypercomputecluster.v1.IListClustersRequest, + 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['listClusters']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listClusters iterate %j', request); return this.descriptors.page.listClusters.asyncIterate( this.innerApiCalls['listClusters'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** + + /** * Gets information about a location. * * @param {Object} request @@ -1133,12 +1486,11 @@ export class HypercomputeClusterClient { | 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. @@ -1171,12 +1523,12 @@ export class HypercomputeClusterClient { */ 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. @@ -1219,22 +1571,22 @@ export class HypercomputeClusterClient { 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); } /** @@ -1269,15 +1621,15 @@ export class HypercomputeClusterClient { */ 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); } /** @@ -1311,7 +1663,7 @@ export class HypercomputeClusterClient { * await client.cancelOperation({name: ''}); * ``` */ - cancelOperation( + cancelOperation( request: protos.google.longrunning.CancelOperationRequest, optionsOrCallback?: | gax.CallOptions @@ -1324,25 +1676,24 @@ export class HypercomputeClusterClient { 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 @@ -1381,22 +1732,22 @@ export class HypercomputeClusterClient { 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); } @@ -1411,7 +1762,7 @@ export class HypercomputeClusterClient { * @param {string} bucket * @returns {string} Resource name string. */ - bucketPath(project:string,bucket:string) { + bucketPath(project: string, bucket: string) { return this.pathTemplates.bucketPathTemplate.render({ project: project, bucket: bucket, @@ -1448,7 +1799,7 @@ export class HypercomputeClusterClient { * @param {string} cluster * @returns {string} Resource name string. */ - clusterPath(project:string,location:string,cluster:string) { + clusterPath(project: string, location: string, cluster: string) { return this.pathTemplates.clusterPathTemplate.render({ project: project, location: location, @@ -1497,7 +1848,7 @@ export class HypercomputeClusterClient { * @param {string} instance * @returns {string} Resource name string. */ - computeInstancePath(project:string,zone:string,instance:string) { + computeInstancePath(project: string, zone: string, instance: string) { return this.pathTemplates.computeInstancePathTemplate.render({ project: project, zone: zone, @@ -1513,7 +1864,9 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the project. */ matchProjectFromComputeInstanceName(computeInstanceName: string) { - return this.pathTemplates.computeInstancePathTemplate.match(computeInstanceName).project; + return this.pathTemplates.computeInstancePathTemplate.match( + computeInstanceName, + ).project; } /** @@ -1524,7 +1877,9 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the zone. */ matchZoneFromComputeInstanceName(computeInstanceName: string) { - return this.pathTemplates.computeInstancePathTemplate.match(computeInstanceName).zone; + return this.pathTemplates.computeInstancePathTemplate.match( + computeInstanceName, + ).zone; } /** @@ -1535,7 +1890,9 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the instance. */ matchInstanceFromComputeInstanceName(computeInstanceName: string) { - return this.pathTemplates.computeInstancePathTemplate.match(computeInstanceName).instance; + return this.pathTemplates.computeInstancePathTemplate.match( + computeInstanceName, + ).instance; } /** @@ -1546,7 +1903,7 @@ export class HypercomputeClusterClient { * @param {string} disk_type * @returns {string} Resource name string. */ - diskTypePath(project:string,zone:string,diskType:string) { + diskTypePath(project: string, zone: string, diskType: string) { return this.pathTemplates.diskTypePathTemplate.render({ project: project, zone: zone, @@ -1584,7 +1941,8 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the disk_type. */ matchDiskTypeFromDiskTypeName(diskTypeName: string) { - return this.pathTemplates.diskTypePathTemplate.match(diskTypeName).disk_type; + return this.pathTemplates.diskTypePathTemplate.match(diskTypeName) + .disk_type; } /** @@ -1595,7 +1953,7 @@ export class HypercomputeClusterClient { * @param {string} instance * @returns {string} Resource name string. */ - fileInstancePath(project:string,location:string,instance:string) { + fileInstancePath(project: string, location: string, instance: string) { return this.pathTemplates.fileInstancePathTemplate.render({ project: project, location: location, @@ -1611,7 +1969,8 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the project. */ matchProjectFromFileInstanceName(fileInstanceName: string) { - return this.pathTemplates.fileInstancePathTemplate.match(fileInstanceName).project; + return this.pathTemplates.fileInstancePathTemplate.match(fileInstanceName) + .project; } /** @@ -1622,7 +1981,8 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the location. */ matchLocationFromFileInstanceName(fileInstanceName: string) { - return this.pathTemplates.fileInstancePathTemplate.match(fileInstanceName).location; + return this.pathTemplates.fileInstancePathTemplate.match(fileInstanceName) + .location; } /** @@ -1633,7 +1993,8 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the instance. */ matchInstanceFromFileInstanceName(fileInstanceName: string) { - return this.pathTemplates.fileInstancePathTemplate.match(fileInstanceName).instance; + return this.pathTemplates.fileInstancePathTemplate.match(fileInstanceName) + .instance; } /** @@ -1643,7 +2004,7 @@ export class HypercomputeClusterClient { * @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, @@ -1679,7 +2040,7 @@ export class HypercomputeClusterClient { * @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, @@ -1714,7 +2075,7 @@ export class HypercomputeClusterClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -1739,7 +2100,7 @@ export class HypercomputeClusterClient { * @param {string} reservation * @returns {string} Resource name string. */ - reservationPath(project:string,zone:string,reservation:string) { + reservationPath(project: string, zone: string, reservation: string) { return this.pathTemplates.reservationPathTemplate.render({ project: project, zone: zone, @@ -1755,7 +2116,8 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the project. */ matchProjectFromReservationName(reservationName: string) { - return this.pathTemplates.reservationPathTemplate.match(reservationName).project; + return this.pathTemplates.reservationPathTemplate.match(reservationName) + .project; } /** @@ -1766,7 +2128,8 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the zone. */ matchZoneFromReservationName(reservationName: string) { - return this.pathTemplates.reservationPathTemplate.match(reservationName).zone; + return this.pathTemplates.reservationPathTemplate.match(reservationName) + .zone; } /** @@ -1777,7 +2140,8 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the reservation. */ matchReservationFromReservationName(reservationName: string) { - return this.pathTemplates.reservationPathTemplate.match(reservationName).reservation; + return this.pathTemplates.reservationPathTemplate.match(reservationName) + .reservation; } /** @@ -1788,7 +2152,7 @@ export class HypercomputeClusterClient { * @param {string} subnetwork * @returns {string} Resource name string. */ - subnetworkPath(project:string,region:string,subnetwork:string) { + subnetworkPath(project: string, region: string, subnetwork: string) { return this.pathTemplates.subnetworkPathTemplate.render({ project: project, region: region, @@ -1804,7 +2168,8 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the project. */ matchProjectFromSubnetworkName(subnetworkName: string) { - return this.pathTemplates.subnetworkPathTemplate.match(subnetworkName).project; + return this.pathTemplates.subnetworkPathTemplate.match(subnetworkName) + .project; } /** @@ -1815,7 +2180,8 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the region. */ matchRegionFromSubnetworkName(subnetworkName: string) { - return this.pathTemplates.subnetworkPathTemplate.match(subnetworkName).region; + return this.pathTemplates.subnetworkPathTemplate.match(subnetworkName) + .region; } /** @@ -1826,7 +2192,8 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the subnetwork. */ matchSubnetworkFromSubnetworkName(subnetworkName: string) { - return this.pathTemplates.subnetworkPathTemplate.match(subnetworkName).subnetwork; + return this.pathTemplates.subnetworkPathTemplate.match(subnetworkName) + .subnetwork; } /** @@ -1837,14 +2204,16 @@ export class HypercomputeClusterClient { */ close(): Promise { if (this.hypercomputeClusterStub && !this._terminated) { - return this.hypercomputeClusterStub.then(stub => { + return this.hypercomputeClusterStub.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-hypercomputecluster/src/v1/index.ts b/packages/google-cloud-hypercomputecluster/src/v1/index.ts index ee3f58bb3a68..9b93e8506ac2 100644 --- a/packages/google-cloud-hypercomputecluster/src/v1/index.ts +++ b/packages/google-cloud-hypercomputecluster/src/v1/index.ts @@ -16,4 +16,4 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {HypercomputeClusterClient} from './hypercompute_cluster_client'; +export { HypercomputeClusterClient } from './hypercompute_cluster_client'; diff --git a/packages/google-cloud-hypercomputecluster/src/v1alpha/hypercompute_cluster_client.ts b/packages/google-cloud-hypercomputecluster/src/v1alpha/hypercompute_cluster_client.ts index b73bb1e3e87b..b9c42d04e752 100644 --- a/packages/google-cloud-hypercomputecluster/src/v1alpha/hypercompute_cluster_client.ts +++ b/packages/google-cloud-hypercomputecluster/src/v1alpha/hypercompute_cluster_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 HypercomputeClusterClient { 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('hypercomputecluster'); @@ -57,11 +68,11 @@ export class HypercomputeClusterClient { 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; - hypercomputeClusterStub?: Promise<{[name: string]: Function}>; + hypercomputeClusterStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of HypercomputeClusterClient. @@ -102,21 +113,42 @@ export class HypercomputeClusterClient { * const client = new HypercomputeClusterClient({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 HypercomputeClusterClient; - 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 = 'hypercomputecluster.' + 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 HypercomputeClusterClient { 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 HypercomputeClusterClient { } 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,64 +213,64 @@ export class HypercomputeClusterClient { // Create useful helper objects for these. this.pathTemplates = { bucketPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/buckets/{bucket}' + 'projects/{project}/buckets/{bucket}', ), clusterPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/clusters/{cluster}' + 'projects/{project}/locations/{location}/clusters/{cluster}', ), computeInstancePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/zones/{zone}/instances/{instance}' + 'projects/{project}/zones/{zone}/instances/{instance}', ), diskTypePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/zones/{zone}/diskTypes/{disk_type}' + 'projects/{project}/zones/{zone}/diskTypes/{disk_type}', ), imagePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/global/images/{image}' + 'projects/{project}/global/images/{image}', ), instancePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/instances/{instance}' + 'projects/{project}/locations/{location}/instances/{instance}', ), locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' + 'projects/{project}/locations/{location}', ), machineLearningRunPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run}' + 'projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run}', ), monitoredEventPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run}/monitoredEvents/{monitored_event}' + 'projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run}/monitoredEvents/{monitored_event}', ), networkPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/global/networks/{network}' + 'projects/{project}/global/networks/{network}', ), nodePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/clusters/{cluster}/nodes/{node}' + 'projects/{project}/locations/{location}/clusters/{cluster}/nodes/{node}', ), podPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/clusters/{cluster}/k8s/namespaces/{namespace}/pods/{pod}' + 'projects/{project}/locations/{location}/clusters/{cluster}/k8s/namespaces/{namespace}/pods/{pod}', ), profileSessionPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run}/profileSessions/{profile_session}' + 'projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run}/profileSessions/{profile_session}', ), profilerSessionPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run}/profilerSessions/{profiler_session}' + 'projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run}/profilerSessions/{profiler_session}', ), profilerTargetPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run}/profilerTargets/{profiler_target}' + 'projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run}/profilerTargets/{profiler_target}', ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' + 'projects/{project}', ), reservationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/zones/{zone}/reservations/{reservation}' + 'projects/{project}/zones/{zone}/reservations/{reservation}', ), reservationBlockPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/zones/{zone}/reservations/{reservation}/reservationBlocks/{reservation_block}' + 'projects/{project}/zones/{zone}/reservations/{reservation}/reservationBlocks/{reservation_block}', ), reservationSubBlockPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/zones/{zone}/reservations/{reservation}/reservationBlocks/{reservation_block}/reservationSubBlocks/{reservation_sub_block}' + 'projects/{project}/zones/{zone}/reservations/{reservation}/reservationBlocks/{reservation_block}/reservationSubBlocks/{reservation_sub_block}', ), subnetworkPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/regions/{region}/subnetworks/{subnetwork}' + 'projects/{project}/regions/{region}/subnetworks/{subnetwork}', ), }; @@ -250,10 +278,16 @@ export class HypercomputeClusterClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listClusters: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'clusters'), - listNodes: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'nodes') + listClusters: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'clusters', + ), + listNodes: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'nodes', + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -262,45 +296,85 @@ export class HypercomputeClusterClient { // rather than holding a request open. const lroOptions: GrpcClientOptions = { auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1alpha/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1alpha/{name=projects/*}/locations',},{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1alpha/{name=projects/*/locations/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1alpha/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1alpha/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1alpha/{name=projects/*/locations/*}/operations',}]; + lroOptions.httpRules = [ + { + selector: 'google.cloud.location.Locations.GetLocation', + get: '/v1alpha/{name=projects/*/locations/*}', + }, + { + selector: 'google.cloud.location.Locations.ListLocations', + get: '/v1alpha/{name=projects/*}/locations', + }, + { + selector: 'google.longrunning.Operations.CancelOperation', + post: '/v1alpha/{name=projects/*/locations/*/operations/*}:cancel', + body: '*', + }, + { + selector: 'google.longrunning.Operations.DeleteOperation', + delete: '/v1alpha/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v1alpha/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v1alpha/{name=projects/*/locations/*}/operations', + }, + ]; } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); const createClusterResponse = protoFilesRoot.lookup( - '.google.cloud.hypercomputecluster.v1alpha.Cluster') as gax.protobuf.Type; + '.google.cloud.hypercomputecluster.v1alpha.Cluster', + ) as gax.protobuf.Type; const createClusterMetadata = protoFilesRoot.lookup( - '.google.cloud.hypercomputecluster.v1alpha.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.hypercomputecluster.v1alpha.OperationMetadata', + ) as gax.protobuf.Type; const updateClusterResponse = protoFilesRoot.lookup( - '.google.cloud.hypercomputecluster.v1alpha.Cluster') as gax.protobuf.Type; + '.google.cloud.hypercomputecluster.v1alpha.Cluster', + ) as gax.protobuf.Type; const updateClusterMetadata = protoFilesRoot.lookup( - '.google.cloud.hypercomputecluster.v1alpha.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.hypercomputecluster.v1alpha.OperationMetadata', + ) as gax.protobuf.Type; const deleteClusterResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteClusterMetadata = protoFilesRoot.lookup( - '.google.cloud.hypercomputecluster.v1alpha.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.hypercomputecluster.v1alpha.OperationMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { createCluster: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createClusterResponse.decode.bind(createClusterResponse), - createClusterMetadata.decode.bind(createClusterMetadata)), + createClusterMetadata.decode.bind(createClusterMetadata), + ), updateCluster: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateClusterResponse.decode.bind(updateClusterResponse), - updateClusterMetadata.decode.bind(updateClusterMetadata)), + updateClusterMetadata.decode.bind(updateClusterMetadata), + ), deleteCluster: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteClusterResponse.decode.bind(deleteClusterResponse), - deleteClusterMetadata.decode.bind(deleteClusterMetadata)) + deleteClusterMetadata.decode.bind(deleteClusterMetadata), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.hypercomputecluster.v1alpha.HypercomputeCluster', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.hypercomputecluster.v1alpha.HypercomputeCluster', + 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 @@ -331,28 +405,42 @@ export class HypercomputeClusterClient { // Put together the "service stub" for // google.cloud.hypercomputecluster.v1alpha.HypercomputeCluster. this.hypercomputeClusterStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.hypercomputecluster.v1alpha.HypercomputeCluster') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.hypercomputecluster.v1alpha.HypercomputeCluster, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.hypercomputecluster.v1alpha.HypercomputeCluster', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.hypercomputecluster.v1alpha + .HypercomputeCluster, + 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 hypercomputeClusterStubMethods = - ['listClusters', 'getCluster', 'createCluster', 'updateCluster', 'deleteCluster', 'getNode', 'listNodes']; + const hypercomputeClusterStubMethods = [ + 'listClusters', + 'getCluster', + 'createCluster', + 'updateCluster', + 'deleteCluster', + 'getNode', + 'listNodes', + ]; for (const methodName of hypercomputeClusterStubMethods) { const callPromise = this.hypercomputeClusterStub.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] || @@ -362,7 +450,7 @@ export class HypercomputeClusterClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -377,8 +465,14 @@ export class HypercomputeClusterClient { * @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 'hypercomputecluster.googleapis.com'; } @@ -389,8 +483,14 @@ export class HypercomputeClusterClient { * @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 'hypercomputecluster.googleapis.com'; } @@ -421,9 +521,7 @@ export class HypercomputeClusterClient { * @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; @@ -432,8 +530,9 @@ export class HypercomputeClusterClient { * 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; @@ -444,641 +543,950 @@ export class HypercomputeClusterClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Gets details of a single Cluster. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the cluster to retrieve, in the format - * `projects/{project}/locations/{location}/clusters/{cluster}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.hypercomputecluster.v1alpha.Cluster|Cluster}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/hypercompute_cluster.get_cluster.js - * region_tag:hypercomputecluster_v1alpha_generated_HypercomputeCluster_GetCluster_async - */ + /** + * Gets details of a single Cluster. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the cluster to retrieve, in the format + * `projects/{project}/locations/{location}/clusters/{cluster}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.hypercomputecluster.v1alpha.Cluster|Cluster}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/hypercompute_cluster.get_cluster.js + * region_tag:hypercomputecluster_v1alpha_generated_HypercomputeCluster_GetCluster_async + */ getCluster( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IGetClusterRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.hypercomputecluster.v1alpha.ICluster, - protos.google.cloud.hypercomputecluster.v1alpha.IGetClusterRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.hypercomputecluster.v1alpha.IGetClusterRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.hypercomputecluster.v1alpha.ICluster, + ( + | protos.google.cloud.hypercomputecluster.v1alpha.IGetClusterRequest + | undefined + ), + {} | undefined, + ] + >; getCluster( - request: protos.google.cloud.hypercomputecluster.v1alpha.IGetClusterRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.hypercomputecluster.v1alpha.ICluster, - protos.google.cloud.hypercomputecluster.v1alpha.IGetClusterRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.hypercomputecluster.v1alpha.IGetClusterRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.hypercomputecluster.v1alpha.ICluster, + | protos.google.cloud.hypercomputecluster.v1alpha.IGetClusterRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getCluster( - request: protos.google.cloud.hypercomputecluster.v1alpha.IGetClusterRequest, - callback: Callback< - protos.google.cloud.hypercomputecluster.v1alpha.ICluster, - protos.google.cloud.hypercomputecluster.v1alpha.IGetClusterRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.hypercomputecluster.v1alpha.IGetClusterRequest, + callback: Callback< + protos.google.cloud.hypercomputecluster.v1alpha.ICluster, + | protos.google.cloud.hypercomputecluster.v1alpha.IGetClusterRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getCluster( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IGetClusterRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.hypercomputecluster.v1alpha.ICluster, - protos.google.cloud.hypercomputecluster.v1alpha.IGetClusterRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.hypercomputecluster.v1alpha.IGetClusterRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.hypercomputecluster.v1alpha.ICluster, - protos.google.cloud.hypercomputecluster.v1alpha.IGetClusterRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.hypercomputecluster.v1alpha.ICluster, - protos.google.cloud.hypercomputecluster.v1alpha.IGetClusterRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.hypercomputecluster.v1alpha.IGetClusterRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.hypercomputecluster.v1alpha.ICluster, + | protos.google.cloud.hypercomputecluster.v1alpha.IGetClusterRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.hypercomputecluster.v1alpha.ICluster, + ( + | protos.google.cloud.hypercomputecluster.v1alpha.IGetClusterRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getCluster request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.hypercomputecluster.v1alpha.ICluster, - protos.google.cloud.hypercomputecluster.v1alpha.IGetClusterRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.hypercomputecluster.v1alpha.ICluster, + | protos.google.cloud.hypercomputecluster.v1alpha.IGetClusterRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getCluster response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getCluster(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.hypercomputecluster.v1alpha.ICluster, - protos.google.cloud.hypercomputecluster.v1alpha.IGetClusterRequest|undefined, - {}|undefined - ]) => { - this._log.info('getCluster response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getCluster(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.hypercomputecluster.v1alpha.ICluster, + ( + | protos.google.cloud.hypercomputecluster.v1alpha.IGetClusterRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getCluster response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 Node. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the node to retrieve, in the format - * `projects/{project}/locations/{location}/clusters/{cluster}/nodes/{node}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.hypercomputecluster.v1alpha.Node|Node}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/hypercompute_cluster.get_node.js - * region_tag:hypercomputecluster_v1alpha_generated_HypercomputeCluster_GetNode_async - */ + /** + * Gets details of a single Node. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the node to retrieve, in the format + * `projects/{project}/locations/{location}/clusters/{cluster}/nodes/{node}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.hypercomputecluster.v1alpha.Node|Node}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/hypercompute_cluster.get_node.js + * region_tag:hypercomputecluster_v1alpha_generated_HypercomputeCluster_GetNode_async + */ getNode( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IGetNodeRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.hypercomputecluster.v1alpha.INode, - protos.google.cloud.hypercomputecluster.v1alpha.IGetNodeRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.hypercomputecluster.v1alpha.IGetNodeRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.hypercomputecluster.v1alpha.INode, + ( + | protos.google.cloud.hypercomputecluster.v1alpha.IGetNodeRequest + | undefined + ), + {} | undefined, + ] + >; getNode( - request: protos.google.cloud.hypercomputecluster.v1alpha.IGetNodeRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.hypercomputecluster.v1alpha.INode, - protos.google.cloud.hypercomputecluster.v1alpha.IGetNodeRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.hypercomputecluster.v1alpha.IGetNodeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.hypercomputecluster.v1alpha.INode, + | protos.google.cloud.hypercomputecluster.v1alpha.IGetNodeRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getNode( - request: protos.google.cloud.hypercomputecluster.v1alpha.IGetNodeRequest, - callback: Callback< - protos.google.cloud.hypercomputecluster.v1alpha.INode, - protos.google.cloud.hypercomputecluster.v1alpha.IGetNodeRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.hypercomputecluster.v1alpha.IGetNodeRequest, + callback: Callback< + protos.google.cloud.hypercomputecluster.v1alpha.INode, + | protos.google.cloud.hypercomputecluster.v1alpha.IGetNodeRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getNode( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IGetNodeRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.hypercomputecluster.v1alpha.INode, - protos.google.cloud.hypercomputecluster.v1alpha.IGetNodeRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.hypercomputecluster.v1alpha.IGetNodeRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.hypercomputecluster.v1alpha.INode, - protos.google.cloud.hypercomputecluster.v1alpha.IGetNodeRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.hypercomputecluster.v1alpha.INode, - protos.google.cloud.hypercomputecluster.v1alpha.IGetNodeRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.hypercomputecluster.v1alpha.IGetNodeRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.hypercomputecluster.v1alpha.INode, + | protos.google.cloud.hypercomputecluster.v1alpha.IGetNodeRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.hypercomputecluster.v1alpha.INode, + ( + | protos.google.cloud.hypercomputecluster.v1alpha.IGetNodeRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getNode request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.hypercomputecluster.v1alpha.INode, - protos.google.cloud.hypercomputecluster.v1alpha.IGetNodeRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.hypercomputecluster.v1alpha.INode, + | protos.google.cloud.hypercomputecluster.v1alpha.IGetNodeRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getNode response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getNode(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.hypercomputecluster.v1alpha.INode, - protos.google.cloud.hypercomputecluster.v1alpha.IGetNodeRequest|undefined, - {}|undefined - ]) => { - this._log.info('getNode response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getNode(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.hypercomputecluster.v1alpha.INode, + ( + | protos.google.cloud.hypercomputecluster.v1alpha.IGetNodeRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getNode response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 Cluster in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent location in which the cluster should be created, in the - * format `projects/{project}/locations/{location}`. - * @param {string} request.clusterId - * Required. ID of the cluster to create. Must conform to - * [RFC-1034](https://datatracker.ietf.org/doc/html/rfc1034) (lower-case, - * alphanumeric, and at most 63 characters). - * @param {google.cloud.hypercomputecluster.v1alpha.Cluster} request.cluster - * Required. Cluster to create. - * @param {string} [request.requestId] - * Optional. A unique identifier for this request. A random UUID is - * recommended. This request is idempotent if and only if `request_id` is - * provided. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/hypercompute_cluster.create_cluster.js - * region_tag:hypercomputecluster_v1alpha_generated_HypercomputeCluster_CreateCluster_async - */ + /** + * Creates a new Cluster in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent location in which the cluster should be created, in the + * format `projects/{project}/locations/{location}`. + * @param {string} request.clusterId + * Required. ID of the cluster to create. Must conform to + * [RFC-1034](https://datatracker.ietf.org/doc/html/rfc1034) (lower-case, + * alphanumeric, and at most 63 characters). + * @param {google.cloud.hypercomputecluster.v1alpha.Cluster} request.cluster + * Required. Cluster to create. + * @param {string} [request.requestId] + * Optional. A unique identifier for this request. A random UUID is + * recommended. This request is idempotent if and only if `request_id` is + * provided. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/hypercompute_cluster.create_cluster.js + * region_tag:hypercomputecluster_v1alpha_generated_HypercomputeCluster_CreateCluster_async + */ createCluster( - request?: protos.google.cloud.hypercomputecluster.v1alpha.ICreateClusterRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.hypercomputecluster.v1alpha.ICreateClusterRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.ICluster, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createCluster( - request: protos.google.cloud.hypercomputecluster.v1alpha.ICreateClusterRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.hypercomputecluster.v1alpha.ICreateClusterRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.ICluster, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createCluster( - request: protos.google.cloud.hypercomputecluster.v1alpha.ICreateClusterRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.hypercomputecluster.v1alpha.ICreateClusterRequest, + callback: Callback< + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.ICluster, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createCluster( - request?: protos.google.cloud.hypercomputecluster.v1alpha.ICreateClusterRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.hypercomputecluster.v1alpha.ICreateClusterRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.ICluster, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.ICluster, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.ICluster, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.ICluster, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createCluster response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createCluster request %j', request); - return this.innerApiCalls.createCluster(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createCluster response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createCluster(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.ICluster, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createCluster response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createCluster()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/hypercompute_cluster.create_cluster.js - * region_tag:hypercomputecluster_v1alpha_generated_HypercomputeCluster_CreateCluster_async - */ - async checkCreateClusterProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createCluster()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/hypercompute_cluster.create_cluster.js + * region_tag:hypercomputecluster_v1alpha_generated_HypercomputeCluster_CreateCluster_async + */ + async checkCreateClusterProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.Cluster, + protos.google.cloud.hypercomputecluster.v1alpha.OperationMetadata + > + > { this._log.info('createCluster long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createCluster, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createCluster, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.Cluster, + protos.google.cloud.hypercomputecluster.v1alpha.OperationMetadata + >; } -/** - * Updates the parameters of a single Cluster. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.hypercomputecluster.v1alpha.Cluster} request.cluster - * Required. Cluster to update. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. Mask specifying which fields in the cluster to update. All paths - * must be specified explicitly - wildcards are not supported. At least one - * path must be provided. - * @param {string} [request.requestId] - * Optional. A unique identifier for this request. A random UUID is - * recommended. This request is idempotent if and only if `request_id` is - * provided. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/hypercompute_cluster.update_cluster.js - * region_tag:hypercomputecluster_v1alpha_generated_HypercomputeCluster_UpdateCluster_async - */ + /** + * Updates the parameters of a single Cluster. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.hypercomputecluster.v1alpha.Cluster} request.cluster + * Required. Cluster to update. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. Mask specifying which fields in the cluster to update. All paths + * must be specified explicitly - wildcards are not supported. At least one + * path must be provided. + * @param {string} [request.requestId] + * Optional. A unique identifier for this request. A random UUID is + * recommended. This request is idempotent if and only if `request_id` is + * provided. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/hypercompute_cluster.update_cluster.js + * region_tag:hypercomputecluster_v1alpha_generated_HypercomputeCluster_UpdateCluster_async + */ updateCluster( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IUpdateClusterRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.hypercomputecluster.v1alpha.IUpdateClusterRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.ICluster, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateCluster( - request: protos.google.cloud.hypercomputecluster.v1alpha.IUpdateClusterRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.hypercomputecluster.v1alpha.IUpdateClusterRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.ICluster, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateCluster( - request: protos.google.cloud.hypercomputecluster.v1alpha.IUpdateClusterRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.hypercomputecluster.v1alpha.IUpdateClusterRequest, + callback: Callback< + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.ICluster, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateCluster( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IUpdateClusterRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.hypercomputecluster.v1alpha.IUpdateClusterRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.ICluster, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.ICluster, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.ICluster, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'cluster.name': request.cluster!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'cluster.name': request.cluster!.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.hypercomputecluster.v1alpha.ICluster, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateCluster response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateCluster request %j', request); - return this.innerApiCalls.updateCluster(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateCluster response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateCluster(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.ICluster, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateCluster response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateCluster()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/hypercompute_cluster.update_cluster.js - * region_tag:hypercomputecluster_v1alpha_generated_HypercomputeCluster_UpdateCluster_async - */ - async checkUpdateClusterProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateCluster()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/hypercompute_cluster.update_cluster.js + * region_tag:hypercomputecluster_v1alpha_generated_HypercomputeCluster_UpdateCluster_async + */ + async checkUpdateClusterProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.Cluster, + protos.google.cloud.hypercomputecluster.v1alpha.OperationMetadata + > + > { this._log.info('updateCluster long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.updateCluster, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateCluster, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.Cluster, + protos.google.cloud.hypercomputecluster.v1alpha.OperationMetadata + >; } -/** - * Deletes a single Cluster. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the cluster to delete, in the format - * `projects/{project}/locations/{location}/clusters/{cluster}`. - * @param {string} [request.requestId] - * Optional. A unique identifier for this request. A random UUID is - * recommended. This request is idempotent if and only if `request_id` is - * provided. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/hypercompute_cluster.delete_cluster.js - * region_tag:hypercomputecluster_v1alpha_generated_HypercomputeCluster_DeleteCluster_async - */ + /** + * Deletes a single Cluster. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the cluster to delete, in the format + * `projects/{project}/locations/{location}/clusters/{cluster}`. + * @param {string} [request.requestId] + * Optional. A unique identifier for this request. A random UUID is + * recommended. This request is idempotent if and only if `request_id` is + * provided. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/hypercompute_cluster.delete_cluster.js + * region_tag:hypercomputecluster_v1alpha_generated_HypercomputeCluster_DeleteCluster_async + */ deleteCluster( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IDeleteClusterRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.hypercomputecluster.v1alpha.IDeleteClusterRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteCluster( - request: protos.google.cloud.hypercomputecluster.v1alpha.IDeleteClusterRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.hypercomputecluster.v1alpha.IDeleteClusterRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteCluster( - request: protos.google.cloud.hypercomputecluster.v1alpha.IDeleteClusterRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.hypercomputecluster.v1alpha.IDeleteClusterRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteCluster( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IDeleteClusterRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.hypercomputecluster.v1alpha.IDeleteClusterRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteCluster response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteCluster request %j', request); - return this.innerApiCalls.deleteCluster(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteCluster response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteCluster(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteCluster response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteCluster()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/hypercompute_cluster.delete_cluster.js - * region_tag:hypercomputecluster_v1alpha_generated_HypercomputeCluster_DeleteCluster_async - */ - async checkDeleteClusterProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteCluster()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/hypercompute_cluster.delete_cluster.js + * region_tag:hypercomputecluster_v1alpha_generated_HypercomputeCluster_DeleteCluster_async + */ + async checkDeleteClusterProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.hypercomputecluster.v1alpha.OperationMetadata + > + > { this._log.info('deleteCluster long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteCluster, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists Clusters in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent location of the clusters to list, in the format - * `projects/{project}/locations/{location}`. - * @param {number} [request.pageSize] - * Optional. Maximum number of clusters to return. The service may return - * fewer than this value. - * @param {string} [request.pageToken] - * Optional. A page token received from a previous `ListClusters` call. - * Provide this to retrieve the subsequent page. When paginating, all other - * parameters provided to `ListClusters` must match the call that provided the - * page token. - * @param {string} [request.filter] - * Optional. [Filter](https://google.aip.dev/160) to apply to the returned - * results. - * @param {string} [request.orderBy] - * Optional. How to order the resulting clusters. Must be one of the following - * strings: - * - * * `name` - * * `name desc` - * * `create_time` - * * `create_time desc` - * - * If not specified, clusters will be returned in an arbitrary 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.hypercomputecluster.v1alpha.Cluster|Cluster}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listClustersAsync()` - * method described below for async iteration which you can stop as 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.deleteCluster, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.hypercomputecluster.v1alpha.OperationMetadata + >; + } + /** + * Lists Clusters in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent location of the clusters to list, in the format + * `projects/{project}/locations/{location}`. + * @param {number} [request.pageSize] + * Optional. Maximum number of clusters to return. The service may return + * fewer than this value. + * @param {string} [request.pageToken] + * Optional. A page token received from a previous `ListClusters` call. + * Provide this to retrieve the subsequent page. When paginating, all other + * parameters provided to `ListClusters` must match the call that provided the + * page token. + * @param {string} [request.filter] + * Optional. [Filter](https://google.aip.dev/160) to apply to the returned + * results. + * @param {string} [request.orderBy] + * Optional. How to order the resulting clusters. Must be one of the following + * strings: + * + * * `name` + * * `name desc` + * * `create_time` + * * `create_time desc` + * + * If not specified, clusters will be returned in an arbitrary 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.hypercomputecluster.v1alpha.Cluster|Cluster}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listClustersAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listClusters( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IListClustersRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.hypercomputecluster.v1alpha.ICluster[], - protos.google.cloud.hypercomputecluster.v1alpha.IListClustersRequest|null, - protos.google.cloud.hypercomputecluster.v1alpha.IListClustersResponse - ]>; + request?: protos.google.cloud.hypercomputecluster.v1alpha.IListClustersRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.hypercomputecluster.v1alpha.ICluster[], + protos.google.cloud.hypercomputecluster.v1alpha.IListClustersRequest | null, + protos.google.cloud.hypercomputecluster.v1alpha.IListClustersResponse, + ] + >; listClusters( - request: protos.google.cloud.hypercomputecluster.v1alpha.IListClustersRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.hypercomputecluster.v1alpha.IListClustersRequest, - protos.google.cloud.hypercomputecluster.v1alpha.IListClustersResponse|null|undefined, - protos.google.cloud.hypercomputecluster.v1alpha.ICluster>): void; + request: protos.google.cloud.hypercomputecluster.v1alpha.IListClustersRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.hypercomputecluster.v1alpha.IListClustersRequest, + | protos.google.cloud.hypercomputecluster.v1alpha.IListClustersResponse + | null + | undefined, + protos.google.cloud.hypercomputecluster.v1alpha.ICluster + >, + ): void; listClusters( - request: protos.google.cloud.hypercomputecluster.v1alpha.IListClustersRequest, - callback: PaginationCallback< - protos.google.cloud.hypercomputecluster.v1alpha.IListClustersRequest, - protos.google.cloud.hypercomputecluster.v1alpha.IListClustersResponse|null|undefined, - protos.google.cloud.hypercomputecluster.v1alpha.ICluster>): void; + request: protos.google.cloud.hypercomputecluster.v1alpha.IListClustersRequest, + callback: PaginationCallback< + protos.google.cloud.hypercomputecluster.v1alpha.IListClustersRequest, + | protos.google.cloud.hypercomputecluster.v1alpha.IListClustersResponse + | null + | undefined, + protos.google.cloud.hypercomputecluster.v1alpha.ICluster + >, + ): void; listClusters( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IListClustersRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.hypercomputecluster.v1alpha.IListClustersRequest, - protos.google.cloud.hypercomputecluster.v1alpha.IListClustersResponse|null|undefined, - protos.google.cloud.hypercomputecluster.v1alpha.ICluster>, - callback?: PaginationCallback< + request?: protos.google.cloud.hypercomputecluster.v1alpha.IListClustersRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.hypercomputecluster.v1alpha.IListClustersRequest, - protos.google.cloud.hypercomputecluster.v1alpha.IListClustersResponse|null|undefined, - protos.google.cloud.hypercomputecluster.v1alpha.ICluster>): - Promise<[ - protos.google.cloud.hypercomputecluster.v1alpha.ICluster[], - protos.google.cloud.hypercomputecluster.v1alpha.IListClustersRequest|null, - protos.google.cloud.hypercomputecluster.v1alpha.IListClustersResponse - ]>|void { + | protos.google.cloud.hypercomputecluster.v1alpha.IListClustersResponse + | null + | undefined, + protos.google.cloud.hypercomputecluster.v1alpha.ICluster + >, + callback?: PaginationCallback< + protos.google.cloud.hypercomputecluster.v1alpha.IListClustersRequest, + | protos.google.cloud.hypercomputecluster.v1alpha.IListClustersResponse + | null + | undefined, + protos.google.cloud.hypercomputecluster.v1alpha.ICluster + >, + ): Promise< + [ + protos.google.cloud.hypercomputecluster.v1alpha.ICluster[], + protos.google.cloud.hypercomputecluster.v1alpha.IListClustersRequest | null, + protos.google.cloud.hypercomputecluster.v1alpha.IListClustersResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-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.hypercomputecluster.v1alpha.IListClustersRequest, - protos.google.cloud.hypercomputecluster.v1alpha.IListClustersResponse|null|undefined, - protos.google.cloud.hypercomputecluster.v1alpha.ICluster>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.hypercomputecluster.v1alpha.IListClustersRequest, + | protos.google.cloud.hypercomputecluster.v1alpha.IListClustersResponse + | null + | undefined, + protos.google.cloud.hypercomputecluster.v1alpha.ICluster + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listClusters values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1087,241 +1495,270 @@ export class HypercomputeClusterClient { this._log.info('listClusters request %j', request); return this.innerApiCalls .listClusters(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.hypercomputecluster.v1alpha.ICluster[], - protos.google.cloud.hypercomputecluster.v1alpha.IListClustersRequest|null, - protos.google.cloud.hypercomputecluster.v1alpha.IListClustersResponse - ]) => { - this._log.info('listClusters values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.hypercomputecluster.v1alpha.ICluster[], + protos.google.cloud.hypercomputecluster.v1alpha.IListClustersRequest | null, + protos.google.cloud.hypercomputecluster.v1alpha.IListClustersResponse, + ]) => { + this._log.info('listClusters values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listClusters`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent location of the clusters to list, in the format - * `projects/{project}/locations/{location}`. - * @param {number} [request.pageSize] - * Optional. Maximum number of clusters to return. The service may return - * fewer than this value. - * @param {string} [request.pageToken] - * Optional. A page token received from a previous `ListClusters` call. - * Provide this to retrieve the subsequent page. When paginating, all other - * parameters provided to `ListClusters` must match the call that provided the - * page token. - * @param {string} [request.filter] - * Optional. [Filter](https://google.aip.dev/160) to apply to the returned - * results. - * @param {string} [request.orderBy] - * Optional. How to order the resulting clusters. Must be one of the following - * strings: - * - * * `name` - * * `name desc` - * * `create_time` - * * `create_time desc` - * - * If not specified, clusters will be returned in an arbitrary 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.hypercomputecluster.v1alpha.Cluster|Cluster} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listClustersAsync()` - * method described below for async iteration which you can stop as 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 `listClusters`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent location of the clusters to list, in the format + * `projects/{project}/locations/{location}`. + * @param {number} [request.pageSize] + * Optional. Maximum number of clusters to return. The service may return + * fewer than this value. + * @param {string} [request.pageToken] + * Optional. A page token received from a previous `ListClusters` call. + * Provide this to retrieve the subsequent page. When paginating, all other + * parameters provided to `ListClusters` must match the call that provided the + * page token. + * @param {string} [request.filter] + * Optional. [Filter](https://google.aip.dev/160) to apply to the returned + * results. + * @param {string} [request.orderBy] + * Optional. How to order the resulting clusters. Must be one of the following + * strings: + * + * * `name` + * * `name desc` + * * `create_time` + * * `create_time desc` + * + * If not specified, clusters will be returned in an arbitrary 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.hypercomputecluster.v1alpha.Cluster|Cluster} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listClustersAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listClustersStream( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IListClustersRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.hypercomputecluster.v1alpha.IListClustersRequest, + 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['listClusters']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listClusters stream %j', request); return this.descriptors.page.listClusters.createStream( this.innerApiCalls.listClusters as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listClusters`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used 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 location of the clusters to list, in the format - * `projects/{project}/locations/{location}`. - * @param {number} [request.pageSize] - * Optional. Maximum number of clusters to return. The service may return - * fewer than this value. - * @param {string} [request.pageToken] - * Optional. A page token received from a previous `ListClusters` call. - * Provide this to retrieve the subsequent page. When paginating, all other - * parameters provided to `ListClusters` must match the call that provided the - * page token. - * @param {string} [request.filter] - * Optional. [Filter](https://google.aip.dev/160) to apply to the returned - * results. - * @param {string} [request.orderBy] - * Optional. How to order the resulting clusters. Must be one of the following - * strings: - * - * * `name` - * * `name desc` - * * `create_time` - * * `create_time desc` - * - * If not specified, clusters will be returned in an arbitrary 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.hypercomputecluster.v1alpha.Cluster|Cluster}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/hypercompute_cluster.list_clusters.js - * region_tag:hypercomputecluster_v1alpha_generated_HypercomputeCluster_ListClusters_async - */ + /** + * Equivalent to `listClusters`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used 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 location of the clusters to list, in the format + * `projects/{project}/locations/{location}`. + * @param {number} [request.pageSize] + * Optional. Maximum number of clusters to return. The service may return + * fewer than this value. + * @param {string} [request.pageToken] + * Optional. A page token received from a previous `ListClusters` call. + * Provide this to retrieve the subsequent page. When paginating, all other + * parameters provided to `ListClusters` must match the call that provided the + * page token. + * @param {string} [request.filter] + * Optional. [Filter](https://google.aip.dev/160) to apply to the returned + * results. + * @param {string} [request.orderBy] + * Optional. How to order the resulting clusters. Must be one of the following + * strings: + * + * * `name` + * * `name desc` + * * `create_time` + * * `create_time desc` + * + * If not specified, clusters will be returned in an arbitrary 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.hypercomputecluster.v1alpha.Cluster|Cluster}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/hypercompute_cluster.list_clusters.js + * region_tag:hypercomputecluster_v1alpha_generated_HypercomputeCluster_ListClusters_async + */ listClustersAsync( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IListClustersRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.hypercomputecluster.v1alpha.IListClustersRequest, + 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['listClusters']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listClusters iterate %j', request); return this.descriptors.page.listClusters.asyncIterate( this.innerApiCalls['listClusters'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists Nodes in a given cluster. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent cluster of the nodes to list, in the format - * `projects/{project}/locations/{location}/clusters/{cluster}`. - * @param {number} [request.pageSize] - * Optional. Maximum number of nodes to return. The service may return fewer - * than this value. - * @param {string} [request.pageToken] - * Optional. A page token received from a previous `ListNodes` call. Provide - * this to retrieve the subsequent page. When paginating, all other parameters - * provided to `ListNodes` must match the call that provided the page - * token. - * @param {string} [request.filter] - * Optional. [Filter](https://google.aip.dev/160) to apply to the returned - * results. - * @param {string} [request.orderBy] - * Optional. How to order the resulting nodes. Must be one of the following - * strings: - * - * * `name` - * * `name desc` - * - * If not specified, nodes will be returned in an arbitrary 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.hypercomputecluster.v1alpha.Node|Node}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listNodesAsync()` - * method described below for async iteration which you can stop as 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 Nodes in a given cluster. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent cluster of the nodes to list, in the format + * `projects/{project}/locations/{location}/clusters/{cluster}`. + * @param {number} [request.pageSize] + * Optional. Maximum number of nodes to return. The service may return fewer + * than this value. + * @param {string} [request.pageToken] + * Optional. A page token received from a previous `ListNodes` call. Provide + * this to retrieve the subsequent page. When paginating, all other parameters + * provided to `ListNodes` must match the call that provided the page + * token. + * @param {string} [request.filter] + * Optional. [Filter](https://google.aip.dev/160) to apply to the returned + * results. + * @param {string} [request.orderBy] + * Optional. How to order the resulting nodes. Must be one of the following + * strings: + * + * * `name` + * * `name desc` + * + * If not specified, nodes will be returned in an arbitrary 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.hypercomputecluster.v1alpha.Node|Node}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listNodesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listNodes( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IListNodesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.hypercomputecluster.v1alpha.INode[], - protos.google.cloud.hypercomputecluster.v1alpha.IListNodesRequest|null, - protos.google.cloud.hypercomputecluster.v1alpha.IListNodesResponse - ]>; + request?: protos.google.cloud.hypercomputecluster.v1alpha.IListNodesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.hypercomputecluster.v1alpha.INode[], + protos.google.cloud.hypercomputecluster.v1alpha.IListNodesRequest | null, + protos.google.cloud.hypercomputecluster.v1alpha.IListNodesResponse, + ] + >; listNodes( - request: protos.google.cloud.hypercomputecluster.v1alpha.IListNodesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.hypercomputecluster.v1alpha.IListNodesRequest, - protos.google.cloud.hypercomputecluster.v1alpha.IListNodesResponse|null|undefined, - protos.google.cloud.hypercomputecluster.v1alpha.INode>): void; + request: protos.google.cloud.hypercomputecluster.v1alpha.IListNodesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.hypercomputecluster.v1alpha.IListNodesRequest, + | protos.google.cloud.hypercomputecluster.v1alpha.IListNodesResponse + | null + | undefined, + protos.google.cloud.hypercomputecluster.v1alpha.INode + >, + ): void; listNodes( - request: protos.google.cloud.hypercomputecluster.v1alpha.IListNodesRequest, - callback: PaginationCallback< - protos.google.cloud.hypercomputecluster.v1alpha.IListNodesRequest, - protos.google.cloud.hypercomputecluster.v1alpha.IListNodesResponse|null|undefined, - protos.google.cloud.hypercomputecluster.v1alpha.INode>): void; + request: protos.google.cloud.hypercomputecluster.v1alpha.IListNodesRequest, + callback: PaginationCallback< + protos.google.cloud.hypercomputecluster.v1alpha.IListNodesRequest, + | protos.google.cloud.hypercomputecluster.v1alpha.IListNodesResponse + | null + | undefined, + protos.google.cloud.hypercomputecluster.v1alpha.INode + >, + ): void; listNodes( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IListNodesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.hypercomputecluster.v1alpha.IListNodesRequest, - protos.google.cloud.hypercomputecluster.v1alpha.IListNodesResponse|null|undefined, - protos.google.cloud.hypercomputecluster.v1alpha.INode>, - callback?: PaginationCallback< + request?: protos.google.cloud.hypercomputecluster.v1alpha.IListNodesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.hypercomputecluster.v1alpha.IListNodesRequest, - protos.google.cloud.hypercomputecluster.v1alpha.IListNodesResponse|null|undefined, - protos.google.cloud.hypercomputecluster.v1alpha.INode>): - Promise<[ - protos.google.cloud.hypercomputecluster.v1alpha.INode[], - protos.google.cloud.hypercomputecluster.v1alpha.IListNodesRequest|null, - protos.google.cloud.hypercomputecluster.v1alpha.IListNodesResponse - ]>|void { + | protos.google.cloud.hypercomputecluster.v1alpha.IListNodesResponse + | null + | undefined, + protos.google.cloud.hypercomputecluster.v1alpha.INode + >, + callback?: PaginationCallback< + protos.google.cloud.hypercomputecluster.v1alpha.IListNodesRequest, + | protos.google.cloud.hypercomputecluster.v1alpha.IListNodesResponse + | null + | undefined, + protos.google.cloud.hypercomputecluster.v1alpha.INode + >, + ): Promise< + [ + protos.google.cloud.hypercomputecluster.v1alpha.INode[], + protos.google.cloud.hypercomputecluster.v1alpha.IListNodesRequest | null, + protos.google.cloud.hypercomputecluster.v1alpha.IListNodesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-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.hypercomputecluster.v1alpha.IListNodesRequest, - protos.google.cloud.hypercomputecluster.v1alpha.IListNodesResponse|null|undefined, - protos.google.cloud.hypercomputecluster.v1alpha.INode>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.hypercomputecluster.v1alpha.IListNodesRequest, + | protos.google.cloud.hypercomputecluster.v1alpha.IListNodesResponse + | null + | undefined, + protos.google.cloud.hypercomputecluster.v1alpha.INode + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listNodes values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1330,141 +1767,146 @@ export class HypercomputeClusterClient { this._log.info('listNodes request %j', request); return this.innerApiCalls .listNodes(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.hypercomputecluster.v1alpha.INode[], - protos.google.cloud.hypercomputecluster.v1alpha.IListNodesRequest|null, - protos.google.cloud.hypercomputecluster.v1alpha.IListNodesResponse - ]) => { - this._log.info('listNodes values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.hypercomputecluster.v1alpha.INode[], + protos.google.cloud.hypercomputecluster.v1alpha.IListNodesRequest | null, + protos.google.cloud.hypercomputecluster.v1alpha.IListNodesResponse, + ]) => { + this._log.info('listNodes values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listNodes`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent cluster of the nodes to list, in the format - * `projects/{project}/locations/{location}/clusters/{cluster}`. - * @param {number} [request.pageSize] - * Optional. Maximum number of nodes to return. The service may return fewer - * than this value. - * @param {string} [request.pageToken] - * Optional. A page token received from a previous `ListNodes` call. Provide - * this to retrieve the subsequent page. When paginating, all other parameters - * provided to `ListNodes` must match the call that provided the page - * token. - * @param {string} [request.filter] - * Optional. [Filter](https://google.aip.dev/160) to apply to the returned - * results. - * @param {string} [request.orderBy] - * Optional. How to order the resulting nodes. Must be one of the following - * strings: - * - * * `name` - * * `name desc` - * - * If not specified, nodes will be returned in an arbitrary 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.hypercomputecluster.v1alpha.Node|Node} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listNodesAsync()` - * method described below for async iteration which you can stop as 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 `listNodes`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent cluster of the nodes to list, in the format + * `projects/{project}/locations/{location}/clusters/{cluster}`. + * @param {number} [request.pageSize] + * Optional. Maximum number of nodes to return. The service may return fewer + * than this value. + * @param {string} [request.pageToken] + * Optional. A page token received from a previous `ListNodes` call. Provide + * this to retrieve the subsequent page. When paginating, all other parameters + * provided to `ListNodes` must match the call that provided the page + * token. + * @param {string} [request.filter] + * Optional. [Filter](https://google.aip.dev/160) to apply to the returned + * results. + * @param {string} [request.orderBy] + * Optional. How to order the resulting nodes. Must be one of the following + * strings: + * + * * `name` + * * `name desc` + * + * If not specified, nodes will be returned in an arbitrary 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.hypercomputecluster.v1alpha.Node|Node} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listNodesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listNodesStream( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IListNodesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.hypercomputecluster.v1alpha.IListNodesRequest, + 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['listNodes']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listNodes stream %j', request); return this.descriptors.page.listNodes.createStream( this.innerApiCalls.listNodes as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listNodes`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used 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 cluster of the nodes to list, in the format - * `projects/{project}/locations/{location}/clusters/{cluster}`. - * @param {number} [request.pageSize] - * Optional. Maximum number of nodes to return. The service may return fewer - * than this value. - * @param {string} [request.pageToken] - * Optional. A page token received from a previous `ListNodes` call. Provide - * this to retrieve the subsequent page. When paginating, all other parameters - * provided to `ListNodes` must match the call that provided the page - * token. - * @param {string} [request.filter] - * Optional. [Filter](https://google.aip.dev/160) to apply to the returned - * results. - * @param {string} [request.orderBy] - * Optional. How to order the resulting nodes. Must be one of the following - * strings: - * - * * `name` - * * `name desc` - * - * If not specified, nodes will be returned in an arbitrary 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.hypercomputecluster.v1alpha.Node|Node}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/hypercompute_cluster.list_nodes.js - * region_tag:hypercomputecluster_v1alpha_generated_HypercomputeCluster_ListNodes_async - */ + /** + * Equivalent to `listNodes`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used 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 cluster of the nodes to list, in the format + * `projects/{project}/locations/{location}/clusters/{cluster}`. + * @param {number} [request.pageSize] + * Optional. Maximum number of nodes to return. The service may return fewer + * than this value. + * @param {string} [request.pageToken] + * Optional. A page token received from a previous `ListNodes` call. Provide + * this to retrieve the subsequent page. When paginating, all other parameters + * provided to `ListNodes` must match the call that provided the page + * token. + * @param {string} [request.filter] + * Optional. [Filter](https://google.aip.dev/160) to apply to the returned + * results. + * @param {string} [request.orderBy] + * Optional. How to order the resulting nodes. Must be one of the following + * strings: + * + * * `name` + * * `name desc` + * + * If not specified, nodes will be returned in an arbitrary 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.hypercomputecluster.v1alpha.Node|Node}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/hypercompute_cluster.list_nodes.js + * region_tag:hypercomputecluster_v1alpha_generated_HypercomputeCluster_ListNodes_async + */ listNodesAsync( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IListNodesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.hypercomputecluster.v1alpha.IListNodesRequest, + 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['listNodes']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listNodes iterate %j', request); return this.descriptors.page.listNodes.asyncIterate( this.innerApiCalls['listNodes'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** + + /** * Gets information about a location. * * @param {Object} request @@ -1499,12 +1941,11 @@ export class HypercomputeClusterClient { | 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. @@ -1537,12 +1978,12 @@ export class HypercomputeClusterClient { */ 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. @@ -1585,22 +2026,22 @@ export class HypercomputeClusterClient { 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); } /** @@ -1635,15 +2076,15 @@ export class HypercomputeClusterClient { */ 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); } /** @@ -1677,7 +2118,7 @@ export class HypercomputeClusterClient { * await client.cancelOperation({name: ''}); * ``` */ - cancelOperation( + cancelOperation( request: protos.google.longrunning.CancelOperationRequest, optionsOrCallback?: | gax.CallOptions @@ -1690,25 +2131,24 @@ export class HypercomputeClusterClient { 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 @@ -1747,22 +2187,22 @@ export class HypercomputeClusterClient { 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); } @@ -1777,7 +2217,7 @@ export class HypercomputeClusterClient { * @param {string} bucket * @returns {string} Resource name string. */ - bucketPath(project:string,bucket:string) { + bucketPath(project: string, bucket: string) { return this.pathTemplates.bucketPathTemplate.render({ project: project, bucket: bucket, @@ -1814,7 +2254,7 @@ export class HypercomputeClusterClient { * @param {string} cluster * @returns {string} Resource name string. */ - clusterPath(project:string,location:string,cluster:string) { + clusterPath(project: string, location: string, cluster: string) { return this.pathTemplates.clusterPathTemplate.render({ project: project, location: location, @@ -1863,7 +2303,7 @@ export class HypercomputeClusterClient { * @param {string} instance * @returns {string} Resource name string. */ - computeInstancePath(project:string,zone:string,instance:string) { + computeInstancePath(project: string, zone: string, instance: string) { return this.pathTemplates.computeInstancePathTemplate.render({ project: project, zone: zone, @@ -1879,7 +2319,9 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the project. */ matchProjectFromComputeInstanceName(computeInstanceName: string) { - return this.pathTemplates.computeInstancePathTemplate.match(computeInstanceName).project; + return this.pathTemplates.computeInstancePathTemplate.match( + computeInstanceName, + ).project; } /** @@ -1890,7 +2332,9 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the zone. */ matchZoneFromComputeInstanceName(computeInstanceName: string) { - return this.pathTemplates.computeInstancePathTemplate.match(computeInstanceName).zone; + return this.pathTemplates.computeInstancePathTemplate.match( + computeInstanceName, + ).zone; } /** @@ -1901,7 +2345,9 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the instance. */ matchInstanceFromComputeInstanceName(computeInstanceName: string) { - return this.pathTemplates.computeInstancePathTemplate.match(computeInstanceName).instance; + return this.pathTemplates.computeInstancePathTemplate.match( + computeInstanceName, + ).instance; } /** @@ -1912,7 +2358,7 @@ export class HypercomputeClusterClient { * @param {string} disk_type * @returns {string} Resource name string. */ - diskTypePath(project:string,zone:string,diskType:string) { + diskTypePath(project: string, zone: string, diskType: string) { return this.pathTemplates.diskTypePathTemplate.render({ project: project, zone: zone, @@ -1950,7 +2396,8 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the disk_type. */ matchDiskTypeFromDiskTypeName(diskTypeName: string) { - return this.pathTemplates.diskTypePathTemplate.match(diskTypeName).disk_type; + return this.pathTemplates.diskTypePathTemplate.match(diskTypeName) + .disk_type; } /** @@ -1960,7 +2407,7 @@ export class HypercomputeClusterClient { * @param {string} image * @returns {string} Resource name string. */ - imagePath(project:string,image:string) { + imagePath(project: string, image: string) { return this.pathTemplates.imagePathTemplate.render({ project: project, image: image, @@ -1997,7 +2444,7 @@ export class HypercomputeClusterClient { * @param {string} instance * @returns {string} Resource name string. */ - instancePath(project:string,location:string,instance:string) { + instancePath(project: string, location: string, instance: string) { return this.pathTemplates.instancePathTemplate.render({ project: project, location: location, @@ -2045,7 +2492,7 @@ export class HypercomputeClusterClient { * @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, @@ -2082,7 +2529,11 @@ export class HypercomputeClusterClient { * @param {string} machine_learning_run * @returns {string} Resource name string. */ - machineLearningRunPath(project:string,location:string,machineLearningRun:string) { + machineLearningRunPath( + project: string, + location: string, + machineLearningRun: string, + ) { return this.pathTemplates.machineLearningRunPathTemplate.render({ project: project, location: location, @@ -2098,7 +2549,9 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the project. */ matchProjectFromMachineLearningRunName(machineLearningRunName: string) { - return this.pathTemplates.machineLearningRunPathTemplate.match(machineLearningRunName).project; + return this.pathTemplates.machineLearningRunPathTemplate.match( + machineLearningRunName, + ).project; } /** @@ -2109,7 +2562,9 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the location. */ matchLocationFromMachineLearningRunName(machineLearningRunName: string) { - return this.pathTemplates.machineLearningRunPathTemplate.match(machineLearningRunName).location; + return this.pathTemplates.machineLearningRunPathTemplate.match( + machineLearningRunName, + ).location; } /** @@ -2119,8 +2574,12 @@ export class HypercomputeClusterClient { * A fully-qualified path representing MachineLearningRun resource. * @returns {string} A string representing the machine_learning_run. */ - matchMachineLearningRunFromMachineLearningRunName(machineLearningRunName: string) { - return this.pathTemplates.machineLearningRunPathTemplate.match(machineLearningRunName).machine_learning_run; + matchMachineLearningRunFromMachineLearningRunName( + machineLearningRunName: string, + ) { + return this.pathTemplates.machineLearningRunPathTemplate.match( + machineLearningRunName, + ).machine_learning_run; } /** @@ -2132,7 +2591,12 @@ export class HypercomputeClusterClient { * @param {string} monitored_event * @returns {string} Resource name string. */ - monitoredEventPath(project:string,location:string,machineLearningRun:string,monitoredEvent:string) { + monitoredEventPath( + project: string, + location: string, + machineLearningRun: string, + monitoredEvent: string, + ) { return this.pathTemplates.monitoredEventPathTemplate.render({ project: project, location: location, @@ -2149,7 +2613,9 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the project. */ matchProjectFromMonitoredEventName(monitoredEventName: string) { - return this.pathTemplates.monitoredEventPathTemplate.match(monitoredEventName).project; + return this.pathTemplates.monitoredEventPathTemplate.match( + monitoredEventName, + ).project; } /** @@ -2160,7 +2626,9 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the location. */ matchLocationFromMonitoredEventName(monitoredEventName: string) { - return this.pathTemplates.monitoredEventPathTemplate.match(monitoredEventName).location; + return this.pathTemplates.monitoredEventPathTemplate.match( + monitoredEventName, + ).location; } /** @@ -2171,7 +2639,9 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the machine_learning_run. */ matchMachineLearningRunFromMonitoredEventName(monitoredEventName: string) { - return this.pathTemplates.monitoredEventPathTemplate.match(monitoredEventName).machine_learning_run; + return this.pathTemplates.monitoredEventPathTemplate.match( + monitoredEventName, + ).machine_learning_run; } /** @@ -2182,7 +2652,9 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the monitored_event. */ matchMonitoredEventFromMonitoredEventName(monitoredEventName: string) { - return this.pathTemplates.monitoredEventPathTemplate.match(monitoredEventName).monitored_event; + return this.pathTemplates.monitoredEventPathTemplate.match( + monitoredEventName, + ).monitored_event; } /** @@ -2192,7 +2664,7 @@ export class HypercomputeClusterClient { * @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, @@ -2230,7 +2702,7 @@ export class HypercomputeClusterClient { * @param {string} node * @returns {string} Resource name string. */ - nodePath(project:string,location:string,cluster:string,node:string) { + nodePath(project: string, location: string, cluster: string, node: string) { return this.pathTemplates.nodePathTemplate.render({ project: project, location: location, @@ -2293,7 +2765,13 @@ export class HypercomputeClusterClient { * @param {string} pod * @returns {string} Resource name string. */ - podPath(project:string,location:string,cluster:string,namespace:string,pod:string) { + podPath( + project: string, + location: string, + cluster: string, + namespace: string, + pod: string, + ) { return this.pathTemplates.podPathTemplate.render({ project: project, location: location, @@ -2367,7 +2845,12 @@ export class HypercomputeClusterClient { * @param {string} profile_session * @returns {string} Resource name string. */ - profileSessionPath(project:string,location:string,machineLearningRun:string,profileSession:string) { + profileSessionPath( + project: string, + location: string, + machineLearningRun: string, + profileSession: string, + ) { return this.pathTemplates.profileSessionPathTemplate.render({ project: project, location: location, @@ -2384,7 +2867,9 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the project. */ matchProjectFromProfileSessionName(profileSessionName: string) { - return this.pathTemplates.profileSessionPathTemplate.match(profileSessionName).project; + return this.pathTemplates.profileSessionPathTemplate.match( + profileSessionName, + ).project; } /** @@ -2395,7 +2880,9 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the location. */ matchLocationFromProfileSessionName(profileSessionName: string) { - return this.pathTemplates.profileSessionPathTemplate.match(profileSessionName).location; + return this.pathTemplates.profileSessionPathTemplate.match( + profileSessionName, + ).location; } /** @@ -2406,7 +2893,9 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the machine_learning_run. */ matchMachineLearningRunFromProfileSessionName(profileSessionName: string) { - return this.pathTemplates.profileSessionPathTemplate.match(profileSessionName).machine_learning_run; + return this.pathTemplates.profileSessionPathTemplate.match( + profileSessionName, + ).machine_learning_run; } /** @@ -2417,7 +2906,9 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the profile_session. */ matchProfileSessionFromProfileSessionName(profileSessionName: string) { - return this.pathTemplates.profileSessionPathTemplate.match(profileSessionName).profile_session; + return this.pathTemplates.profileSessionPathTemplate.match( + profileSessionName, + ).profile_session; } /** @@ -2429,7 +2920,12 @@ export class HypercomputeClusterClient { * @param {string} profiler_session * @returns {string} Resource name string. */ - profilerSessionPath(project:string,location:string,machineLearningRun:string,profilerSession:string) { + profilerSessionPath( + project: string, + location: string, + machineLearningRun: string, + profilerSession: string, + ) { return this.pathTemplates.profilerSessionPathTemplate.render({ project: project, location: location, @@ -2446,7 +2942,9 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the project. */ matchProjectFromProfilerSessionName(profilerSessionName: string) { - return this.pathTemplates.profilerSessionPathTemplate.match(profilerSessionName).project; + return this.pathTemplates.profilerSessionPathTemplate.match( + profilerSessionName, + ).project; } /** @@ -2457,7 +2955,9 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the location. */ matchLocationFromProfilerSessionName(profilerSessionName: string) { - return this.pathTemplates.profilerSessionPathTemplate.match(profilerSessionName).location; + return this.pathTemplates.profilerSessionPathTemplate.match( + profilerSessionName, + ).location; } /** @@ -2468,7 +2968,9 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the machine_learning_run. */ matchMachineLearningRunFromProfilerSessionName(profilerSessionName: string) { - return this.pathTemplates.profilerSessionPathTemplate.match(profilerSessionName).machine_learning_run; + return this.pathTemplates.profilerSessionPathTemplate.match( + profilerSessionName, + ).machine_learning_run; } /** @@ -2479,7 +2981,9 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the profiler_session. */ matchProfilerSessionFromProfilerSessionName(profilerSessionName: string) { - return this.pathTemplates.profilerSessionPathTemplate.match(profilerSessionName).profiler_session; + return this.pathTemplates.profilerSessionPathTemplate.match( + profilerSessionName, + ).profiler_session; } /** @@ -2491,7 +2995,12 @@ export class HypercomputeClusterClient { * @param {string} profiler_target * @returns {string} Resource name string. */ - profilerTargetPath(project:string,location:string,machineLearningRun:string,profilerTarget:string) { + profilerTargetPath( + project: string, + location: string, + machineLearningRun: string, + profilerTarget: string, + ) { return this.pathTemplates.profilerTargetPathTemplate.render({ project: project, location: location, @@ -2508,7 +3017,9 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the project. */ matchProjectFromProfilerTargetName(profilerTargetName: string) { - return this.pathTemplates.profilerTargetPathTemplate.match(profilerTargetName).project; + return this.pathTemplates.profilerTargetPathTemplate.match( + profilerTargetName, + ).project; } /** @@ -2519,7 +3030,9 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the location. */ matchLocationFromProfilerTargetName(profilerTargetName: string) { - return this.pathTemplates.profilerTargetPathTemplate.match(profilerTargetName).location; + return this.pathTemplates.profilerTargetPathTemplate.match( + profilerTargetName, + ).location; } /** @@ -2530,7 +3043,9 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the machine_learning_run. */ matchMachineLearningRunFromProfilerTargetName(profilerTargetName: string) { - return this.pathTemplates.profilerTargetPathTemplate.match(profilerTargetName).machine_learning_run; + return this.pathTemplates.profilerTargetPathTemplate.match( + profilerTargetName, + ).machine_learning_run; } /** @@ -2541,7 +3056,9 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the profiler_target. */ matchProfilerTargetFromProfilerTargetName(profilerTargetName: string) { - return this.pathTemplates.profilerTargetPathTemplate.match(profilerTargetName).profiler_target; + return this.pathTemplates.profilerTargetPathTemplate.match( + profilerTargetName, + ).profiler_target; } /** @@ -2550,7 +3067,7 @@ export class HypercomputeClusterClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -2575,7 +3092,7 @@ export class HypercomputeClusterClient { * @param {string} reservation * @returns {string} Resource name string. */ - reservationPath(project:string,zone:string,reservation:string) { + reservationPath(project: string, zone: string, reservation: string) { return this.pathTemplates.reservationPathTemplate.render({ project: project, zone: zone, @@ -2591,7 +3108,8 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the project. */ matchProjectFromReservationName(reservationName: string) { - return this.pathTemplates.reservationPathTemplate.match(reservationName).project; + return this.pathTemplates.reservationPathTemplate.match(reservationName) + .project; } /** @@ -2602,7 +3120,8 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the zone. */ matchZoneFromReservationName(reservationName: string) { - return this.pathTemplates.reservationPathTemplate.match(reservationName).zone; + return this.pathTemplates.reservationPathTemplate.match(reservationName) + .zone; } /** @@ -2613,7 +3132,8 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the reservation. */ matchReservationFromReservationName(reservationName: string) { - return this.pathTemplates.reservationPathTemplate.match(reservationName).reservation; + return this.pathTemplates.reservationPathTemplate.match(reservationName) + .reservation; } /** @@ -2625,7 +3145,12 @@ export class HypercomputeClusterClient { * @param {string} reservation_block * @returns {string} Resource name string. */ - reservationBlockPath(project:string,zone:string,reservation:string,reservationBlock:string) { + reservationBlockPath( + project: string, + zone: string, + reservation: string, + reservationBlock: string, + ) { return this.pathTemplates.reservationBlockPathTemplate.render({ project: project, zone: zone, @@ -2642,7 +3167,9 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the project. */ matchProjectFromReservationBlockName(reservationBlockName: string) { - return this.pathTemplates.reservationBlockPathTemplate.match(reservationBlockName).project; + return this.pathTemplates.reservationBlockPathTemplate.match( + reservationBlockName, + ).project; } /** @@ -2653,7 +3180,9 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the zone. */ matchZoneFromReservationBlockName(reservationBlockName: string) { - return this.pathTemplates.reservationBlockPathTemplate.match(reservationBlockName).zone; + return this.pathTemplates.reservationBlockPathTemplate.match( + reservationBlockName, + ).zone; } /** @@ -2664,7 +3193,9 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the reservation. */ matchReservationFromReservationBlockName(reservationBlockName: string) { - return this.pathTemplates.reservationBlockPathTemplate.match(reservationBlockName).reservation; + return this.pathTemplates.reservationBlockPathTemplate.match( + reservationBlockName, + ).reservation; } /** @@ -2675,7 +3206,9 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the reservation_block. */ matchReservationBlockFromReservationBlockName(reservationBlockName: string) { - return this.pathTemplates.reservationBlockPathTemplate.match(reservationBlockName).reservation_block; + return this.pathTemplates.reservationBlockPathTemplate.match( + reservationBlockName, + ).reservation_block; } /** @@ -2688,7 +3221,13 @@ export class HypercomputeClusterClient { * @param {string} reservation_sub_block * @returns {string} Resource name string. */ - reservationSubBlockPath(project:string,zone:string,reservation:string,reservationBlock:string,reservationSubBlock:string) { + reservationSubBlockPath( + project: string, + zone: string, + reservation: string, + reservationBlock: string, + reservationSubBlock: string, + ) { return this.pathTemplates.reservationSubBlockPathTemplate.render({ project: project, zone: zone, @@ -2706,7 +3245,9 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the project. */ matchProjectFromReservationSubBlockName(reservationSubBlockName: string) { - return this.pathTemplates.reservationSubBlockPathTemplate.match(reservationSubBlockName).project; + return this.pathTemplates.reservationSubBlockPathTemplate.match( + reservationSubBlockName, + ).project; } /** @@ -2717,7 +3258,9 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the zone. */ matchZoneFromReservationSubBlockName(reservationSubBlockName: string) { - return this.pathTemplates.reservationSubBlockPathTemplate.match(reservationSubBlockName).zone; + return this.pathTemplates.reservationSubBlockPathTemplate.match( + reservationSubBlockName, + ).zone; } /** @@ -2728,7 +3271,9 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the reservation. */ matchReservationFromReservationSubBlockName(reservationSubBlockName: string) { - return this.pathTemplates.reservationSubBlockPathTemplate.match(reservationSubBlockName).reservation; + return this.pathTemplates.reservationSubBlockPathTemplate.match( + reservationSubBlockName, + ).reservation; } /** @@ -2738,8 +3283,12 @@ export class HypercomputeClusterClient { * A fully-qualified path representing ReservationSubBlock resource. * @returns {string} A string representing the reservation_block. */ - matchReservationBlockFromReservationSubBlockName(reservationSubBlockName: string) { - return this.pathTemplates.reservationSubBlockPathTemplate.match(reservationSubBlockName).reservation_block; + matchReservationBlockFromReservationSubBlockName( + reservationSubBlockName: string, + ) { + return this.pathTemplates.reservationSubBlockPathTemplate.match( + reservationSubBlockName, + ).reservation_block; } /** @@ -2749,8 +3298,12 @@ export class HypercomputeClusterClient { * A fully-qualified path representing ReservationSubBlock resource. * @returns {string} A string representing the reservation_sub_block. */ - matchReservationSubBlockFromReservationSubBlockName(reservationSubBlockName: string) { - return this.pathTemplates.reservationSubBlockPathTemplate.match(reservationSubBlockName).reservation_sub_block; + matchReservationSubBlockFromReservationSubBlockName( + reservationSubBlockName: string, + ) { + return this.pathTemplates.reservationSubBlockPathTemplate.match( + reservationSubBlockName, + ).reservation_sub_block; } /** @@ -2761,7 +3314,7 @@ export class HypercomputeClusterClient { * @param {string} subnetwork * @returns {string} Resource name string. */ - subnetworkPath(project:string,region:string,subnetwork:string) { + subnetworkPath(project: string, region: string, subnetwork: string) { return this.pathTemplates.subnetworkPathTemplate.render({ project: project, region: region, @@ -2777,7 +3330,8 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the project. */ matchProjectFromSubnetworkName(subnetworkName: string) { - return this.pathTemplates.subnetworkPathTemplate.match(subnetworkName).project; + return this.pathTemplates.subnetworkPathTemplate.match(subnetworkName) + .project; } /** @@ -2788,7 +3342,8 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the region. */ matchRegionFromSubnetworkName(subnetworkName: string) { - return this.pathTemplates.subnetworkPathTemplate.match(subnetworkName).region; + return this.pathTemplates.subnetworkPathTemplate.match(subnetworkName) + .region; } /** @@ -2799,7 +3354,8 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the subnetwork. */ matchSubnetworkFromSubnetworkName(subnetworkName: string) { - return this.pathTemplates.subnetworkPathTemplate.match(subnetworkName).subnetwork; + return this.pathTemplates.subnetworkPathTemplate.match(subnetworkName) + .subnetwork; } /** @@ -2810,14 +3366,16 @@ export class HypercomputeClusterClient { */ close(): Promise { if (this.hypercomputeClusterStub && !this._terminated) { - return this.hypercomputeClusterStub.then(stub => { + return this.hypercomputeClusterStub.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-hypercomputecluster/src/v1alpha/index.ts b/packages/google-cloud-hypercomputecluster/src/v1alpha/index.ts index d8e9732630c1..e6340c61167d 100644 --- a/packages/google-cloud-hypercomputecluster/src/v1alpha/index.ts +++ b/packages/google-cloud-hypercomputecluster/src/v1alpha/index.ts @@ -16,5 +16,5 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {HypercomputeClusterClient} from './hypercompute_cluster_client'; -export {MachineLearningRunsClient} from './machine_learning_runs_client'; +export { HypercomputeClusterClient } from './hypercompute_cluster_client'; +export { MachineLearningRunsClient } from './machine_learning_runs_client'; diff --git a/packages/google-cloud-hypercomputecluster/src/v1alpha/machine_learning_runs_client.ts b/packages/google-cloud-hypercomputecluster/src/v1alpha/machine_learning_runs_client.ts index 7a1920866054..93f7af13518f 100644 --- a/packages/google-cloud-hypercomputecluster/src/v1alpha/machine_learning_runs_client.ts +++ b/packages/google-cloud-hypercomputecluster/src/v1alpha/machine_learning_runs_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 MachineLearningRunsClient { 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('hypercomputecluster'); @@ -57,11 +68,11 @@ export class MachineLearningRunsClient { 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; - machineLearningRunsStub?: Promise<{[name: string]: Function}>; + machineLearningRunsStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of MachineLearningRunsClient. @@ -102,21 +113,42 @@ export class MachineLearningRunsClient { * const client = new MachineLearningRunsClient({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 MachineLearningRunsClient; - 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 = 'hypercomputecluster.' + 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 MachineLearningRunsClient { 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 MachineLearningRunsClient { } 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,31 +213,31 @@ export class MachineLearningRunsClient { // Create useful helper objects for these. this.pathTemplates = { clusterPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/clusters/{cluster}' + 'projects/{project}/locations/{location}/clusters/{cluster}', ), locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' + 'projects/{project}/locations/{location}', ), machineLearningRunPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run}' + 'projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run}', ), monitoredEventPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run}/monitoredEvents/{monitored_event}' + 'projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run}/monitoredEvents/{monitored_event}', ), nodePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/clusters/{cluster}/nodes/{node}' + 'projects/{project}/locations/{location}/clusters/{cluster}/nodes/{node}', ), profileSessionPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run}/profileSessions/{profile_session}' + 'projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run}/profileSessions/{profile_session}', ), profilerSessionPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run}/profilerSessions/{profiler_session}' + 'projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run}/profilerSessions/{profiler_session}', ), profilerTargetPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run}/profilerTargets/{profiler_target}' + 'projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run}/profilerTargets/{profiler_target}', ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' + 'projects/{project}', ), }; @@ -217,16 +245,31 @@ export class MachineLearningRunsClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listMachineLearningRuns: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'machineLearningRuns'), - listProfilerTargets: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'profilerTargets'), - listProfilerSessions: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'profilerSessions'), - listProfileSessions: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'profileSessions'), - listMonitoredEvents: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'monitoredEvents') + listMachineLearningRuns: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'machineLearningRuns', + ), + listProfilerTargets: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'profilerTargets', + ), + listProfilerSessions: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'profilerSessions', + ), + listProfileSessions: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'profileSessions', + ), + listMonitoredEvents: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'monitoredEvents', + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -235,85 +278,156 @@ export class MachineLearningRunsClient { // rather than holding a request open. const lroOptions: GrpcClientOptions = { auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1alpha/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1alpha/{name=projects/*}/locations',},{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1alpha/{name=projects/*/locations/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1alpha/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1alpha/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1alpha/{name=projects/*/locations/*}/operations',}]; + lroOptions.httpRules = [ + { + selector: 'google.cloud.location.Locations.GetLocation', + get: '/v1alpha/{name=projects/*/locations/*}', + }, + { + selector: 'google.cloud.location.Locations.ListLocations', + get: '/v1alpha/{name=projects/*}/locations', + }, + { + selector: 'google.longrunning.Operations.CancelOperation', + post: '/v1alpha/{name=projects/*/locations/*/operations/*}:cancel', + body: '*', + }, + { + selector: 'google.longrunning.Operations.DeleteOperation', + delete: '/v1alpha/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v1alpha/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v1alpha/{name=projects/*/locations/*}/operations', + }, + ]; } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); const createMachineLearningRunResponse = protoFilesRoot.lookup( - '.google.cloud.hypercomputecluster.v1alpha.MachineLearningRun') as gax.protobuf.Type; + '.google.cloud.hypercomputecluster.v1alpha.MachineLearningRun', + ) as gax.protobuf.Type; const createMachineLearningRunMetadata = protoFilesRoot.lookup( - '.google.cloud.hypercomputecluster.v1alpha.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.hypercomputecluster.v1alpha.OperationMetadata', + ) as gax.protobuf.Type; const updateMachineLearningRunResponse = protoFilesRoot.lookup( - '.google.cloud.hypercomputecluster.v1alpha.MachineLearningRun') as gax.protobuf.Type; + '.google.cloud.hypercomputecluster.v1alpha.MachineLearningRun', + ) as gax.protobuf.Type; const updateMachineLearningRunMetadata = protoFilesRoot.lookup( - '.google.cloud.hypercomputecluster.v1alpha.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.hypercomputecluster.v1alpha.OperationMetadata', + ) as gax.protobuf.Type; const deleteMachineLearningRunResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteMachineLearningRunMetadata = protoFilesRoot.lookup( - '.google.cloud.hypercomputecluster.v1alpha.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.hypercomputecluster.v1alpha.OperationMetadata', + ) as gax.protobuf.Type; const createProfilerTargetResponse = protoFilesRoot.lookup( - '.google.cloud.hypercomputecluster.v1alpha.ProfilerTarget') as gax.protobuf.Type; + '.google.cloud.hypercomputecluster.v1alpha.ProfilerTarget', + ) as gax.protobuf.Type; const createProfilerTargetMetadata = protoFilesRoot.lookup( - '.google.cloud.hypercomputecluster.v1alpha.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.hypercomputecluster.v1alpha.OperationMetadata', + ) as gax.protobuf.Type; const createProfilerSessionResponse = protoFilesRoot.lookup( - '.google.cloud.hypercomputecluster.v1alpha.ProfilerSession') as gax.protobuf.Type; + '.google.cloud.hypercomputecluster.v1alpha.ProfilerSession', + ) as gax.protobuf.Type; const createProfilerSessionMetadata = protoFilesRoot.lookup( - '.google.cloud.hypercomputecluster.v1alpha.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.hypercomputecluster.v1alpha.OperationMetadata', + ) as gax.protobuf.Type; const createMonitoredEventResponse = protoFilesRoot.lookup( - '.google.cloud.hypercomputecluster.v1alpha.MonitoredEvent') as gax.protobuf.Type; + '.google.cloud.hypercomputecluster.v1alpha.MonitoredEvent', + ) as gax.protobuf.Type; const createMonitoredEventMetadata = protoFilesRoot.lookup( - '.google.cloud.hypercomputecluster.v1alpha.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.hypercomputecluster.v1alpha.OperationMetadata', + ) as gax.protobuf.Type; const updateMonitoredEventResponse = protoFilesRoot.lookup( - '.google.cloud.hypercomputecluster.v1alpha.MonitoredEvent') as gax.protobuf.Type; + '.google.cloud.hypercomputecluster.v1alpha.MonitoredEvent', + ) as gax.protobuf.Type; const updateMonitoredEventMetadata = protoFilesRoot.lookup( - '.google.cloud.hypercomputecluster.v1alpha.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.hypercomputecluster.v1alpha.OperationMetadata', + ) as gax.protobuf.Type; const deleteMonitoredEventResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteMonitoredEventMetadata = protoFilesRoot.lookup( - '.google.cloud.hypercomputecluster.v1alpha.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.hypercomputecluster.v1alpha.OperationMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { createMachineLearningRun: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - createMachineLearningRunResponse.decode.bind(createMachineLearningRunResponse), - createMachineLearningRunMetadata.decode.bind(createMachineLearningRunMetadata)), + createMachineLearningRunResponse.decode.bind( + createMachineLearningRunResponse, + ), + createMachineLearningRunMetadata.decode.bind( + createMachineLearningRunMetadata, + ), + ), updateMachineLearningRun: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - updateMachineLearningRunResponse.decode.bind(updateMachineLearningRunResponse), - updateMachineLearningRunMetadata.decode.bind(updateMachineLearningRunMetadata)), + updateMachineLearningRunResponse.decode.bind( + updateMachineLearningRunResponse, + ), + updateMachineLearningRunMetadata.decode.bind( + updateMachineLearningRunMetadata, + ), + ), deleteMachineLearningRun: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - deleteMachineLearningRunResponse.decode.bind(deleteMachineLearningRunResponse), - deleteMachineLearningRunMetadata.decode.bind(deleteMachineLearningRunMetadata)), + deleteMachineLearningRunResponse.decode.bind( + deleteMachineLearningRunResponse, + ), + deleteMachineLearningRunMetadata.decode.bind( + deleteMachineLearningRunMetadata, + ), + ), createProfilerTarget: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createProfilerTargetResponse.decode.bind(createProfilerTargetResponse), - createProfilerTargetMetadata.decode.bind(createProfilerTargetMetadata)), + createProfilerTargetMetadata.decode.bind(createProfilerTargetMetadata), + ), createProfilerSession: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - createProfilerSessionResponse.decode.bind(createProfilerSessionResponse), - createProfilerSessionMetadata.decode.bind(createProfilerSessionMetadata)), + createProfilerSessionResponse.decode.bind( + createProfilerSessionResponse, + ), + createProfilerSessionMetadata.decode.bind( + createProfilerSessionMetadata, + ), + ), createMonitoredEvent: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createMonitoredEventResponse.decode.bind(createMonitoredEventResponse), - createMonitoredEventMetadata.decode.bind(createMonitoredEventMetadata)), + createMonitoredEventMetadata.decode.bind(createMonitoredEventMetadata), + ), updateMonitoredEvent: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateMonitoredEventResponse.decode.bind(updateMonitoredEventResponse), - updateMonitoredEventMetadata.decode.bind(updateMonitoredEventMetadata)), + updateMonitoredEventMetadata.decode.bind(updateMonitoredEventMetadata), + ), deleteMonitoredEvent: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteMonitoredEventResponse.decode.bind(deleteMonitoredEventResponse), - deleteMonitoredEventMetadata.decode.bind(deleteMonitoredEventMetadata)) + deleteMonitoredEventMetadata.decode.bind(deleteMonitoredEventMetadata), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.hypercomputecluster.v1alpha.MachineLearningRuns', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.hypercomputecluster.v1alpha.MachineLearningRuns', + gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, + { 'x-goog-api-client': clientHeader.join(' ') }, + ); // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code @@ -344,28 +458,55 @@ export class MachineLearningRunsClient { // Put together the "service stub" for // google.cloud.hypercomputecluster.v1alpha.MachineLearningRuns. this.machineLearningRunsStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.hypercomputecluster.v1alpha.MachineLearningRuns') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.hypercomputecluster.v1alpha.MachineLearningRuns, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.hypercomputecluster.v1alpha.MachineLearningRuns', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.hypercomputecluster.v1alpha + .MachineLearningRuns, + 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 machineLearningRunsStubMethods = - ['createMachineLearningRun', 'updateMachineLearningRun', 'deleteMachineLearningRun', 'getMachineLearningRun', 'listMachineLearningRuns', 'createProfilerTarget', 'getProfilerTarget', 'listProfilerTargets', 'deleteProfilerTarget', 'createProfilerSession', 'getProfilerSession', 'listProfilerSessions', 'deleteProfilerSession', 'getProfileSession', 'listProfileSessions', 'createMonitoredEvent', 'getMonitoredEvent', 'listMonitoredEvents', 'updateMonitoredEvent', 'deleteMonitoredEvent']; + const machineLearningRunsStubMethods = [ + 'createMachineLearningRun', + 'updateMachineLearningRun', + 'deleteMachineLearningRun', + 'getMachineLearningRun', + 'listMachineLearningRuns', + 'createProfilerTarget', + 'getProfilerTarget', + 'listProfilerTargets', + 'deleteProfilerTarget', + 'createProfilerSession', + 'getProfilerSession', + 'listProfilerSessions', + 'deleteProfilerSession', + 'getProfileSession', + 'listProfileSessions', + 'createMonitoredEvent', + 'getMonitoredEvent', + 'listMonitoredEvents', + 'updateMonitoredEvent', + 'deleteMonitoredEvent', + ]; for (const methodName of machineLearningRunsStubMethods) { const callPromise = this.machineLearningRunsStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { + (stub) => + (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error | null | undefined) => () => { throw err; - }); + }, + ); const descriptor = this.descriptors.page[methodName] || @@ -375,7 +516,7 @@ export class MachineLearningRunsClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -390,8 +531,14 @@ export class MachineLearningRunsClient { * @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 'hypercomputecluster.googleapis.com'; } @@ -402,8 +549,14 @@ export class MachineLearningRunsClient { * @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 'hypercomputecluster.googleapis.com'; } @@ -434,9 +587,7 @@ export class MachineLearningRunsClient { * @returns {string[]} List of default scopes. */ static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform' - ]; + return ['https://www.googleapis.com/auth/cloud-platform']; } getProjectId(): Promise; @@ -445,8 +596,9 @@ export class MachineLearningRunsClient { * Return the project ID used by this class. * @returns {Promise} A promise that resolves to string containing the project ID. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback, + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -457,1706 +609,2574 @@ export class MachineLearningRunsClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Gets a Machine Learning Run. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. - * projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run} - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.hypercomputecluster.v1alpha.MachineLearningRun|MachineLearningRun}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/machine_learning_runs.get_machine_learning_run.js - * region_tag:hypercomputecluster_v1alpha_generated_MachineLearningRuns_GetMachineLearningRun_async - */ + /** + * Gets a Machine Learning Run. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. + * projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run} + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.hypercomputecluster.v1alpha.MachineLearningRun|MachineLearningRun}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/machine_learning_runs.get_machine_learning_run.js + * region_tag:hypercomputecluster_v1alpha_generated_MachineLearningRuns_GetMachineLearningRun_async + */ getMachineLearningRun( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IGetMachineLearningRunRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun, - protos.google.cloud.hypercomputecluster.v1alpha.IGetMachineLearningRunRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.hypercomputecluster.v1alpha.IGetMachineLearningRunRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun, + ( + | protos.google.cloud.hypercomputecluster.v1alpha.IGetMachineLearningRunRequest + | undefined + ), + {} | undefined, + ] + >; getMachineLearningRun( - request: protos.google.cloud.hypercomputecluster.v1alpha.IGetMachineLearningRunRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun, - protos.google.cloud.hypercomputecluster.v1alpha.IGetMachineLearningRunRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.hypercomputecluster.v1alpha.IGetMachineLearningRunRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun, + | protos.google.cloud.hypercomputecluster.v1alpha.IGetMachineLearningRunRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getMachineLearningRun( - request: protos.google.cloud.hypercomputecluster.v1alpha.IGetMachineLearningRunRequest, - callback: Callback< - protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun, - protos.google.cloud.hypercomputecluster.v1alpha.IGetMachineLearningRunRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.hypercomputecluster.v1alpha.IGetMachineLearningRunRequest, + callback: Callback< + protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun, + | protos.google.cloud.hypercomputecluster.v1alpha.IGetMachineLearningRunRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getMachineLearningRun( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IGetMachineLearningRunRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun, - protos.google.cloud.hypercomputecluster.v1alpha.IGetMachineLearningRunRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.hypercomputecluster.v1alpha.IGetMachineLearningRunRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun, - protos.google.cloud.hypercomputecluster.v1alpha.IGetMachineLearningRunRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun, - protos.google.cloud.hypercomputecluster.v1alpha.IGetMachineLearningRunRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.hypercomputecluster.v1alpha.IGetMachineLearningRunRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun, + | protos.google.cloud.hypercomputecluster.v1alpha.IGetMachineLearningRunRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun, + ( + | protos.google.cloud.hypercomputecluster.v1alpha.IGetMachineLearningRunRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getMachineLearningRun request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun, - protos.google.cloud.hypercomputecluster.v1alpha.IGetMachineLearningRunRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun, + | protos.google.cloud.hypercomputecluster.v1alpha.IGetMachineLearningRunRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getMachineLearningRun response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getMachineLearningRun(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun, - protos.google.cloud.hypercomputecluster.v1alpha.IGetMachineLearningRunRequest|undefined, - {}|undefined - ]) => { - this._log.info('getMachineLearningRun response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getMachineLearningRun(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun, + ( + | protos.google.cloud.hypercomputecluster.v1alpha.IGetMachineLearningRunRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getMachineLearningRun response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 Profiler Target. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. - * projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run}/profilerTargets/{profiler_target} - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.hypercomputecluster.v1alpha.ProfilerTarget|ProfilerTarget}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/machine_learning_runs.get_profiler_target.js - * region_tag:hypercomputecluster_v1alpha_generated_MachineLearningRuns_GetProfilerTarget_async - */ + /** + * Gets a Profiler Target. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. + * projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run}/profilerTargets/{profiler_target} + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.hypercomputecluster.v1alpha.ProfilerTarget|ProfilerTarget}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/machine_learning_runs.get_profiler_target.js + * region_tag:hypercomputecluster_v1alpha_generated_MachineLearningRuns_GetProfilerTarget_async + */ getProfilerTarget( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IGetProfilerTargetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.hypercomputecluster.v1alpha.IProfilerTarget, - protos.google.cloud.hypercomputecluster.v1alpha.IGetProfilerTargetRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.hypercomputecluster.v1alpha.IGetProfilerTargetRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.hypercomputecluster.v1alpha.IProfilerTarget, + ( + | protos.google.cloud.hypercomputecluster.v1alpha.IGetProfilerTargetRequest + | undefined + ), + {} | undefined, + ] + >; getProfilerTarget( - request: protos.google.cloud.hypercomputecluster.v1alpha.IGetProfilerTargetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.hypercomputecluster.v1alpha.IProfilerTarget, - protos.google.cloud.hypercomputecluster.v1alpha.IGetProfilerTargetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.hypercomputecluster.v1alpha.IGetProfilerTargetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.hypercomputecluster.v1alpha.IProfilerTarget, + | protos.google.cloud.hypercomputecluster.v1alpha.IGetProfilerTargetRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getProfilerTarget( - request: protos.google.cloud.hypercomputecluster.v1alpha.IGetProfilerTargetRequest, - callback: Callback< - protos.google.cloud.hypercomputecluster.v1alpha.IProfilerTarget, - protos.google.cloud.hypercomputecluster.v1alpha.IGetProfilerTargetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.hypercomputecluster.v1alpha.IGetProfilerTargetRequest, + callback: Callback< + protos.google.cloud.hypercomputecluster.v1alpha.IProfilerTarget, + | protos.google.cloud.hypercomputecluster.v1alpha.IGetProfilerTargetRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getProfilerTarget( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IGetProfilerTargetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.hypercomputecluster.v1alpha.IProfilerTarget, - protos.google.cloud.hypercomputecluster.v1alpha.IGetProfilerTargetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.hypercomputecluster.v1alpha.IGetProfilerTargetRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.hypercomputecluster.v1alpha.IProfilerTarget, - protos.google.cloud.hypercomputecluster.v1alpha.IGetProfilerTargetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.hypercomputecluster.v1alpha.IProfilerTarget, - protos.google.cloud.hypercomputecluster.v1alpha.IGetProfilerTargetRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.hypercomputecluster.v1alpha.IGetProfilerTargetRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.hypercomputecluster.v1alpha.IProfilerTarget, + | protos.google.cloud.hypercomputecluster.v1alpha.IGetProfilerTargetRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.hypercomputecluster.v1alpha.IProfilerTarget, + ( + | protos.google.cloud.hypercomputecluster.v1alpha.IGetProfilerTargetRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getProfilerTarget request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.hypercomputecluster.v1alpha.IProfilerTarget, - protos.google.cloud.hypercomputecluster.v1alpha.IGetProfilerTargetRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.hypercomputecluster.v1alpha.IProfilerTarget, + | protos.google.cloud.hypercomputecluster.v1alpha.IGetProfilerTargetRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getProfilerTarget response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getProfilerTarget(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.hypercomputecluster.v1alpha.IProfilerTarget, - protos.google.cloud.hypercomputecluster.v1alpha.IGetProfilerTargetRequest|undefined, - {}|undefined - ]) => { - this._log.info('getProfilerTarget response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getProfilerTarget(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.hypercomputecluster.v1alpha.IProfilerTarget, + ( + | protos.google.cloud.hypercomputecluster.v1alpha.IGetProfilerTargetRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getProfilerTarget response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 Profiler Target. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the profiler target to delete. - * Format: - * projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run}/profilerTargets/{profiler_target} - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for 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/v1alpha/machine_learning_runs.delete_profiler_target.js - * region_tag:hypercomputecluster_v1alpha_generated_MachineLearningRuns_DeleteProfilerTarget_async - */ + /** + * Delete a Profiler Target. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the profiler target to delete. + * Format: + * projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run}/profilerTargets/{profiler_target} + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for 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/v1alpha/machine_learning_runs.delete_profiler_target.js + * region_tag:hypercomputecluster_v1alpha_generated_MachineLearningRuns_DeleteProfilerTarget_async + */ deleteProfilerTarget( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IDeleteProfilerTargetRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.hypercomputecluster.v1alpha.IDeleteProfilerTargetRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.hypercomputecluster.v1alpha.IDeleteProfilerTargetRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.hypercomputecluster.v1alpha.IDeleteProfilerTargetRequest + | undefined + ), + {} | undefined, + ] + >; deleteProfilerTarget( - request: protos.google.cloud.hypercomputecluster.v1alpha.IDeleteProfilerTargetRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.hypercomputecluster.v1alpha.IDeleteProfilerTargetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.hypercomputecluster.v1alpha.IDeleteProfilerTargetRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.hypercomputecluster.v1alpha.IDeleteProfilerTargetRequest + | null + | undefined, + {} | null | undefined + >, + ): void; deleteProfilerTarget( - request: protos.google.cloud.hypercomputecluster.v1alpha.IDeleteProfilerTargetRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.hypercomputecluster.v1alpha.IDeleteProfilerTargetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.hypercomputecluster.v1alpha.IDeleteProfilerTargetRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.hypercomputecluster.v1alpha.IDeleteProfilerTargetRequest + | null + | undefined, + {} | null | undefined + >, + ): void; deleteProfilerTarget( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IDeleteProfilerTargetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.hypercomputecluster.v1alpha.IDeleteProfilerTargetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.hypercomputecluster.v1alpha.IDeleteProfilerTargetRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.protobuf.IEmpty, - protos.google.cloud.hypercomputecluster.v1alpha.IDeleteProfilerTargetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.hypercomputecluster.v1alpha.IDeleteProfilerTargetRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.hypercomputecluster.v1alpha.IDeleteProfilerTargetRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.hypercomputecluster.v1alpha.IDeleteProfilerTargetRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.hypercomputecluster.v1alpha.IDeleteProfilerTargetRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('deleteProfilerTarget request %j', request); - const wrappedCallback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.hypercomputecluster.v1alpha.IDeleteProfilerTargetRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.hypercomputecluster.v1alpha.IDeleteProfilerTargetRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('deleteProfilerTarget response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.deleteProfilerTarget(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.protobuf.IEmpty, - protos.google.cloud.hypercomputecluster.v1alpha.IDeleteProfilerTargetRequest|undefined, - {}|undefined - ]) => { - this._log.info('deleteProfilerTarget response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .deleteProfilerTarget(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.hypercomputecluster.v1alpha.IDeleteProfilerTargetRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('deleteProfilerTarget response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 Profiler Session. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. - * projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run}/profilerSessions/{profiler_session} - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.hypercomputecluster.v1alpha.ProfilerSession|ProfilerSession}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/machine_learning_runs.get_profiler_session.js - * region_tag:hypercomputecluster_v1alpha_generated_MachineLearningRuns_GetProfilerSession_async - */ + /** + * Get Profiler Session. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. + * projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run}/profilerSessions/{profiler_session} + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.hypercomputecluster.v1alpha.ProfilerSession|ProfilerSession}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/machine_learning_runs.get_profiler_session.js + * region_tag:hypercomputecluster_v1alpha_generated_MachineLearningRuns_GetProfilerSession_async + */ getProfilerSession( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IGetProfilerSessionRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.hypercomputecluster.v1alpha.IProfilerSession, - protos.google.cloud.hypercomputecluster.v1alpha.IGetProfilerSessionRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.hypercomputecluster.v1alpha.IGetProfilerSessionRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.hypercomputecluster.v1alpha.IProfilerSession, + ( + | protos.google.cloud.hypercomputecluster.v1alpha.IGetProfilerSessionRequest + | undefined + ), + {} | undefined, + ] + >; getProfilerSession( - request: protos.google.cloud.hypercomputecluster.v1alpha.IGetProfilerSessionRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.hypercomputecluster.v1alpha.IProfilerSession, - protos.google.cloud.hypercomputecluster.v1alpha.IGetProfilerSessionRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.hypercomputecluster.v1alpha.IGetProfilerSessionRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.hypercomputecluster.v1alpha.IProfilerSession, + | protos.google.cloud.hypercomputecluster.v1alpha.IGetProfilerSessionRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getProfilerSession( - request: protos.google.cloud.hypercomputecluster.v1alpha.IGetProfilerSessionRequest, - callback: Callback< - protos.google.cloud.hypercomputecluster.v1alpha.IProfilerSession, - protos.google.cloud.hypercomputecluster.v1alpha.IGetProfilerSessionRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.hypercomputecluster.v1alpha.IGetProfilerSessionRequest, + callback: Callback< + protos.google.cloud.hypercomputecluster.v1alpha.IProfilerSession, + | protos.google.cloud.hypercomputecluster.v1alpha.IGetProfilerSessionRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getProfilerSession( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IGetProfilerSessionRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.hypercomputecluster.v1alpha.IProfilerSession, - protos.google.cloud.hypercomputecluster.v1alpha.IGetProfilerSessionRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.hypercomputecluster.v1alpha.IGetProfilerSessionRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.hypercomputecluster.v1alpha.IProfilerSession, - protos.google.cloud.hypercomputecluster.v1alpha.IGetProfilerSessionRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.hypercomputecluster.v1alpha.IProfilerSession, - protos.google.cloud.hypercomputecluster.v1alpha.IGetProfilerSessionRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.hypercomputecluster.v1alpha.IGetProfilerSessionRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.hypercomputecluster.v1alpha.IProfilerSession, + | protos.google.cloud.hypercomputecluster.v1alpha.IGetProfilerSessionRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.hypercomputecluster.v1alpha.IProfilerSession, + ( + | protos.google.cloud.hypercomputecluster.v1alpha.IGetProfilerSessionRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getProfilerSession request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.hypercomputecluster.v1alpha.IProfilerSession, - protos.google.cloud.hypercomputecluster.v1alpha.IGetProfilerSessionRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.hypercomputecluster.v1alpha.IProfilerSession, + | protos.google.cloud.hypercomputecluster.v1alpha.IGetProfilerSessionRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getProfilerSession response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getProfilerSession(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.hypercomputecluster.v1alpha.IProfilerSession, - protos.google.cloud.hypercomputecluster.v1alpha.IGetProfilerSessionRequest|undefined, - {}|undefined - ]) => { - this._log.info('getProfilerSession response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getProfilerSession(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.hypercomputecluster.v1alpha.IProfilerSession, + ( + | protos.google.cloud.hypercomputecluster.v1alpha.IGetProfilerSessionRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getProfilerSession response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 Profiler Session. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the profiler session to delete. - * Format: - * projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run}/profilerSessions/{profiler_session} - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for 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/v1alpha/machine_learning_runs.delete_profiler_session.js - * region_tag:hypercomputecluster_v1alpha_generated_MachineLearningRuns_DeleteProfilerSession_async - */ + /** + * Delete a Profiler Session. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the profiler session to delete. + * Format: + * projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run}/profilerSessions/{profiler_session} + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for 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/v1alpha/machine_learning_runs.delete_profiler_session.js + * region_tag:hypercomputecluster_v1alpha_generated_MachineLearningRuns_DeleteProfilerSession_async + */ deleteProfilerSession( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IDeleteProfilerSessionRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.hypercomputecluster.v1alpha.IDeleteProfilerSessionRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.hypercomputecluster.v1alpha.IDeleteProfilerSessionRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.hypercomputecluster.v1alpha.IDeleteProfilerSessionRequest + | undefined + ), + {} | undefined, + ] + >; deleteProfilerSession( - request: protos.google.cloud.hypercomputecluster.v1alpha.IDeleteProfilerSessionRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.hypercomputecluster.v1alpha.IDeleteProfilerSessionRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.hypercomputecluster.v1alpha.IDeleteProfilerSessionRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.hypercomputecluster.v1alpha.IDeleteProfilerSessionRequest + | null + | undefined, + {} | null | undefined + >, + ): void; deleteProfilerSession( - request: protos.google.cloud.hypercomputecluster.v1alpha.IDeleteProfilerSessionRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.hypercomputecluster.v1alpha.IDeleteProfilerSessionRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.hypercomputecluster.v1alpha.IDeleteProfilerSessionRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.hypercomputecluster.v1alpha.IDeleteProfilerSessionRequest + | null + | undefined, + {} | null | undefined + >, + ): void; deleteProfilerSession( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IDeleteProfilerSessionRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.hypercomputecluster.v1alpha.IDeleteProfilerSessionRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.protobuf.IEmpty, - protos.google.cloud.hypercomputecluster.v1alpha.IDeleteProfilerSessionRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.hypercomputecluster.v1alpha.IDeleteProfilerSessionRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.hypercomputecluster.v1alpha.IDeleteProfilerSessionRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.hypercomputecluster.v1alpha.IDeleteProfilerSessionRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.hypercomputecluster.v1alpha.IDeleteProfilerSessionRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.hypercomputecluster.v1alpha.IDeleteProfilerSessionRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('deleteProfilerSession request %j', request); - const wrappedCallback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.hypercomputecluster.v1alpha.IDeleteProfilerSessionRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.hypercomputecluster.v1alpha.IDeleteProfilerSessionRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('deleteProfilerSession response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.deleteProfilerSession(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.protobuf.IEmpty, - protos.google.cloud.hypercomputecluster.v1alpha.IDeleteProfilerSessionRequest|undefined, - {}|undefined - ]) => { - this._log.info('deleteProfilerSession response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .deleteProfilerSession(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.hypercomputecluster.v1alpha.IDeleteProfilerSessionRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('deleteProfilerSession response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Deprecated: Use `GetProfilerSession` instead. - * Gets a Profile Session. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. - * projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run}/profileSessions/{profileSession} - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.hypercomputecluster.v1alpha.ProfileSession|ProfileSession}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/machine_learning_runs.get_profile_session.js - * region_tag:hypercomputecluster_v1alpha_generated_MachineLearningRuns_GetProfileSession_async - * @deprecated GetProfileSession is deprecated and may be removed in a future version. - */ + /** + * Deprecated: Use `GetProfilerSession` instead. + * Gets a Profile Session. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. + * projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run}/profileSessions/{profileSession} + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.hypercomputecluster.v1alpha.ProfileSession|ProfileSession}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/machine_learning_runs.get_profile_session.js + * region_tag:hypercomputecluster_v1alpha_generated_MachineLearningRuns_GetProfileSession_async + * @deprecated GetProfileSession is deprecated and may be removed in a future version. + */ getProfileSession( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IGetProfileSessionRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.hypercomputecluster.v1alpha.IProfileSession, - protos.google.cloud.hypercomputecluster.v1alpha.IGetProfileSessionRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.hypercomputecluster.v1alpha.IGetProfileSessionRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.hypercomputecluster.v1alpha.IProfileSession, + ( + | protos.google.cloud.hypercomputecluster.v1alpha.IGetProfileSessionRequest + | undefined + ), + {} | undefined, + ] + >; getProfileSession( - request: protos.google.cloud.hypercomputecluster.v1alpha.IGetProfileSessionRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.hypercomputecluster.v1alpha.IProfileSession, - protos.google.cloud.hypercomputecluster.v1alpha.IGetProfileSessionRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.hypercomputecluster.v1alpha.IGetProfileSessionRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.hypercomputecluster.v1alpha.IProfileSession, + | protos.google.cloud.hypercomputecluster.v1alpha.IGetProfileSessionRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getProfileSession( - request: protos.google.cloud.hypercomputecluster.v1alpha.IGetProfileSessionRequest, - callback: Callback< - protos.google.cloud.hypercomputecluster.v1alpha.IProfileSession, - protos.google.cloud.hypercomputecluster.v1alpha.IGetProfileSessionRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.hypercomputecluster.v1alpha.IGetProfileSessionRequest, + callback: Callback< + protos.google.cloud.hypercomputecluster.v1alpha.IProfileSession, + | protos.google.cloud.hypercomputecluster.v1alpha.IGetProfileSessionRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getProfileSession( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IGetProfileSessionRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.hypercomputecluster.v1alpha.IProfileSession, - protos.google.cloud.hypercomputecluster.v1alpha.IGetProfileSessionRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.hypercomputecluster.v1alpha.IGetProfileSessionRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.hypercomputecluster.v1alpha.IProfileSession, - protos.google.cloud.hypercomputecluster.v1alpha.IGetProfileSessionRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.hypercomputecluster.v1alpha.IProfileSession, - protos.google.cloud.hypercomputecluster.v1alpha.IGetProfileSessionRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.hypercomputecluster.v1alpha.IGetProfileSessionRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.hypercomputecluster.v1alpha.IProfileSession, + | protos.google.cloud.hypercomputecluster.v1alpha.IGetProfileSessionRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.hypercomputecluster.v1alpha.IProfileSession, + ( + | protos.google.cloud.hypercomputecluster.v1alpha.IGetProfileSessionRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - this.warn('DEP$MachineLearningRuns-$GetProfileSession','GetProfileSession is deprecated and may be removed in a future version.', 'DeprecationWarning'); + this.warn( + 'DEP$MachineLearningRuns-$GetProfileSession', + 'GetProfileSession is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); this._log.info('getProfileSession request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.hypercomputecluster.v1alpha.IProfileSession, - protos.google.cloud.hypercomputecluster.v1alpha.IGetProfileSessionRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.hypercomputecluster.v1alpha.IProfileSession, + | protos.google.cloud.hypercomputecluster.v1alpha.IGetProfileSessionRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getProfileSession response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getProfileSession(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.hypercomputecluster.v1alpha.IProfileSession, - protos.google.cloud.hypercomputecluster.v1alpha.IGetProfileSessionRequest|undefined, - {}|undefined - ]) => { - this._log.info('getProfileSession response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getProfileSession(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.hypercomputecluster.v1alpha.IProfileSession, + ( + | protos.google.cloud.hypercomputecluster.v1alpha.IGetProfileSessionRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getProfileSession response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 specific Monitored Event. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the monitored event to retrieve. - * Format: - * projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run}/monitoredEvents/{monitored_event} - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.hypercomputecluster.v1alpha.MonitoredEvent|MonitoredEvent}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/machine_learning_runs.get_monitored_event.js - * region_tag:hypercomputecluster_v1alpha_generated_MachineLearningRuns_GetMonitoredEvent_async - */ + /** + * Gets a specific Monitored Event. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the monitored event to retrieve. + * Format: + * projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run}/monitoredEvents/{monitored_event} + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.hypercomputecluster.v1alpha.MonitoredEvent|MonitoredEvent}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/machine_learning_runs.get_monitored_event.js + * region_tag:hypercomputecluster_v1alpha_generated_MachineLearningRuns_GetMonitoredEvent_async + */ getMonitoredEvent( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IGetMonitoredEventRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent, - protos.google.cloud.hypercomputecluster.v1alpha.IGetMonitoredEventRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.hypercomputecluster.v1alpha.IGetMonitoredEventRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent, + ( + | protos.google.cloud.hypercomputecluster.v1alpha.IGetMonitoredEventRequest + | undefined + ), + {} | undefined, + ] + >; getMonitoredEvent( - request: protos.google.cloud.hypercomputecluster.v1alpha.IGetMonitoredEventRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent, - protos.google.cloud.hypercomputecluster.v1alpha.IGetMonitoredEventRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.hypercomputecluster.v1alpha.IGetMonitoredEventRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent, + | protos.google.cloud.hypercomputecluster.v1alpha.IGetMonitoredEventRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getMonitoredEvent( - request: protos.google.cloud.hypercomputecluster.v1alpha.IGetMonitoredEventRequest, - callback: Callback< - protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent, - protos.google.cloud.hypercomputecluster.v1alpha.IGetMonitoredEventRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.hypercomputecluster.v1alpha.IGetMonitoredEventRequest, + callback: Callback< + protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent, + | protos.google.cloud.hypercomputecluster.v1alpha.IGetMonitoredEventRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getMonitoredEvent( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IGetMonitoredEventRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent, - protos.google.cloud.hypercomputecluster.v1alpha.IGetMonitoredEventRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.hypercomputecluster.v1alpha.IGetMonitoredEventRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent, - protos.google.cloud.hypercomputecluster.v1alpha.IGetMonitoredEventRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent, - protos.google.cloud.hypercomputecluster.v1alpha.IGetMonitoredEventRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.hypercomputecluster.v1alpha.IGetMonitoredEventRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent, + | protos.google.cloud.hypercomputecluster.v1alpha.IGetMonitoredEventRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent, + ( + | protos.google.cloud.hypercomputecluster.v1alpha.IGetMonitoredEventRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getMonitoredEvent request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent, - protos.google.cloud.hypercomputecluster.v1alpha.IGetMonitoredEventRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent, + | protos.google.cloud.hypercomputecluster.v1alpha.IGetMonitoredEventRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getMonitoredEvent response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getMonitoredEvent(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent, - protos.google.cloud.hypercomputecluster.v1alpha.IGetMonitoredEventRequest|undefined, - {}|undefined - ]) => { - this._log.info('getMonitoredEvent response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getMonitoredEvent(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent, + ( + | protos.google.cloud.hypercomputecluster.v1alpha.IGetMonitoredEventRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getMonitoredEvent response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 Machine Learning Run. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent format: projects/{project}/locations/{location} - * @param {google.cloud.hypercomputecluster.v1alpha.MachineLearningRun} request.machineLearningRun - * Required. The Machine Learning Run to create. - * @param {string} [request.machineLearningRunId] - * Optional. The ID of the Machine Learning Run 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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/machine_learning_runs.create_machine_learning_run.js - * region_tag:hypercomputecluster_v1alpha_generated_MachineLearningRuns_CreateMachineLearningRun_async - */ + /** + * Creates a Machine Learning Run. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent format: projects/{project}/locations/{location} + * @param {google.cloud.hypercomputecluster.v1alpha.MachineLearningRun} request.machineLearningRun + * Required. The Machine Learning Run to create. + * @param {string} [request.machineLearningRunId] + * Optional. The ID of the Machine Learning Run 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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/machine_learning_runs.create_machine_learning_run.js + * region_tag:hypercomputecluster_v1alpha_generated_MachineLearningRuns_CreateMachineLearningRun_async + */ createMachineLearningRun( - request?: protos.google.cloud.hypercomputecluster.v1alpha.ICreateMachineLearningRunRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.hypercomputecluster.v1alpha.ICreateMachineLearningRunRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createMachineLearningRun( - request: protos.google.cloud.hypercomputecluster.v1alpha.ICreateMachineLearningRunRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.hypercomputecluster.v1alpha.ICreateMachineLearningRunRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createMachineLearningRun( - request: protos.google.cloud.hypercomputecluster.v1alpha.ICreateMachineLearningRunRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.hypercomputecluster.v1alpha.ICreateMachineLearningRunRequest, + callback: Callback< + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createMachineLearningRun( - request?: protos.google.cloud.hypercomputecluster.v1alpha.ICreateMachineLearningRunRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.hypercomputecluster.v1alpha.ICreateMachineLearningRunRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createMachineLearningRun response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createMachineLearningRun request %j', request); - return this.innerApiCalls.createMachineLearningRun(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createMachineLearningRun response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createMachineLearningRun(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createMachineLearningRun response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createMachineLearningRun()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/machine_learning_runs.create_machine_learning_run.js - * region_tag:hypercomputecluster_v1alpha_generated_MachineLearningRuns_CreateMachineLearningRun_async - */ - async checkCreateMachineLearningRunProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createMachineLearningRun()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/machine_learning_runs.create_machine_learning_run.js + * region_tag:hypercomputecluster_v1alpha_generated_MachineLearningRuns_CreateMachineLearningRun_async + */ + async checkCreateMachineLearningRunProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.MachineLearningRun, + protos.google.cloud.hypercomputecluster.v1alpha.OperationMetadata + > + > { this._log.info('createMachineLearningRun long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createMachineLearningRun, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createMachineLearningRun, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.MachineLearningRun, + protos.google.cloud.hypercomputecluster.v1alpha.OperationMetadata + >; } -/** - * Updates an Machine Learning Run. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.hypercomputecluster.v1alpha.MachineLearningRun} request.machineLearningRun - * Required. The Machine Learning Run to update. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. Used to identify fields to be updated. Allowed fields is *, we - * don't support partial updates. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/machine_learning_runs.update_machine_learning_run.js - * region_tag:hypercomputecluster_v1alpha_generated_MachineLearningRuns_UpdateMachineLearningRun_async - */ + /** + * Updates an Machine Learning Run. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.hypercomputecluster.v1alpha.MachineLearningRun} request.machineLearningRun + * Required. The Machine Learning Run to update. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. Used to identify fields to be updated. Allowed fields is *, we + * don't support partial updates. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/machine_learning_runs.update_machine_learning_run.js + * region_tag:hypercomputecluster_v1alpha_generated_MachineLearningRuns_UpdateMachineLearningRun_async + */ updateMachineLearningRun( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IUpdateMachineLearningRunRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.hypercomputecluster.v1alpha.IUpdateMachineLearningRunRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateMachineLearningRun( - request: protos.google.cloud.hypercomputecluster.v1alpha.IUpdateMachineLearningRunRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.hypercomputecluster.v1alpha.IUpdateMachineLearningRunRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateMachineLearningRun( - request: protos.google.cloud.hypercomputecluster.v1alpha.IUpdateMachineLearningRunRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.hypercomputecluster.v1alpha.IUpdateMachineLearningRunRequest, + callback: Callback< + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateMachineLearningRun( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IUpdateMachineLearningRunRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.hypercomputecluster.v1alpha.IUpdateMachineLearningRunRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'machine_learning_run.name': request.machineLearningRun!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'machine_learning_run.name': request.machineLearningRun!.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.hypercomputecluster.v1alpha.IMachineLearningRun, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateMachineLearningRun response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateMachineLearningRun request %j', request); - return this.innerApiCalls.updateMachineLearningRun(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateMachineLearningRun response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateMachineLearningRun(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateMachineLearningRun response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateMachineLearningRun()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/machine_learning_runs.update_machine_learning_run.js - * region_tag:hypercomputecluster_v1alpha_generated_MachineLearningRuns_UpdateMachineLearningRun_async - */ - async checkUpdateMachineLearningRunProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateMachineLearningRun()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/machine_learning_runs.update_machine_learning_run.js + * region_tag:hypercomputecluster_v1alpha_generated_MachineLearningRuns_UpdateMachineLearningRun_async + */ + async checkUpdateMachineLearningRunProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.MachineLearningRun, + protos.google.cloud.hypercomputecluster.v1alpha.OperationMetadata + > + > { this._log.info('updateMachineLearningRun long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.updateMachineLearningRun, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateMachineLearningRun, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.MachineLearningRun, + protos.google.cloud.hypercomputecluster.v1alpha.OperationMetadata + >; } -/** - * Deletes a Machine Learning Run. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. - * projects/{project}/locations/{location}/machineLearningRuns/{machineLearningRun} - * @param {boolean} [request.force] - * Optional. If force=false and if a user tries to delete an ml run resource - * that still has child resources (e.g., ProfilerTarget), the request should - * fail with a FAILED_PRECONDITION error. If force=true, the delete request - * should delete both parent and child resources that exist. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/machine_learning_runs.delete_machine_learning_run.js - * region_tag:hypercomputecluster_v1alpha_generated_MachineLearningRuns_DeleteMachineLearningRun_async - */ + /** + * Deletes a Machine Learning Run. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. + * projects/{project}/locations/{location}/machineLearningRuns/{machineLearningRun} + * @param {boolean} [request.force] + * Optional. If force=false and if a user tries to delete an ml run resource + * that still has child resources (e.g., ProfilerTarget), the request should + * fail with a FAILED_PRECONDITION error. If force=true, the delete request + * should delete both parent and child resources that exist. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/machine_learning_runs.delete_machine_learning_run.js + * region_tag:hypercomputecluster_v1alpha_generated_MachineLearningRuns_DeleteMachineLearningRun_async + */ deleteMachineLearningRun( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IDeleteMachineLearningRunRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.hypercomputecluster.v1alpha.IDeleteMachineLearningRunRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteMachineLearningRun( - request: protos.google.cloud.hypercomputecluster.v1alpha.IDeleteMachineLearningRunRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.hypercomputecluster.v1alpha.IDeleteMachineLearningRunRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteMachineLearningRun( - request: protos.google.cloud.hypercomputecluster.v1alpha.IDeleteMachineLearningRunRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.hypercomputecluster.v1alpha.IDeleteMachineLearningRunRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteMachineLearningRun( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IDeleteMachineLearningRunRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.hypercomputecluster.v1alpha.IDeleteMachineLearningRunRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteMachineLearningRun response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteMachineLearningRun request %j', request); - return this.innerApiCalls.deleteMachineLearningRun(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteMachineLearningRun response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteMachineLearningRun(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteMachineLearningRun response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteMachineLearningRun()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/machine_learning_runs.delete_machine_learning_run.js - * region_tag:hypercomputecluster_v1alpha_generated_MachineLearningRuns_DeleteMachineLearningRun_async - */ - async checkDeleteMachineLearningRunProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteMachineLearningRun()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/machine_learning_runs.delete_machine_learning_run.js + * region_tag:hypercomputecluster_v1alpha_generated_MachineLearningRuns_DeleteMachineLearningRun_async + */ + async checkDeleteMachineLearningRunProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.hypercomputecluster.v1alpha.OperationMetadata + > + > { this._log.info('deleteMachineLearningRun long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteMachineLearningRun, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteMachineLearningRun, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.hypercomputecluster.v1alpha.OperationMetadata + >; } -/** - * Creates a Profiler Target. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. - * projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run} - * @param {google.cloud.hypercomputecluster.v1alpha.ProfilerTarget} request.profilerTarget - * Required. The Profiler Target to create. - * @param {string} [request.profilerTargetId] - * Optional. If not provided, the server will generate an ID based on hostname - * and node_index. Example: "myhost-0" - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/machine_learning_runs.create_profiler_target.js - * region_tag:hypercomputecluster_v1alpha_generated_MachineLearningRuns_CreateProfilerTarget_async - */ + /** + * Creates a Profiler Target. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. + * projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run} + * @param {google.cloud.hypercomputecluster.v1alpha.ProfilerTarget} request.profilerTarget + * Required. The Profiler Target to create. + * @param {string} [request.profilerTargetId] + * Optional. If not provided, the server will generate an ID based on hostname + * and node_index. Example: "myhost-0" + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/machine_learning_runs.create_profiler_target.js + * region_tag:hypercomputecluster_v1alpha_generated_MachineLearningRuns_CreateProfilerTarget_async + */ createProfilerTarget( - request?: protos.google.cloud.hypercomputecluster.v1alpha.ICreateProfilerTargetRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.hypercomputecluster.v1alpha.ICreateProfilerTargetRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IProfilerTarget, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createProfilerTarget( - request: protos.google.cloud.hypercomputecluster.v1alpha.ICreateProfilerTargetRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.hypercomputecluster.v1alpha.ICreateProfilerTargetRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IProfilerTarget, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createProfilerTarget( - request: protos.google.cloud.hypercomputecluster.v1alpha.ICreateProfilerTargetRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.hypercomputecluster.v1alpha.ICreateProfilerTargetRequest, + callback: Callback< + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IProfilerTarget, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createProfilerTarget( - request?: protos.google.cloud.hypercomputecluster.v1alpha.ICreateProfilerTargetRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.hypercomputecluster.v1alpha.ICreateProfilerTargetRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IProfilerTarget, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IProfilerTarget, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IProfilerTarget, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IProfilerTarget, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createProfilerTarget response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createProfilerTarget request %j', request); - return this.innerApiCalls.createProfilerTarget(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createProfilerTarget response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createProfilerTarget(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IProfilerTarget, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createProfilerTarget response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createProfilerTarget()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/machine_learning_runs.create_profiler_target.js - * region_tag:hypercomputecluster_v1alpha_generated_MachineLearningRuns_CreateProfilerTarget_async - */ - async checkCreateProfilerTargetProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createProfilerTarget()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/machine_learning_runs.create_profiler_target.js + * region_tag:hypercomputecluster_v1alpha_generated_MachineLearningRuns_CreateProfilerTarget_async + */ + async checkCreateProfilerTargetProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.ProfilerTarget, + protos.google.cloud.hypercomputecluster.v1alpha.OperationMetadata + > + > { this._log.info('createProfilerTarget long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createProfilerTarget, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createProfilerTarget, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.ProfilerTarget, + protos.google.cloud.hypercomputecluster.v1alpha.OperationMetadata + >; } -/** - * Create a Profiler Session. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. - * projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run} - * @param {string} [request.profilerSessionId] - * Optional. ID for the profiler session. - * @param {google.cloud.hypercomputecluster.v1alpha.ProfilerSession} request.profilerSession - * Required. The Profiler Session 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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/machine_learning_runs.create_profiler_session.js - * region_tag:hypercomputecluster_v1alpha_generated_MachineLearningRuns_CreateProfilerSession_async - */ + /** + * Create a Profiler Session. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. + * projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run} + * @param {string} [request.profilerSessionId] + * Optional. ID for the profiler session. + * @param {google.cloud.hypercomputecluster.v1alpha.ProfilerSession} request.profilerSession + * Required. The Profiler Session 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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/machine_learning_runs.create_profiler_session.js + * region_tag:hypercomputecluster_v1alpha_generated_MachineLearningRuns_CreateProfilerSession_async + */ createProfilerSession( - request?: protos.google.cloud.hypercomputecluster.v1alpha.ICreateProfilerSessionRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.hypercomputecluster.v1alpha.ICreateProfilerSessionRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IProfilerSession, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createProfilerSession( - request: protos.google.cloud.hypercomputecluster.v1alpha.ICreateProfilerSessionRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.hypercomputecluster.v1alpha.ICreateProfilerSessionRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IProfilerSession, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createProfilerSession( - request: protos.google.cloud.hypercomputecluster.v1alpha.ICreateProfilerSessionRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.hypercomputecluster.v1alpha.ICreateProfilerSessionRequest, + callback: Callback< + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IProfilerSession, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createProfilerSession( - request?: protos.google.cloud.hypercomputecluster.v1alpha.ICreateProfilerSessionRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.hypercomputecluster.v1alpha.ICreateProfilerSessionRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IProfilerSession, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IProfilerSession, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IProfilerSession, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IProfilerSession, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createProfilerSession response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createProfilerSession request %j', request); - return this.innerApiCalls.createProfilerSession(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createProfilerSession response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createProfilerSession(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IProfilerSession, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createProfilerSession response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createProfilerSession()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/machine_learning_runs.create_profiler_session.js - * region_tag:hypercomputecluster_v1alpha_generated_MachineLearningRuns_CreateProfilerSession_async - */ - async checkCreateProfilerSessionProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createProfilerSession()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/machine_learning_runs.create_profiler_session.js + * region_tag:hypercomputecluster_v1alpha_generated_MachineLearningRuns_CreateProfilerSession_async + */ + async checkCreateProfilerSessionProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.ProfilerSession, + protos.google.cloud.hypercomputecluster.v1alpha.OperationMetadata + > + > { this._log.info('createProfilerSession long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createProfilerSession, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createProfilerSession, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.ProfilerSession, + protos.google.cloud.hypercomputecluster.v1alpha.OperationMetadata + >; } -/** - * Creates a Monitored Event. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent resource where the event will be created. - * Format: - * projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run} - * @param {google.cloud.hypercomputecluster.v1alpha.MonitoredEvent} request.monitoredEvent - * Required. The event resource to create. - * @param {string} [request.monitoredEventId] - * Optional. Optional ID for the event. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/machine_learning_runs.create_monitored_event.js - * region_tag:hypercomputecluster_v1alpha_generated_MachineLearningRuns_CreateMonitoredEvent_async - */ + /** + * Creates a Monitored Event. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent resource where the event will be created. + * Format: + * projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run} + * @param {google.cloud.hypercomputecluster.v1alpha.MonitoredEvent} request.monitoredEvent + * Required. The event resource to create. + * @param {string} [request.monitoredEventId] + * Optional. Optional ID for the event. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/machine_learning_runs.create_monitored_event.js + * region_tag:hypercomputecluster_v1alpha_generated_MachineLearningRuns_CreateMonitoredEvent_async + */ createMonitoredEvent( - request?: protos.google.cloud.hypercomputecluster.v1alpha.ICreateMonitoredEventRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.hypercomputecluster.v1alpha.ICreateMonitoredEventRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createMonitoredEvent( - request: protos.google.cloud.hypercomputecluster.v1alpha.ICreateMonitoredEventRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.hypercomputecluster.v1alpha.ICreateMonitoredEventRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createMonitoredEvent( - request: protos.google.cloud.hypercomputecluster.v1alpha.ICreateMonitoredEventRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.hypercomputecluster.v1alpha.ICreateMonitoredEventRequest, + callback: Callback< + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createMonitoredEvent( - request?: protos.google.cloud.hypercomputecluster.v1alpha.ICreateMonitoredEventRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.hypercomputecluster.v1alpha.ICreateMonitoredEventRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createMonitoredEvent response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createMonitoredEvent request %j', request); - return this.innerApiCalls.createMonitoredEvent(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createMonitoredEvent response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createMonitoredEvent(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createMonitoredEvent response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createMonitoredEvent()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/machine_learning_runs.create_monitored_event.js - * region_tag:hypercomputecluster_v1alpha_generated_MachineLearningRuns_CreateMonitoredEvent_async - */ - async checkCreateMonitoredEventProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createMonitoredEvent()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/machine_learning_runs.create_monitored_event.js + * region_tag:hypercomputecluster_v1alpha_generated_MachineLearningRuns_CreateMonitoredEvent_async + */ + async checkCreateMonitoredEventProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.MonitoredEvent, + protos.google.cloud.hypercomputecluster.v1alpha.OperationMetadata + > + > { this._log.info('createMonitoredEvent long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createMonitoredEvent, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createMonitoredEvent, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.MonitoredEvent, + protos.google.cloud.hypercomputecluster.v1alpha.OperationMetadata + >; } -/** - * Updates a Monitored Event. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.hypercomputecluster.v1alpha.MonitoredEvent} request.monitoredEvent - * Required. The monitored event to update. - * - * The event's `name` field is used to identify the event to be updated. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. 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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/machine_learning_runs.update_monitored_event.js - * region_tag:hypercomputecluster_v1alpha_generated_MachineLearningRuns_UpdateMonitoredEvent_async - */ + /** + * Updates a Monitored Event. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.hypercomputecluster.v1alpha.MonitoredEvent} request.monitoredEvent + * Required. The monitored event to update. + * + * The event's `name` field is used to identify the event to be updated. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. 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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/machine_learning_runs.update_monitored_event.js + * region_tag:hypercomputecluster_v1alpha_generated_MachineLearningRuns_UpdateMonitoredEvent_async + */ updateMonitoredEvent( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IUpdateMonitoredEventRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.hypercomputecluster.v1alpha.IUpdateMonitoredEventRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateMonitoredEvent( - request: protos.google.cloud.hypercomputecluster.v1alpha.IUpdateMonitoredEventRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.hypercomputecluster.v1alpha.IUpdateMonitoredEventRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateMonitoredEvent( - request: protos.google.cloud.hypercomputecluster.v1alpha.IUpdateMonitoredEventRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.hypercomputecluster.v1alpha.IUpdateMonitoredEventRequest, + callback: Callback< + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateMonitoredEvent( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IUpdateMonitoredEventRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.hypercomputecluster.v1alpha.IUpdateMonitoredEventRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'monitored_event.name': request.monitoredEvent!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'monitored_event.name': request.monitoredEvent!.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.hypercomputecluster.v1alpha.IMonitoredEvent, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateMonitoredEvent response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateMonitoredEvent request %j', request); - return this.innerApiCalls.updateMonitoredEvent(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateMonitoredEvent response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateMonitoredEvent(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateMonitoredEvent response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateMonitoredEvent()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/machine_learning_runs.update_monitored_event.js - * region_tag:hypercomputecluster_v1alpha_generated_MachineLearningRuns_UpdateMonitoredEvent_async - */ - async checkUpdateMonitoredEventProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateMonitoredEvent()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/machine_learning_runs.update_monitored_event.js + * region_tag:hypercomputecluster_v1alpha_generated_MachineLearningRuns_UpdateMonitoredEvent_async + */ + async checkUpdateMonitoredEventProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.MonitoredEvent, + protos.google.cloud.hypercomputecluster.v1alpha.OperationMetadata + > + > { this._log.info('updateMonitoredEvent long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.updateMonitoredEvent, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateMonitoredEvent, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.MonitoredEvent, + protos.google.cloud.hypercomputecluster.v1alpha.OperationMetadata + >; } -/** - * Deletes a Monitored Event. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the monitored event to delete. - * Format: - * projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run}/monitoredEvents/{monitored_event} - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/machine_learning_runs.delete_monitored_event.js - * region_tag:hypercomputecluster_v1alpha_generated_MachineLearningRuns_DeleteMonitoredEvent_async - */ + /** + * Deletes a Monitored Event. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the monitored event to delete. + * Format: + * projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run}/monitoredEvents/{monitored_event} + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/machine_learning_runs.delete_monitored_event.js + * region_tag:hypercomputecluster_v1alpha_generated_MachineLearningRuns_DeleteMonitoredEvent_async + */ deleteMonitoredEvent( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IDeleteMonitoredEventRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.hypercomputecluster.v1alpha.IDeleteMonitoredEventRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteMonitoredEvent( - request: protos.google.cloud.hypercomputecluster.v1alpha.IDeleteMonitoredEventRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.hypercomputecluster.v1alpha.IDeleteMonitoredEventRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteMonitoredEvent( - request: protos.google.cloud.hypercomputecluster.v1alpha.IDeleteMonitoredEventRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.hypercomputecluster.v1alpha.IDeleteMonitoredEventRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteMonitoredEvent( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IDeleteMonitoredEventRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.hypercomputecluster.v1alpha.IDeleteMonitoredEventRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteMonitoredEvent response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteMonitoredEvent request %j', request); - return this.innerApiCalls.deleteMonitoredEvent(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteMonitoredEvent response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteMonitoredEvent(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteMonitoredEvent response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteMonitoredEvent()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/machine_learning_runs.delete_monitored_event.js - * region_tag:hypercomputecluster_v1alpha_generated_MachineLearningRuns_DeleteMonitoredEvent_async - */ - async checkDeleteMonitoredEventProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteMonitoredEvent()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/machine_learning_runs.delete_monitored_event.js + * region_tag:hypercomputecluster_v1alpha_generated_MachineLearningRuns_DeleteMonitoredEvent_async + */ + async checkDeleteMonitoredEventProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.hypercomputecluster.v1alpha.OperationMetadata + > + > { this._log.info('deleteMonitoredEvent long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteMonitoredEvent, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists Machine Learning Runs. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. projects/{project}/locations/{location} - * @param {number} [request.pageSize] - * Optional. The maximum number of Machine Learning Runs to return. The - * service may return fewer than this value. If unspecified, at most 10 - * Machine Learning Runs will be returned. The maximum value is 1000; values - * above 1000 will be coerced to 1000. Please refer to - * https://google.aip.dev/158 for more details. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListMachineLearningRuns` - * call. Provide this to retrieve the subsequent page. Please refer to - * https://google.aip.dev/158 for more details. - * @param {string} [request.filter] - * Optional. An expression for filtering the results of the request. - * - * Supported filter fields are: - * - run_id (string): The ID of the run (e.g., "run-1"). - * - run_set (string): The run set (e.g., "run-set-1"). - * - display_name (string): The display name of the run (e.g., - * "display-name-1"). - * - state (enum): The state of the run (e.g., "STATE_COMPLETED"). - * - region (string): The region of the run (e.g., "us-central1"). - * - orchestrator (enum): The orchestrator used for the run (e.g., - * "ORCHESTRATOR_GKE"). - * - create_time (timestamp): The creation timestamp of the run. - * - update_time (timestamp): The last update timestamp of the run. - * - etag (string): The ETag of the run. - * - * Filter expressions can be combined using "AND" and "OR" operators. - * - * Examples: - * - * To filter by a single field: - * - * `run_set = "run-set-1"` - * `state = "STATE_ACTIVE"` - * - * To filter by multiple fields: - * - * `run_set = "run-set-1" AND state = "STATE_ACTIVE"` - * `region = "us-central1" AND orchestrator = "ORCHESTRATOR_GKE"` - * - * To filter by timestamp: - * - * `create_time > "2025-05-26T10:00:00Z"` - * @param {string} [request.orderBy] - * Optional. A comma-separated list of fields to order by, sorted in ascending - * order. Use "desc" after a field name for descending. - * - * Supported fields: - * - * * `run_id` - * * `run_set` - * * `display_name` - * * `region` - * * `orchestrator` - * * `state` - * * `create_time` - * * `update_time` - * - * Example: `update_time desc, 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.hypercomputecluster.v1alpha.MachineLearningRun|MachineLearningRun}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listMachineLearningRunsAsync()` - * method described below for async iteration which you can stop as 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.deleteMonitoredEvent, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.hypercomputecluster.v1alpha.OperationMetadata + >; + } + /** + * Lists Machine Learning Runs. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. projects/{project}/locations/{location} + * @param {number} [request.pageSize] + * Optional. The maximum number of Machine Learning Runs to return. The + * service may return fewer than this value. If unspecified, at most 10 + * Machine Learning Runs will be returned. The maximum value is 1000; values + * above 1000 will be coerced to 1000. Please refer to + * https://google.aip.dev/158 for more details. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListMachineLearningRuns` + * call. Provide this to retrieve the subsequent page. Please refer to + * https://google.aip.dev/158 for more details. + * @param {string} [request.filter] + * Optional. An expression for filtering the results of the request. + * + * Supported filter fields are: + * - run_id (string): The ID of the run (e.g., "run-1"). + * - run_set (string): The run set (e.g., "run-set-1"). + * - display_name (string): The display name of the run (e.g., + * "display-name-1"). + * - state (enum): The state of the run (e.g., "STATE_COMPLETED"). + * - region (string): The region of the run (e.g., "us-central1"). + * - orchestrator (enum): The orchestrator used for the run (e.g., + * "ORCHESTRATOR_GKE"). + * - create_time (timestamp): The creation timestamp of the run. + * - update_time (timestamp): The last update timestamp of the run. + * - etag (string): The ETag of the run. + * + * Filter expressions can be combined using "AND" and "OR" operators. + * + * Examples: + * + * To filter by a single field: + * + * `run_set = "run-set-1"` + * `state = "STATE_ACTIVE"` + * + * To filter by multiple fields: + * + * `run_set = "run-set-1" AND state = "STATE_ACTIVE"` + * `region = "us-central1" AND orchestrator = "ORCHESTRATOR_GKE"` + * + * To filter by timestamp: + * + * `create_time > "2025-05-26T10:00:00Z"` + * @param {string} [request.orderBy] + * Optional. A comma-separated list of fields to order by, sorted in ascending + * order. Use "desc" after a field name for descending. + * + * Supported fields: + * + * * `run_id` + * * `run_set` + * * `display_name` + * * `region` + * * `orchestrator` + * * `state` + * * `create_time` + * * `update_time` + * + * Example: `update_time desc, 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.hypercomputecluster.v1alpha.MachineLearningRun|MachineLearningRun}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listMachineLearningRunsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listMachineLearningRuns( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IListMachineLearningRunsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun[], - protos.google.cloud.hypercomputecluster.v1alpha.IListMachineLearningRunsRequest|null, - protos.google.cloud.hypercomputecluster.v1alpha.IListMachineLearningRunsResponse - ]>; + request?: protos.google.cloud.hypercomputecluster.v1alpha.IListMachineLearningRunsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun[], + protos.google.cloud.hypercomputecluster.v1alpha.IListMachineLearningRunsRequest | null, + protos.google.cloud.hypercomputecluster.v1alpha.IListMachineLearningRunsResponse, + ] + >; listMachineLearningRuns( - request: protos.google.cloud.hypercomputecluster.v1alpha.IListMachineLearningRunsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.hypercomputecluster.v1alpha.IListMachineLearningRunsRequest, - protos.google.cloud.hypercomputecluster.v1alpha.IListMachineLearningRunsResponse|null|undefined, - protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun>): void; + request: protos.google.cloud.hypercomputecluster.v1alpha.IListMachineLearningRunsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.hypercomputecluster.v1alpha.IListMachineLearningRunsRequest, + | protos.google.cloud.hypercomputecluster.v1alpha.IListMachineLearningRunsResponse + | null + | undefined, + protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun + >, + ): void; listMachineLearningRuns( - request: protos.google.cloud.hypercomputecluster.v1alpha.IListMachineLearningRunsRequest, - callback: PaginationCallback< - protos.google.cloud.hypercomputecluster.v1alpha.IListMachineLearningRunsRequest, - protos.google.cloud.hypercomputecluster.v1alpha.IListMachineLearningRunsResponse|null|undefined, - protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun>): void; + request: protos.google.cloud.hypercomputecluster.v1alpha.IListMachineLearningRunsRequest, + callback: PaginationCallback< + protos.google.cloud.hypercomputecluster.v1alpha.IListMachineLearningRunsRequest, + | protos.google.cloud.hypercomputecluster.v1alpha.IListMachineLearningRunsResponse + | null + | undefined, + protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun + >, + ): void; listMachineLearningRuns( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IListMachineLearningRunsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.hypercomputecluster.v1alpha.IListMachineLearningRunsRequest, - protos.google.cloud.hypercomputecluster.v1alpha.IListMachineLearningRunsResponse|null|undefined, - protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun>, - callback?: PaginationCallback< + request?: protos.google.cloud.hypercomputecluster.v1alpha.IListMachineLearningRunsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.hypercomputecluster.v1alpha.IListMachineLearningRunsRequest, - protos.google.cloud.hypercomputecluster.v1alpha.IListMachineLearningRunsResponse|null|undefined, - protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun>): - Promise<[ - protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun[], - protos.google.cloud.hypercomputecluster.v1alpha.IListMachineLearningRunsRequest|null, - protos.google.cloud.hypercomputecluster.v1alpha.IListMachineLearningRunsResponse - ]>|void { + | protos.google.cloud.hypercomputecluster.v1alpha.IListMachineLearningRunsResponse + | null + | undefined, + protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun + >, + callback?: PaginationCallback< + protos.google.cloud.hypercomputecluster.v1alpha.IListMachineLearningRunsRequest, + | protos.google.cloud.hypercomputecluster.v1alpha.IListMachineLearningRunsResponse + | null + | undefined, + protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun + >, + ): Promise< + [ + protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun[], + protos.google.cloud.hypercomputecluster.v1alpha.IListMachineLearningRunsRequest | null, + protos.google.cloud.hypercomputecluster.v1alpha.IListMachineLearningRunsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-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.hypercomputecluster.v1alpha.IListMachineLearningRunsRequest, - protos.google.cloud.hypercomputecluster.v1alpha.IListMachineLearningRunsResponse|null|undefined, - protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.hypercomputecluster.v1alpha.IListMachineLearningRunsRequest, + | protos.google.cloud.hypercomputecluster.v1alpha.IListMachineLearningRunsResponse + | null + | undefined, + protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listMachineLearningRuns values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -2165,306 +3185,335 @@ export class MachineLearningRunsClient { this._log.info('listMachineLearningRuns request %j', request); return this.innerApiCalls .listMachineLearningRuns(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun[], - protos.google.cloud.hypercomputecluster.v1alpha.IListMachineLearningRunsRequest|null, - protos.google.cloud.hypercomputecluster.v1alpha.IListMachineLearningRunsResponse - ]) => { - this._log.info('listMachineLearningRuns values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun[], + protos.google.cloud.hypercomputecluster.v1alpha.IListMachineLearningRunsRequest | null, + protos.google.cloud.hypercomputecluster.v1alpha.IListMachineLearningRunsResponse, + ]) => { + this._log.info('listMachineLearningRuns values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listMachineLearningRuns`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. projects/{project}/locations/{location} - * @param {number} [request.pageSize] - * Optional. The maximum number of Machine Learning Runs to return. The - * service may return fewer than this value. If unspecified, at most 10 - * Machine Learning Runs will be returned. The maximum value is 1000; values - * above 1000 will be coerced to 1000. Please refer to - * https://google.aip.dev/158 for more details. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListMachineLearningRuns` - * call. Provide this to retrieve the subsequent page. Please refer to - * https://google.aip.dev/158 for more details. - * @param {string} [request.filter] - * Optional. An expression for filtering the results of the request. - * - * Supported filter fields are: - * - run_id (string): The ID of the run (e.g., "run-1"). - * - run_set (string): The run set (e.g., "run-set-1"). - * - display_name (string): The display name of the run (e.g., - * "display-name-1"). - * - state (enum): The state of the run (e.g., "STATE_COMPLETED"). - * - region (string): The region of the run (e.g., "us-central1"). - * - orchestrator (enum): The orchestrator used for the run (e.g., - * "ORCHESTRATOR_GKE"). - * - create_time (timestamp): The creation timestamp of the run. - * - update_time (timestamp): The last update timestamp of the run. - * - etag (string): The ETag of the run. - * - * Filter expressions can be combined using "AND" and "OR" operators. - * - * Examples: - * - * To filter by a single field: - * - * `run_set = "run-set-1"` - * `state = "STATE_ACTIVE"` - * - * To filter by multiple fields: - * - * `run_set = "run-set-1" AND state = "STATE_ACTIVE"` - * `region = "us-central1" AND orchestrator = "ORCHESTRATOR_GKE"` - * - * To filter by timestamp: - * - * `create_time > "2025-05-26T10:00:00Z"` - * @param {string} [request.orderBy] - * Optional. A comma-separated list of fields to order by, sorted in ascending - * order. Use "desc" after a field name for descending. - * - * Supported fields: - * - * * `run_id` - * * `run_set` - * * `display_name` - * * `region` - * * `orchestrator` - * * `state` - * * `create_time` - * * `update_time` - * - * Example: `update_time desc, 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.hypercomputecluster.v1alpha.MachineLearningRun|MachineLearningRun} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listMachineLearningRunsAsync()` - * method described below for async iteration which you can stop as 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 `listMachineLearningRuns`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. projects/{project}/locations/{location} + * @param {number} [request.pageSize] + * Optional. The maximum number of Machine Learning Runs to return. The + * service may return fewer than this value. If unspecified, at most 10 + * Machine Learning Runs will be returned. The maximum value is 1000; values + * above 1000 will be coerced to 1000. Please refer to + * https://google.aip.dev/158 for more details. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListMachineLearningRuns` + * call. Provide this to retrieve the subsequent page. Please refer to + * https://google.aip.dev/158 for more details. + * @param {string} [request.filter] + * Optional. An expression for filtering the results of the request. + * + * Supported filter fields are: + * - run_id (string): The ID of the run (e.g., "run-1"). + * - run_set (string): The run set (e.g., "run-set-1"). + * - display_name (string): The display name of the run (e.g., + * "display-name-1"). + * - state (enum): The state of the run (e.g., "STATE_COMPLETED"). + * - region (string): The region of the run (e.g., "us-central1"). + * - orchestrator (enum): The orchestrator used for the run (e.g., + * "ORCHESTRATOR_GKE"). + * - create_time (timestamp): The creation timestamp of the run. + * - update_time (timestamp): The last update timestamp of the run. + * - etag (string): The ETag of the run. + * + * Filter expressions can be combined using "AND" and "OR" operators. + * + * Examples: + * + * To filter by a single field: + * + * `run_set = "run-set-1"` + * `state = "STATE_ACTIVE"` + * + * To filter by multiple fields: + * + * `run_set = "run-set-1" AND state = "STATE_ACTIVE"` + * `region = "us-central1" AND orchestrator = "ORCHESTRATOR_GKE"` + * + * To filter by timestamp: + * + * `create_time > "2025-05-26T10:00:00Z"` + * @param {string} [request.orderBy] + * Optional. A comma-separated list of fields to order by, sorted in ascending + * order. Use "desc" after a field name for descending. + * + * Supported fields: + * + * * `run_id` + * * `run_set` + * * `display_name` + * * `region` + * * `orchestrator` + * * `state` + * * `create_time` + * * `update_time` + * + * Example: `update_time desc, 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.hypercomputecluster.v1alpha.MachineLearningRun|MachineLearningRun} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listMachineLearningRunsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listMachineLearningRunsStream( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IListMachineLearningRunsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.hypercomputecluster.v1alpha.IListMachineLearningRunsRequest, + 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['listMachineLearningRuns']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listMachineLearningRuns stream %j', request); return this.descriptors.page.listMachineLearningRuns.createStream( this.innerApiCalls.listMachineLearningRuns as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listMachineLearningRuns`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. projects/{project}/locations/{location} - * @param {number} [request.pageSize] - * Optional. The maximum number of Machine Learning Runs to return. The - * service may return fewer than this value. If unspecified, at most 10 - * Machine Learning Runs will be returned. The maximum value is 1000; values - * above 1000 will be coerced to 1000. Please refer to - * https://google.aip.dev/158 for more details. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListMachineLearningRuns` - * call. Provide this to retrieve the subsequent page. Please refer to - * https://google.aip.dev/158 for more details. - * @param {string} [request.filter] - * Optional. An expression for filtering the results of the request. - * - * Supported filter fields are: - * - run_id (string): The ID of the run (e.g., "run-1"). - * - run_set (string): The run set (e.g., "run-set-1"). - * - display_name (string): The display name of the run (e.g., - * "display-name-1"). - * - state (enum): The state of the run (e.g., "STATE_COMPLETED"). - * - region (string): The region of the run (e.g., "us-central1"). - * - orchestrator (enum): The orchestrator used for the run (e.g., - * "ORCHESTRATOR_GKE"). - * - create_time (timestamp): The creation timestamp of the run. - * - update_time (timestamp): The last update timestamp of the run. - * - etag (string): The ETag of the run. - * - * Filter expressions can be combined using "AND" and "OR" operators. - * - * Examples: - * - * To filter by a single field: - * - * `run_set = "run-set-1"` - * `state = "STATE_ACTIVE"` - * - * To filter by multiple fields: - * - * `run_set = "run-set-1" AND state = "STATE_ACTIVE"` - * `region = "us-central1" AND orchestrator = "ORCHESTRATOR_GKE"` - * - * To filter by timestamp: - * - * `create_time > "2025-05-26T10:00:00Z"` - * @param {string} [request.orderBy] - * Optional. A comma-separated list of fields to order by, sorted in ascending - * order. Use "desc" after a field name for descending. - * - * Supported fields: - * - * * `run_id` - * * `run_set` - * * `display_name` - * * `region` - * * `orchestrator` - * * `state` - * * `create_time` - * * `update_time` - * - * Example: `update_time desc, 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.hypercomputecluster.v1alpha.MachineLearningRun|MachineLearningRun}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/machine_learning_runs.list_machine_learning_runs.js - * region_tag:hypercomputecluster_v1alpha_generated_MachineLearningRuns_ListMachineLearningRuns_async - */ + /** + * Equivalent to `listMachineLearningRuns`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. projects/{project}/locations/{location} + * @param {number} [request.pageSize] + * Optional. The maximum number of Machine Learning Runs to return. The + * service may return fewer than this value. If unspecified, at most 10 + * Machine Learning Runs will be returned. The maximum value is 1000; values + * above 1000 will be coerced to 1000. Please refer to + * https://google.aip.dev/158 for more details. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListMachineLearningRuns` + * call. Provide this to retrieve the subsequent page. Please refer to + * https://google.aip.dev/158 for more details. + * @param {string} [request.filter] + * Optional. An expression for filtering the results of the request. + * + * Supported filter fields are: + * - run_id (string): The ID of the run (e.g., "run-1"). + * - run_set (string): The run set (e.g., "run-set-1"). + * - display_name (string): The display name of the run (e.g., + * "display-name-1"). + * - state (enum): The state of the run (e.g., "STATE_COMPLETED"). + * - region (string): The region of the run (e.g., "us-central1"). + * - orchestrator (enum): The orchestrator used for the run (e.g., + * "ORCHESTRATOR_GKE"). + * - create_time (timestamp): The creation timestamp of the run. + * - update_time (timestamp): The last update timestamp of the run. + * - etag (string): The ETag of the run. + * + * Filter expressions can be combined using "AND" and "OR" operators. + * + * Examples: + * + * To filter by a single field: + * + * `run_set = "run-set-1"` + * `state = "STATE_ACTIVE"` + * + * To filter by multiple fields: + * + * `run_set = "run-set-1" AND state = "STATE_ACTIVE"` + * `region = "us-central1" AND orchestrator = "ORCHESTRATOR_GKE"` + * + * To filter by timestamp: + * + * `create_time > "2025-05-26T10:00:00Z"` + * @param {string} [request.orderBy] + * Optional. A comma-separated list of fields to order by, sorted in ascending + * order. Use "desc" after a field name for descending. + * + * Supported fields: + * + * * `run_id` + * * `run_set` + * * `display_name` + * * `region` + * * `orchestrator` + * * `state` + * * `create_time` + * * `update_time` + * + * Example: `update_time desc, 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.hypercomputecluster.v1alpha.MachineLearningRun|MachineLearningRun}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/machine_learning_runs.list_machine_learning_runs.js + * region_tag:hypercomputecluster_v1alpha_generated_MachineLearningRuns_ListMachineLearningRuns_async + */ listMachineLearningRunsAsync( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IListMachineLearningRunsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.hypercomputecluster.v1alpha.IListMachineLearningRunsRequest, + 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['listMachineLearningRuns']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listMachineLearningRuns iterate %j', request); return this.descriptors.page.listMachineLearningRuns.asyncIterate( this.innerApiCalls['listMachineLearningRuns'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * List Profiler Targets for a Machine Learning Run. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. - * projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run} - * @param {number} [request.pageSize] - * Optional. The maximum number of profiler targets to return. The service may - * return fewer than this value. If unspecified, at most 10 profiler targets - * will be returned. The maximum value is 1000; values above 1000 will be - * coerced to 1000. Please refer to https://google.aip.dev/158 for more - * details. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListProfilerTargets` - * call. Provide this to retrieve the subsequent page. Please refer to - * https://google.aip.dev/158 for more details. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link protos.google.cloud.hypercomputecluster.v1alpha.ProfilerTarget|ProfilerTarget}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listProfilerTargetsAsync()` - * method described below for async iteration which you can stop as 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 Profiler Targets for a Machine Learning Run. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. + * projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run} + * @param {number} [request.pageSize] + * Optional. The maximum number of profiler targets to return. The service may + * return fewer than this value. If unspecified, at most 10 profiler targets + * will be returned. The maximum value is 1000; values above 1000 will be + * coerced to 1000. Please refer to https://google.aip.dev/158 for more + * details. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListProfilerTargets` + * call. Provide this to retrieve the subsequent page. Please refer to + * https://google.aip.dev/158 for more details. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.hypercomputecluster.v1alpha.ProfilerTarget|ProfilerTarget}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listProfilerTargetsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listProfilerTargets( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerTargetsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.hypercomputecluster.v1alpha.IProfilerTarget[], - protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerTargetsRequest|null, - protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerTargetsResponse - ]>; + request?: protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerTargetsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.hypercomputecluster.v1alpha.IProfilerTarget[], + protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerTargetsRequest | null, + protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerTargetsResponse, + ] + >; listProfilerTargets( - request: protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerTargetsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerTargetsRequest, - protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerTargetsResponse|null|undefined, - protos.google.cloud.hypercomputecluster.v1alpha.IProfilerTarget>): void; + request: protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerTargetsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerTargetsRequest, + | protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerTargetsResponse + | null + | undefined, + protos.google.cloud.hypercomputecluster.v1alpha.IProfilerTarget + >, + ): void; listProfilerTargets( - request: protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerTargetsRequest, - callback: PaginationCallback< - protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerTargetsRequest, - protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerTargetsResponse|null|undefined, - protos.google.cloud.hypercomputecluster.v1alpha.IProfilerTarget>): void; + request: protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerTargetsRequest, + callback: PaginationCallback< + protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerTargetsRequest, + | protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerTargetsResponse + | null + | undefined, + protos.google.cloud.hypercomputecluster.v1alpha.IProfilerTarget + >, + ): void; listProfilerTargets( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerTargetsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerTargetsRequest, - protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerTargetsResponse|null|undefined, - protos.google.cloud.hypercomputecluster.v1alpha.IProfilerTarget>, - callback?: PaginationCallback< + request?: protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerTargetsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerTargetsRequest, - protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerTargetsResponse|null|undefined, - protos.google.cloud.hypercomputecluster.v1alpha.IProfilerTarget>): - Promise<[ - protos.google.cloud.hypercomputecluster.v1alpha.IProfilerTarget[], - protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerTargetsRequest|null, - protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerTargetsResponse - ]>|void { + | protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerTargetsResponse + | null + | undefined, + protos.google.cloud.hypercomputecluster.v1alpha.IProfilerTarget + >, + callback?: PaginationCallback< + protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerTargetsRequest, + | protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerTargetsResponse + | null + | undefined, + protos.google.cloud.hypercomputecluster.v1alpha.IProfilerTarget + >, + ): Promise< + [ + protos.google.cloud.hypercomputecluster.v1alpha.IProfilerTarget[], + protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerTargetsRequest | null, + protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerTargetsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-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.hypercomputecluster.v1alpha.IListProfilerTargetsRequest, - protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerTargetsResponse|null|undefined, - protos.google.cloud.hypercomputecluster.v1alpha.IProfilerTarget>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerTargetsRequest, + | protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerTargetsResponse + | null + | undefined, + protos.google.cloud.hypercomputecluster.v1alpha.IProfilerTarget + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listProfilerTargets values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -2473,210 +3522,239 @@ export class MachineLearningRunsClient { this._log.info('listProfilerTargets request %j', request); return this.innerApiCalls .listProfilerTargets(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.hypercomputecluster.v1alpha.IProfilerTarget[], - protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerTargetsRequest|null, - protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerTargetsResponse - ]) => { - this._log.info('listProfilerTargets values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.hypercomputecluster.v1alpha.IProfilerTarget[], + protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerTargetsRequest | null, + protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerTargetsResponse, + ]) => { + this._log.info('listProfilerTargets values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listProfilerTargets`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. - * projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run} - * @param {number} [request.pageSize] - * Optional. The maximum number of profiler targets to return. The service may - * return fewer than this value. If unspecified, at most 10 profiler targets - * will be returned. The maximum value is 1000; values above 1000 will be - * coerced to 1000. Please refer to https://google.aip.dev/158 for more - * details. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListProfilerTargets` - * call. Provide this to retrieve the subsequent page. Please refer to - * https://google.aip.dev/158 for more details. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.hypercomputecluster.v1alpha.ProfilerTarget|ProfilerTarget} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listProfilerTargetsAsync()` - * method described below for async iteration which you can stop as 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 `listProfilerTargets`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. + * projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run} + * @param {number} [request.pageSize] + * Optional. The maximum number of profiler targets to return. The service may + * return fewer than this value. If unspecified, at most 10 profiler targets + * will be returned. The maximum value is 1000; values above 1000 will be + * coerced to 1000. Please refer to https://google.aip.dev/158 for more + * details. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListProfilerTargets` + * call. Provide this to retrieve the subsequent page. Please refer to + * https://google.aip.dev/158 for more details. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.hypercomputecluster.v1alpha.ProfilerTarget|ProfilerTarget} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listProfilerTargetsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listProfilerTargetsStream( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerTargetsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerTargetsRequest, + 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['listProfilerTargets']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listProfilerTargets stream %j', request); return this.descriptors.page.listProfilerTargets.createStream( this.innerApiCalls.listProfilerTargets as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listProfilerTargets`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. - * projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run} - * @param {number} [request.pageSize] - * Optional. The maximum number of profiler targets to return. The service may - * return fewer than this value. If unspecified, at most 10 profiler targets - * will be returned. The maximum value is 1000; values above 1000 will be - * coerced to 1000. Please refer to https://google.aip.dev/158 for more - * details. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListProfilerTargets` - * call. Provide this to retrieve the subsequent page. Please refer to - * https://google.aip.dev/158 for more details. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.hypercomputecluster.v1alpha.ProfilerTarget|ProfilerTarget}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/machine_learning_runs.list_profiler_targets.js - * region_tag:hypercomputecluster_v1alpha_generated_MachineLearningRuns_ListProfilerTargets_async - */ + /** + * Equivalent to `listProfilerTargets`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. + * projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run} + * @param {number} [request.pageSize] + * Optional. The maximum number of profiler targets to return. The service may + * return fewer than this value. If unspecified, at most 10 profiler targets + * will be returned. The maximum value is 1000; values above 1000 will be + * coerced to 1000. Please refer to https://google.aip.dev/158 for more + * details. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListProfilerTargets` + * call. Provide this to retrieve the subsequent page. Please refer to + * https://google.aip.dev/158 for more details. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.hypercomputecluster.v1alpha.ProfilerTarget|ProfilerTarget}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/machine_learning_runs.list_profiler_targets.js + * region_tag:hypercomputecluster_v1alpha_generated_MachineLearningRuns_ListProfilerTargets_async + */ listProfilerTargetsAsync( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerTargetsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerTargetsRequest, + 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['listProfilerTargets']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listProfilerTargets iterate %j', request); return this.descriptors.page.listProfilerTargets.asyncIterate( this.innerApiCalls['listProfilerTargets'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists Profiler Sessions for a Machine Learning Run. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. - * projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run} - * @param {number} [request.pageSize] - * Optional. The maximum number of profiler sessions to return. The service - * may return fewer than this value. If unspecified, at most 10 profiler - * sessions will be returned. The maximum value is 1000; values above 1000 - * will be coerced to 1000. Please refer to https://google.aip.dev/158 for - * more details. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListProfilerSessions` - * call. Provide this to retrieve the subsequent page. Please refer to - * https://google.aip.dev/158 for more details. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link protos.google.cloud.hypercomputecluster.v1alpha.ProfilerSession|ProfilerSession}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listProfilerSessionsAsync()` - * method described below for async iteration which you can stop as 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 Profiler Sessions for a Machine Learning Run. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. + * projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run} + * @param {number} [request.pageSize] + * Optional. The maximum number of profiler sessions to return. The service + * may return fewer than this value. If unspecified, at most 10 profiler + * sessions will be returned. The maximum value is 1000; values above 1000 + * will be coerced to 1000. Please refer to https://google.aip.dev/158 for + * more details. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListProfilerSessions` + * call. Provide this to retrieve the subsequent page. Please refer to + * https://google.aip.dev/158 for more details. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.hypercomputecluster.v1alpha.ProfilerSession|ProfilerSession}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listProfilerSessionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listProfilerSessions( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerSessionsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.hypercomputecluster.v1alpha.IProfilerSession[], - protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerSessionsRequest|null, - protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerSessionsResponse - ]>; + request?: protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerSessionsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.hypercomputecluster.v1alpha.IProfilerSession[], + protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerSessionsRequest | null, + protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerSessionsResponse, + ] + >; listProfilerSessions( - request: protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerSessionsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerSessionsRequest, - protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerSessionsResponse|null|undefined, - protos.google.cloud.hypercomputecluster.v1alpha.IProfilerSession>): void; + request: protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerSessionsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerSessionsRequest, + | protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerSessionsResponse + | null + | undefined, + protos.google.cloud.hypercomputecluster.v1alpha.IProfilerSession + >, + ): void; listProfilerSessions( - request: protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerSessionsRequest, - callback: PaginationCallback< - protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerSessionsRequest, - protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerSessionsResponse|null|undefined, - protos.google.cloud.hypercomputecluster.v1alpha.IProfilerSession>): void; + request: protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerSessionsRequest, + callback: PaginationCallback< + protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerSessionsRequest, + | protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerSessionsResponse + | null + | undefined, + protos.google.cloud.hypercomputecluster.v1alpha.IProfilerSession + >, + ): void; listProfilerSessions( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerSessionsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerSessionsRequest, - protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerSessionsResponse|null|undefined, - protos.google.cloud.hypercomputecluster.v1alpha.IProfilerSession>, - callback?: PaginationCallback< + request?: protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerSessionsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerSessionsRequest, - protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerSessionsResponse|null|undefined, - protos.google.cloud.hypercomputecluster.v1alpha.IProfilerSession>): - Promise<[ - protos.google.cloud.hypercomputecluster.v1alpha.IProfilerSession[], - protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerSessionsRequest|null, - protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerSessionsResponse - ]>|void { + | protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerSessionsResponse + | null + | undefined, + protos.google.cloud.hypercomputecluster.v1alpha.IProfilerSession + >, + callback?: PaginationCallback< + protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerSessionsRequest, + | protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerSessionsResponse + | null + | undefined, + protos.google.cloud.hypercomputecluster.v1alpha.IProfilerSession + >, + ): Promise< + [ + protos.google.cloud.hypercomputecluster.v1alpha.IProfilerSession[], + protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerSessionsRequest | null, + protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerSessionsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-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.hypercomputecluster.v1alpha.IListProfilerSessionsRequest, - protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerSessionsResponse|null|undefined, - protos.google.cloud.hypercomputecluster.v1alpha.IProfilerSession>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerSessionsRequest, + | protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerSessionsResponse + | null + | undefined, + protos.google.cloud.hypercomputecluster.v1alpha.IProfilerSession + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listProfilerSessions values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -2685,211 +3763,244 @@ export class MachineLearningRunsClient { this._log.info('listProfilerSessions request %j', request); return this.innerApiCalls .listProfilerSessions(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.hypercomputecluster.v1alpha.IProfilerSession[], - protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerSessionsRequest|null, - protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerSessionsResponse - ]) => { - this._log.info('listProfilerSessions values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.hypercomputecluster.v1alpha.IProfilerSession[], + protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerSessionsRequest | null, + protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerSessionsResponse, + ]) => { + this._log.info('listProfilerSessions values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listProfilerSessions`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. - * projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run} - * @param {number} [request.pageSize] - * Optional. The maximum number of profiler sessions to return. The service - * may return fewer than this value. If unspecified, at most 10 profiler - * sessions will be returned. The maximum value is 1000; values above 1000 - * will be coerced to 1000. Please refer to https://google.aip.dev/158 for - * more details. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListProfilerSessions` - * call. Provide this to retrieve the subsequent page. Please refer to - * https://google.aip.dev/158 for more details. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.hypercomputecluster.v1alpha.ProfilerSession|ProfilerSession} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listProfilerSessionsAsync()` - * method described below for async iteration which you can stop as 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 `listProfilerSessions`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. + * projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run} + * @param {number} [request.pageSize] + * Optional. The maximum number of profiler sessions to return. The service + * may return fewer than this value. If unspecified, at most 10 profiler + * sessions will be returned. The maximum value is 1000; values above 1000 + * will be coerced to 1000. Please refer to https://google.aip.dev/158 for + * more details. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListProfilerSessions` + * call. Provide this to retrieve the subsequent page. Please refer to + * https://google.aip.dev/158 for more details. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.hypercomputecluster.v1alpha.ProfilerSession|ProfilerSession} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listProfilerSessionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listProfilerSessionsStream( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerSessionsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerSessionsRequest, + 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['listProfilerSessions']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listProfilerSessions stream %j', request); return this.descriptors.page.listProfilerSessions.createStream( this.innerApiCalls.listProfilerSessions as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listProfilerSessions`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. - * projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run} - * @param {number} [request.pageSize] - * Optional. The maximum number of profiler sessions to return. The service - * may return fewer than this value. If unspecified, at most 10 profiler - * sessions will be returned. The maximum value is 1000; values above 1000 - * will be coerced to 1000. Please refer to https://google.aip.dev/158 for - * more details. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListProfilerSessions` - * call. Provide this to retrieve the subsequent page. Please refer to - * https://google.aip.dev/158 for more details. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.hypercomputecluster.v1alpha.ProfilerSession|ProfilerSession}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/machine_learning_runs.list_profiler_sessions.js - * region_tag:hypercomputecluster_v1alpha_generated_MachineLearningRuns_ListProfilerSessions_async - */ + /** + * Equivalent to `listProfilerSessions`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. + * projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run} + * @param {number} [request.pageSize] + * Optional. The maximum number of profiler sessions to return. The service + * may return fewer than this value. If unspecified, at most 10 profiler + * sessions will be returned. The maximum value is 1000; values above 1000 + * will be coerced to 1000. Please refer to https://google.aip.dev/158 for + * more details. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListProfilerSessions` + * call. Provide this to retrieve the subsequent page. Please refer to + * https://google.aip.dev/158 for more details. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.hypercomputecluster.v1alpha.ProfilerSession|ProfilerSession}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/machine_learning_runs.list_profiler_sessions.js + * region_tag:hypercomputecluster_v1alpha_generated_MachineLearningRuns_ListProfilerSessions_async + */ listProfilerSessionsAsync( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerSessionsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.hypercomputecluster.v1alpha.IListProfilerSessionsRequest, + 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['listProfilerSessions']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listProfilerSessions iterate %j', request); return this.descriptors.page.listProfilerSessions.asyncIterate( this.innerApiCalls['listProfilerSessions'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Deprecated: Use `ListProfilerSessions` instead. - * Lists Profile Sessions for a Machine Learning Run. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent format: - * projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run} - * @param {number} [request.pageSize] - * Optional. The maximum number of Profile Sessions to return. The service may - * return fewer than this value. - * If unspecified, at most 50 Profile Sessions will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListProfileSessions` - * call. Provide this to retrieve the subsequent 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.hypercomputecluster.v1alpha.ProfileSession|ProfileSession}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listProfileSessionsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @deprecated ListProfileSessions is deprecated and may be removed in a future version. - */ + /** + * Deprecated: Use `ListProfilerSessions` instead. + * Lists Profile Sessions for a Machine Learning Run. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent format: + * projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run} + * @param {number} [request.pageSize] + * Optional. The maximum number of Profile Sessions to return. The service may + * return fewer than this value. + * If unspecified, at most 50 Profile Sessions will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListProfileSessions` + * call. Provide this to retrieve the subsequent 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.hypercomputecluster.v1alpha.ProfileSession|ProfileSession}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listProfileSessionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @deprecated ListProfileSessions is deprecated and may be removed in a future version. + */ listProfileSessions( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IListProfileSessionsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.hypercomputecluster.v1alpha.IProfileSession[], - protos.google.cloud.hypercomputecluster.v1alpha.IListProfileSessionsRequest|null, - protos.google.cloud.hypercomputecluster.v1alpha.IListProfileSessionsResponse - ]>; + request?: protos.google.cloud.hypercomputecluster.v1alpha.IListProfileSessionsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.hypercomputecluster.v1alpha.IProfileSession[], + protos.google.cloud.hypercomputecluster.v1alpha.IListProfileSessionsRequest | null, + protos.google.cloud.hypercomputecluster.v1alpha.IListProfileSessionsResponse, + ] + >; listProfileSessions( - request: protos.google.cloud.hypercomputecluster.v1alpha.IListProfileSessionsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.hypercomputecluster.v1alpha.IListProfileSessionsRequest, - protos.google.cloud.hypercomputecluster.v1alpha.IListProfileSessionsResponse|null|undefined, - protos.google.cloud.hypercomputecluster.v1alpha.IProfileSession>): void; + request: protos.google.cloud.hypercomputecluster.v1alpha.IListProfileSessionsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.hypercomputecluster.v1alpha.IListProfileSessionsRequest, + | protos.google.cloud.hypercomputecluster.v1alpha.IListProfileSessionsResponse + | null + | undefined, + protos.google.cloud.hypercomputecluster.v1alpha.IProfileSession + >, + ): void; listProfileSessions( - request: protos.google.cloud.hypercomputecluster.v1alpha.IListProfileSessionsRequest, - callback: PaginationCallback< - protos.google.cloud.hypercomputecluster.v1alpha.IListProfileSessionsRequest, - protos.google.cloud.hypercomputecluster.v1alpha.IListProfileSessionsResponse|null|undefined, - protos.google.cloud.hypercomputecluster.v1alpha.IProfileSession>): void; + request: protos.google.cloud.hypercomputecluster.v1alpha.IListProfileSessionsRequest, + callback: PaginationCallback< + protos.google.cloud.hypercomputecluster.v1alpha.IListProfileSessionsRequest, + | protos.google.cloud.hypercomputecluster.v1alpha.IListProfileSessionsResponse + | null + | undefined, + protos.google.cloud.hypercomputecluster.v1alpha.IProfileSession + >, + ): void; listProfileSessions( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IListProfileSessionsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.hypercomputecluster.v1alpha.IListProfileSessionsRequest, - protos.google.cloud.hypercomputecluster.v1alpha.IListProfileSessionsResponse|null|undefined, - protos.google.cloud.hypercomputecluster.v1alpha.IProfileSession>, - callback?: PaginationCallback< + request?: protos.google.cloud.hypercomputecluster.v1alpha.IListProfileSessionsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.hypercomputecluster.v1alpha.IListProfileSessionsRequest, - protos.google.cloud.hypercomputecluster.v1alpha.IListProfileSessionsResponse|null|undefined, - protos.google.cloud.hypercomputecluster.v1alpha.IProfileSession>): - Promise<[ - protos.google.cloud.hypercomputecluster.v1alpha.IProfileSession[], - protos.google.cloud.hypercomputecluster.v1alpha.IListProfileSessionsRequest|null, - protos.google.cloud.hypercomputecluster.v1alpha.IListProfileSessionsResponse - ]>|void { + | protos.google.cloud.hypercomputecluster.v1alpha.IListProfileSessionsResponse + | null + | undefined, + protos.google.cloud.hypercomputecluster.v1alpha.IProfileSession + >, + callback?: PaginationCallback< + protos.google.cloud.hypercomputecluster.v1alpha.IListProfileSessionsRequest, + | protos.google.cloud.hypercomputecluster.v1alpha.IListProfileSessionsResponse + | null + | undefined, + protos.google.cloud.hypercomputecluster.v1alpha.IProfileSession + >, + ): Promise< + [ + protos.google.cloud.hypercomputecluster.v1alpha.IProfileSession[], + protos.google.cloud.hypercomputecluster.v1alpha.IListProfileSessionsRequest | null, + protos.google.cloud.hypercomputecluster.v1alpha.IListProfileSessionsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.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.warn('DEP$MachineLearningRuns-$ListProfileSessions','ListProfileSessions is deprecated and may be removed in a future version.', 'DeprecationWarning'); - const wrappedCallback: PaginationCallback< - protos.google.cloud.hypercomputecluster.v1alpha.IListProfileSessionsRequest, - protos.google.cloud.hypercomputecluster.v1alpha.IListProfileSessionsResponse|null|undefined, - protos.google.cloud.hypercomputecluster.v1alpha.IProfileSession>|undefined = callback + this.warn( + 'DEP$MachineLearningRuns-$ListProfileSessions', + 'ListProfileSessions is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.hypercomputecluster.v1alpha.IListProfileSessionsRequest, + | protos.google.cloud.hypercomputecluster.v1alpha.IListProfileSessionsResponse + | null + | undefined, + protos.google.cloud.hypercomputecluster.v1alpha.IProfileSession + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listProfileSessions values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -2898,215 +4009,252 @@ export class MachineLearningRunsClient { this._log.info('listProfileSessions request %j', request); return this.innerApiCalls .listProfileSessions(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.hypercomputecluster.v1alpha.IProfileSession[], - protos.google.cloud.hypercomputecluster.v1alpha.IListProfileSessionsRequest|null, - protos.google.cloud.hypercomputecluster.v1alpha.IListProfileSessionsResponse - ]) => { - this._log.info('listProfileSessions values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.hypercomputecluster.v1alpha.IProfileSession[], + protos.google.cloud.hypercomputecluster.v1alpha.IListProfileSessionsRequest | null, + protos.google.cloud.hypercomputecluster.v1alpha.IListProfileSessionsResponse, + ]) => { + this._log.info('listProfileSessions values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listProfileSessions`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent format: - * projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run} - * @param {number} [request.pageSize] - * Optional. The maximum number of Profile Sessions to return. The service may - * return fewer than this value. - * If unspecified, at most 50 Profile Sessions will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListProfileSessions` - * call. Provide this to retrieve the subsequent 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.hypercomputecluster.v1alpha.ProfileSession|ProfileSession} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listProfileSessionsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @deprecated ListProfileSessions is deprecated and may be removed in a future version. - */ + /** + * Equivalent to `listProfileSessions`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent format: + * projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run} + * @param {number} [request.pageSize] + * Optional. The maximum number of Profile Sessions to return. The service may + * return fewer than this value. + * If unspecified, at most 50 Profile Sessions will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListProfileSessions` + * call. Provide this to retrieve the subsequent 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.hypercomputecluster.v1alpha.ProfileSession|ProfileSession} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listProfileSessionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @deprecated ListProfileSessions is deprecated and may be removed in a future version. + */ listProfileSessionsStream( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IListProfileSessionsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.hypercomputecluster.v1alpha.IListProfileSessionsRequest, + 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['listProfileSessions']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); - this.warn('DEP$MachineLearningRuns-$ListProfileSessions','ListProfileSessions is deprecated and may be removed in a future version.', 'DeprecationWarning'); + this.initialize().catch((err) => { + throw err; + }); + this.warn( + 'DEP$MachineLearningRuns-$ListProfileSessions', + 'ListProfileSessions is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); this._log.info('listProfileSessions stream %j', request); return this.descriptors.page.listProfileSessions.createStream( this.innerApiCalls.listProfileSessions as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listProfileSessions`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used 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 format: - * projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run} - * @param {number} [request.pageSize] - * Optional. The maximum number of Profile Sessions to return. The service may - * return fewer than this value. - * If unspecified, at most 50 Profile Sessions will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListProfileSessions` - * call. Provide this to retrieve the subsequent 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.hypercomputecluster.v1alpha.ProfileSession|ProfileSession}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/machine_learning_runs.list_profile_sessions.js - * region_tag:hypercomputecluster_v1alpha_generated_MachineLearningRuns_ListProfileSessions_async - * @deprecated ListProfileSessions is deprecated and may be removed in a future version. - */ + /** + * Equivalent to `listProfileSessions`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used 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 format: + * projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run} + * @param {number} [request.pageSize] + * Optional. The maximum number of Profile Sessions to return. The service may + * return fewer than this value. + * If unspecified, at most 50 Profile Sessions will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListProfileSessions` + * call. Provide this to retrieve the subsequent 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.hypercomputecluster.v1alpha.ProfileSession|ProfileSession}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/machine_learning_runs.list_profile_sessions.js + * region_tag:hypercomputecluster_v1alpha_generated_MachineLearningRuns_ListProfileSessions_async + * @deprecated ListProfileSessions is deprecated and may be removed in a future version. + */ listProfileSessionsAsync( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IListProfileSessionsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.hypercomputecluster.v1alpha.IListProfileSessionsRequest, + 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['listProfileSessions']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); - this.warn('DEP$MachineLearningRuns-$ListProfileSessions','ListProfileSessions is deprecated and may be removed in a future version.', 'DeprecationWarning'); + this.initialize().catch((err) => { + throw err; + }); + this.warn( + 'DEP$MachineLearningRuns-$ListProfileSessions', + 'ListProfileSessions is deprecated and may be removed in a future version.', + 'DeprecationWarning', + ); this._log.info('listProfileSessions iterate %j', request); return this.descriptors.page.listProfileSessions.asyncIterate( this.innerApiCalls['listProfileSessions'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists Monitored Events for a run. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent resource to list events from. - * Format: - * projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run} - * @param {number} [request.pageSize] - * Optional. The maximum number of events to return. The service may return - * fewer than this value. If unspecified, at most 50 events will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListMonitoredEvents` - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListMonitoredEvents` - * must match the call that provided the page token. - * @param {string} [request.filter] - * Optional. A filter expression for filtering results. - * @param {string} [request.orderBy] - * Optional. Order by field for sorting 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.hypercomputecluster.v1alpha.MonitoredEvent|MonitoredEvent}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listMonitoredEventsAsync()` - * method described below for async iteration which you can stop as 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 Monitored Events for a run. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent resource to list events from. + * Format: + * projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run} + * @param {number} [request.pageSize] + * Optional. The maximum number of events to return. The service may return + * fewer than this value. If unspecified, at most 50 events will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListMonitoredEvents` + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListMonitoredEvents` + * must match the call that provided the page token. + * @param {string} [request.filter] + * Optional. A filter expression for filtering results. + * @param {string} [request.orderBy] + * Optional. Order by field for sorting 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.hypercomputecluster.v1alpha.MonitoredEvent|MonitoredEvent}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listMonitoredEventsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listMonitoredEvents( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IListMonitoredEventsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent[], - protos.google.cloud.hypercomputecluster.v1alpha.IListMonitoredEventsRequest|null, - protos.google.cloud.hypercomputecluster.v1alpha.IListMonitoredEventsResponse - ]>; + request?: protos.google.cloud.hypercomputecluster.v1alpha.IListMonitoredEventsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent[], + protos.google.cloud.hypercomputecluster.v1alpha.IListMonitoredEventsRequest | null, + protos.google.cloud.hypercomputecluster.v1alpha.IListMonitoredEventsResponse, + ] + >; listMonitoredEvents( - request: protos.google.cloud.hypercomputecluster.v1alpha.IListMonitoredEventsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.hypercomputecluster.v1alpha.IListMonitoredEventsRequest, - protos.google.cloud.hypercomputecluster.v1alpha.IListMonitoredEventsResponse|null|undefined, - protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent>): void; + request: protos.google.cloud.hypercomputecluster.v1alpha.IListMonitoredEventsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.hypercomputecluster.v1alpha.IListMonitoredEventsRequest, + | protos.google.cloud.hypercomputecluster.v1alpha.IListMonitoredEventsResponse + | null + | undefined, + protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent + >, + ): void; listMonitoredEvents( - request: protos.google.cloud.hypercomputecluster.v1alpha.IListMonitoredEventsRequest, - callback: PaginationCallback< - protos.google.cloud.hypercomputecluster.v1alpha.IListMonitoredEventsRequest, - protos.google.cloud.hypercomputecluster.v1alpha.IListMonitoredEventsResponse|null|undefined, - protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent>): void; + request: protos.google.cloud.hypercomputecluster.v1alpha.IListMonitoredEventsRequest, + callback: PaginationCallback< + protos.google.cloud.hypercomputecluster.v1alpha.IListMonitoredEventsRequest, + | protos.google.cloud.hypercomputecluster.v1alpha.IListMonitoredEventsResponse + | null + | undefined, + protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent + >, + ): void; listMonitoredEvents( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IListMonitoredEventsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.hypercomputecluster.v1alpha.IListMonitoredEventsRequest, - protos.google.cloud.hypercomputecluster.v1alpha.IListMonitoredEventsResponse|null|undefined, - protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent>, - callback?: PaginationCallback< + request?: protos.google.cloud.hypercomputecluster.v1alpha.IListMonitoredEventsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.hypercomputecluster.v1alpha.IListMonitoredEventsRequest, - protos.google.cloud.hypercomputecluster.v1alpha.IListMonitoredEventsResponse|null|undefined, - protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent>): - Promise<[ - protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent[], - protos.google.cloud.hypercomputecluster.v1alpha.IListMonitoredEventsRequest|null, - protos.google.cloud.hypercomputecluster.v1alpha.IListMonitoredEventsResponse - ]>|void { + | protos.google.cloud.hypercomputecluster.v1alpha.IListMonitoredEventsResponse + | null + | undefined, + protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent + >, + callback?: PaginationCallback< + protos.google.cloud.hypercomputecluster.v1alpha.IListMonitoredEventsRequest, + | protos.google.cloud.hypercomputecluster.v1alpha.IListMonitoredEventsResponse + | null + | undefined, + protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent + >, + ): Promise< + [ + protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent[], + protos.google.cloud.hypercomputecluster.v1alpha.IListMonitoredEventsRequest | null, + protos.google.cloud.hypercomputecluster.v1alpha.IListMonitoredEventsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-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.hypercomputecluster.v1alpha.IListMonitoredEventsRequest, - protos.google.cloud.hypercomputecluster.v1alpha.IListMonitoredEventsResponse|null|undefined, - protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.hypercomputecluster.v1alpha.IListMonitoredEventsRequest, + | protos.google.cloud.hypercomputecluster.v1alpha.IListMonitoredEventsResponse + | null + | undefined, + protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listMonitoredEvents values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -3115,133 +4263,138 @@ export class MachineLearningRunsClient { this._log.info('listMonitoredEvents request %j', request); return this.innerApiCalls .listMonitoredEvents(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent[], - protos.google.cloud.hypercomputecluster.v1alpha.IListMonitoredEventsRequest|null, - protos.google.cloud.hypercomputecluster.v1alpha.IListMonitoredEventsResponse - ]) => { - this._log.info('listMonitoredEvents values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent[], + protos.google.cloud.hypercomputecluster.v1alpha.IListMonitoredEventsRequest | null, + protos.google.cloud.hypercomputecluster.v1alpha.IListMonitoredEventsResponse, + ]) => { + this._log.info('listMonitoredEvents values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listMonitoredEvents`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent resource to list events from. - * Format: - * projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run} - * @param {number} [request.pageSize] - * Optional. The maximum number of events to return. The service may return - * fewer than this value. If unspecified, at most 50 events will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListMonitoredEvents` - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListMonitoredEvents` - * must match the call that provided the page token. - * @param {string} [request.filter] - * Optional. A filter expression for filtering results. - * @param {string} [request.orderBy] - * Optional. Order by field for sorting 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.hypercomputecluster.v1alpha.MonitoredEvent|MonitoredEvent} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listMonitoredEventsAsync()` - * method described below for async iteration which you can stop as 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 `listMonitoredEvents`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent resource to list events from. + * Format: + * projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run} + * @param {number} [request.pageSize] + * Optional. The maximum number of events to return. The service may return + * fewer than this value. If unspecified, at most 50 events will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListMonitoredEvents` + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListMonitoredEvents` + * must match the call that provided the page token. + * @param {string} [request.filter] + * Optional. A filter expression for filtering results. + * @param {string} [request.orderBy] + * Optional. Order by field for sorting 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.hypercomputecluster.v1alpha.MonitoredEvent|MonitoredEvent} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listMonitoredEventsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listMonitoredEventsStream( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IListMonitoredEventsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.hypercomputecluster.v1alpha.IListMonitoredEventsRequest, + 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['listMonitoredEvents']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listMonitoredEvents stream %j', request); return this.descriptors.page.listMonitoredEvents.createStream( this.innerApiCalls.listMonitoredEvents as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listMonitoredEvents`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used 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 resource to list events from. - * Format: - * projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run} - * @param {number} [request.pageSize] - * Optional. The maximum number of events to return. The service may return - * fewer than this value. If unspecified, at most 50 events will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListMonitoredEvents` - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListMonitoredEvents` - * must match the call that provided the page token. - * @param {string} [request.filter] - * Optional. A filter expression for filtering results. - * @param {string} [request.orderBy] - * Optional. Order by field for sorting 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.hypercomputecluster.v1alpha.MonitoredEvent|MonitoredEvent}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1alpha/machine_learning_runs.list_monitored_events.js - * region_tag:hypercomputecluster_v1alpha_generated_MachineLearningRuns_ListMonitoredEvents_async - */ + /** + * Equivalent to `listMonitoredEvents`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used 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 resource to list events from. + * Format: + * projects/{project}/locations/{location}/machineLearningRuns/{machine_learning_run} + * @param {number} [request.pageSize] + * Optional. The maximum number of events to return. The service may return + * fewer than this value. If unspecified, at most 50 events will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListMonitoredEvents` + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListMonitoredEvents` + * must match the call that provided the page token. + * @param {string} [request.filter] + * Optional. A filter expression for filtering results. + * @param {string} [request.orderBy] + * Optional. Order by field for sorting 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.hypercomputecluster.v1alpha.MonitoredEvent|MonitoredEvent}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1alpha/machine_learning_runs.list_monitored_events.js + * region_tag:hypercomputecluster_v1alpha_generated_MachineLearningRuns_ListMonitoredEvents_async + */ listMonitoredEventsAsync( - request?: protos.google.cloud.hypercomputecluster.v1alpha.IListMonitoredEventsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.hypercomputecluster.v1alpha.IListMonitoredEventsRequest, + 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['listMonitoredEvents']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listMonitoredEvents iterate %j', request); return this.descriptors.page.listMonitoredEvents.asyncIterate( this.innerApiCalls['listMonitoredEvents'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** + + /** * Gets information about a location. * * @param {Object} request @@ -3276,12 +4429,11 @@ export class MachineLearningRunsClient { | 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. @@ -3314,12 +4466,12 @@ export class MachineLearningRunsClient { */ 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. @@ -3362,22 +4514,22 @@ export class MachineLearningRunsClient { 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); } /** @@ -3412,15 +4564,15 @@ export class MachineLearningRunsClient { */ 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); } /** @@ -3454,7 +4606,7 @@ export class MachineLearningRunsClient { * await client.cancelOperation({name: ''}); * ``` */ - cancelOperation( + cancelOperation( request: protos.google.longrunning.CancelOperationRequest, optionsOrCallback?: | gax.CallOptions @@ -3467,25 +4619,24 @@ export class MachineLearningRunsClient { 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 @@ -3524,22 +4675,22 @@ export class MachineLearningRunsClient { 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); } @@ -3555,7 +4706,7 @@ export class MachineLearningRunsClient { * @param {string} cluster * @returns {string} Resource name string. */ - clusterPath(project:string,location:string,cluster:string) { + clusterPath(project: string, location: string, cluster: string) { return this.pathTemplates.clusterPathTemplate.render({ project: project, location: location, @@ -3603,7 +4754,7 @@ export class MachineLearningRunsClient { * @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, @@ -3640,7 +4791,11 @@ export class MachineLearningRunsClient { * @param {string} machine_learning_run * @returns {string} Resource name string. */ - machineLearningRunPath(project:string,location:string,machineLearningRun:string) { + machineLearningRunPath( + project: string, + location: string, + machineLearningRun: string, + ) { return this.pathTemplates.machineLearningRunPathTemplate.render({ project: project, location: location, @@ -3656,7 +4811,9 @@ export class MachineLearningRunsClient { * @returns {string} A string representing the project. */ matchProjectFromMachineLearningRunName(machineLearningRunName: string) { - return this.pathTemplates.machineLearningRunPathTemplate.match(machineLearningRunName).project; + return this.pathTemplates.machineLearningRunPathTemplate.match( + machineLearningRunName, + ).project; } /** @@ -3667,7 +4824,9 @@ export class MachineLearningRunsClient { * @returns {string} A string representing the location. */ matchLocationFromMachineLearningRunName(machineLearningRunName: string) { - return this.pathTemplates.machineLearningRunPathTemplate.match(machineLearningRunName).location; + return this.pathTemplates.machineLearningRunPathTemplate.match( + machineLearningRunName, + ).location; } /** @@ -3677,8 +4836,12 @@ export class MachineLearningRunsClient { * A fully-qualified path representing MachineLearningRun resource. * @returns {string} A string representing the machine_learning_run. */ - matchMachineLearningRunFromMachineLearningRunName(machineLearningRunName: string) { - return this.pathTemplates.machineLearningRunPathTemplate.match(machineLearningRunName).machine_learning_run; + matchMachineLearningRunFromMachineLearningRunName( + machineLearningRunName: string, + ) { + return this.pathTemplates.machineLearningRunPathTemplate.match( + machineLearningRunName, + ).machine_learning_run; } /** @@ -3690,7 +4853,12 @@ export class MachineLearningRunsClient { * @param {string} monitored_event * @returns {string} Resource name string. */ - monitoredEventPath(project:string,location:string,machineLearningRun:string,monitoredEvent:string) { + monitoredEventPath( + project: string, + location: string, + machineLearningRun: string, + monitoredEvent: string, + ) { return this.pathTemplates.monitoredEventPathTemplate.render({ project: project, location: location, @@ -3707,7 +4875,9 @@ export class MachineLearningRunsClient { * @returns {string} A string representing the project. */ matchProjectFromMonitoredEventName(monitoredEventName: string) { - return this.pathTemplates.monitoredEventPathTemplate.match(monitoredEventName).project; + return this.pathTemplates.monitoredEventPathTemplate.match( + monitoredEventName, + ).project; } /** @@ -3718,7 +4888,9 @@ export class MachineLearningRunsClient { * @returns {string} A string representing the location. */ matchLocationFromMonitoredEventName(monitoredEventName: string) { - return this.pathTemplates.monitoredEventPathTemplate.match(monitoredEventName).location; + return this.pathTemplates.monitoredEventPathTemplate.match( + monitoredEventName, + ).location; } /** @@ -3729,7 +4901,9 @@ export class MachineLearningRunsClient { * @returns {string} A string representing the machine_learning_run. */ matchMachineLearningRunFromMonitoredEventName(monitoredEventName: string) { - return this.pathTemplates.monitoredEventPathTemplate.match(monitoredEventName).machine_learning_run; + return this.pathTemplates.monitoredEventPathTemplate.match( + monitoredEventName, + ).machine_learning_run; } /** @@ -3740,7 +4914,9 @@ export class MachineLearningRunsClient { * @returns {string} A string representing the monitored_event. */ matchMonitoredEventFromMonitoredEventName(monitoredEventName: string) { - return this.pathTemplates.monitoredEventPathTemplate.match(monitoredEventName).monitored_event; + return this.pathTemplates.monitoredEventPathTemplate.match( + monitoredEventName, + ).monitored_event; } /** @@ -3752,7 +4928,7 @@ export class MachineLearningRunsClient { * @param {string} node * @returns {string} Resource name string. */ - nodePath(project:string,location:string,cluster:string,node:string) { + nodePath(project: string, location: string, cluster: string, node: string) { return this.pathTemplates.nodePathTemplate.render({ project: project, location: location, @@ -3814,7 +4990,12 @@ export class MachineLearningRunsClient { * @param {string} profile_session * @returns {string} Resource name string. */ - profileSessionPath(project:string,location:string,machineLearningRun:string,profileSession:string) { + profileSessionPath( + project: string, + location: string, + machineLearningRun: string, + profileSession: string, + ) { return this.pathTemplates.profileSessionPathTemplate.render({ project: project, location: location, @@ -3831,7 +5012,9 @@ export class MachineLearningRunsClient { * @returns {string} A string representing the project. */ matchProjectFromProfileSessionName(profileSessionName: string) { - return this.pathTemplates.profileSessionPathTemplate.match(profileSessionName).project; + return this.pathTemplates.profileSessionPathTemplate.match( + profileSessionName, + ).project; } /** @@ -3842,7 +5025,9 @@ export class MachineLearningRunsClient { * @returns {string} A string representing the location. */ matchLocationFromProfileSessionName(profileSessionName: string) { - return this.pathTemplates.profileSessionPathTemplate.match(profileSessionName).location; + return this.pathTemplates.profileSessionPathTemplate.match( + profileSessionName, + ).location; } /** @@ -3853,7 +5038,9 @@ export class MachineLearningRunsClient { * @returns {string} A string representing the machine_learning_run. */ matchMachineLearningRunFromProfileSessionName(profileSessionName: string) { - return this.pathTemplates.profileSessionPathTemplate.match(profileSessionName).machine_learning_run; + return this.pathTemplates.profileSessionPathTemplate.match( + profileSessionName, + ).machine_learning_run; } /** @@ -3864,7 +5051,9 @@ export class MachineLearningRunsClient { * @returns {string} A string representing the profile_session. */ matchProfileSessionFromProfileSessionName(profileSessionName: string) { - return this.pathTemplates.profileSessionPathTemplate.match(profileSessionName).profile_session; + return this.pathTemplates.profileSessionPathTemplate.match( + profileSessionName, + ).profile_session; } /** @@ -3876,7 +5065,12 @@ export class MachineLearningRunsClient { * @param {string} profiler_session * @returns {string} Resource name string. */ - profilerSessionPath(project:string,location:string,machineLearningRun:string,profilerSession:string) { + profilerSessionPath( + project: string, + location: string, + machineLearningRun: string, + profilerSession: string, + ) { return this.pathTemplates.profilerSessionPathTemplate.render({ project: project, location: location, @@ -3893,7 +5087,9 @@ export class MachineLearningRunsClient { * @returns {string} A string representing the project. */ matchProjectFromProfilerSessionName(profilerSessionName: string) { - return this.pathTemplates.profilerSessionPathTemplate.match(profilerSessionName).project; + return this.pathTemplates.profilerSessionPathTemplate.match( + profilerSessionName, + ).project; } /** @@ -3904,7 +5100,9 @@ export class MachineLearningRunsClient { * @returns {string} A string representing the location. */ matchLocationFromProfilerSessionName(profilerSessionName: string) { - return this.pathTemplates.profilerSessionPathTemplate.match(profilerSessionName).location; + return this.pathTemplates.profilerSessionPathTemplate.match( + profilerSessionName, + ).location; } /** @@ -3915,7 +5113,9 @@ export class MachineLearningRunsClient { * @returns {string} A string representing the machine_learning_run. */ matchMachineLearningRunFromProfilerSessionName(profilerSessionName: string) { - return this.pathTemplates.profilerSessionPathTemplate.match(profilerSessionName).machine_learning_run; + return this.pathTemplates.profilerSessionPathTemplate.match( + profilerSessionName, + ).machine_learning_run; } /** @@ -3926,7 +5126,9 @@ export class MachineLearningRunsClient { * @returns {string} A string representing the profiler_session. */ matchProfilerSessionFromProfilerSessionName(profilerSessionName: string) { - return this.pathTemplates.profilerSessionPathTemplate.match(profilerSessionName).profiler_session; + return this.pathTemplates.profilerSessionPathTemplate.match( + profilerSessionName, + ).profiler_session; } /** @@ -3938,7 +5140,12 @@ export class MachineLearningRunsClient { * @param {string} profiler_target * @returns {string} Resource name string. */ - profilerTargetPath(project:string,location:string,machineLearningRun:string,profilerTarget:string) { + profilerTargetPath( + project: string, + location: string, + machineLearningRun: string, + profilerTarget: string, + ) { return this.pathTemplates.profilerTargetPathTemplate.render({ project: project, location: location, @@ -3955,7 +5162,9 @@ export class MachineLearningRunsClient { * @returns {string} A string representing the project. */ matchProjectFromProfilerTargetName(profilerTargetName: string) { - return this.pathTemplates.profilerTargetPathTemplate.match(profilerTargetName).project; + return this.pathTemplates.profilerTargetPathTemplate.match( + profilerTargetName, + ).project; } /** @@ -3966,7 +5175,9 @@ export class MachineLearningRunsClient { * @returns {string} A string representing the location. */ matchLocationFromProfilerTargetName(profilerTargetName: string) { - return this.pathTemplates.profilerTargetPathTemplate.match(profilerTargetName).location; + return this.pathTemplates.profilerTargetPathTemplate.match( + profilerTargetName, + ).location; } /** @@ -3977,7 +5188,9 @@ export class MachineLearningRunsClient { * @returns {string} A string representing the machine_learning_run. */ matchMachineLearningRunFromProfilerTargetName(profilerTargetName: string) { - return this.pathTemplates.profilerTargetPathTemplate.match(profilerTargetName).machine_learning_run; + return this.pathTemplates.profilerTargetPathTemplate.match( + profilerTargetName, + ).machine_learning_run; } /** @@ -3988,7 +5201,9 @@ export class MachineLearningRunsClient { * @returns {string} A string representing the profiler_target. */ matchProfilerTargetFromProfilerTargetName(profilerTargetName: string) { - return this.pathTemplates.profilerTargetPathTemplate.match(profilerTargetName).profiler_target; + return this.pathTemplates.profilerTargetPathTemplate.match( + profilerTargetName, + ).profiler_target; } /** @@ -3997,7 +5212,7 @@ export class MachineLearningRunsClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -4022,14 +5237,16 @@ export class MachineLearningRunsClient { */ close(): Promise { if (this.machineLearningRunsStub && !this._terminated) { - return this.machineLearningRunsStub.then(stub => { + return this.machineLearningRunsStub.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-hypercomputecluster/src/v1beta/hypercompute_cluster_client.ts b/packages/google-cloud-hypercomputecluster/src/v1beta/hypercompute_cluster_client.ts index 952a636d185d..b5447e56b4fb 100644 --- a/packages/google-cloud-hypercomputecluster/src/v1beta/hypercompute_cluster_client.ts +++ b/packages/google-cloud-hypercomputecluster/src/v1beta/hypercompute_cluster_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 HypercomputeClusterClient { 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('hypercomputecluster'); @@ -57,11 +68,11 @@ export class HypercomputeClusterClient { 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; - hypercomputeClusterStub?: Promise<{[name: string]: Function}>; + hypercomputeClusterStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of HypercomputeClusterClient. @@ -102,21 +113,42 @@ export class HypercomputeClusterClient { * const client = new HypercomputeClusterClient({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 HypercomputeClusterClient; - 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 = 'hypercomputecluster.' + 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 HypercomputeClusterClient { 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 HypercomputeClusterClient { } 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,34 +213,34 @@ export class HypercomputeClusterClient { // Create useful helper objects for these. this.pathTemplates = { bucketPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/buckets/{bucket}' + 'projects/{project}/buckets/{bucket}', ), clusterPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/clusters/{cluster}' + 'projects/{project}/locations/{location}/clusters/{cluster}', ), computeInstancePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/zones/{zone}/instances/{instance}' + 'projects/{project}/zones/{zone}/instances/{instance}', ), diskTypePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/zones/{zone}/diskTypes/{disk_type}' + 'projects/{project}/zones/{zone}/diskTypes/{disk_type}', ), locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' + 'projects/{project}/locations/{location}', ), lustreInstancePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/instances/{instance}' + 'projects/{project}/locations/{location}/instances/{instance}', ), networkPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/global/networks/{network}' + 'projects/{project}/global/networks/{network}', ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' + 'projects/{project}', ), reservationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/zones/{zone}/reservations/{reservation}' + 'projects/{project}/zones/{zone}/reservations/{reservation}', ), subnetworkPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/regions/{region}/subnetworks/{subnetwork}' + 'projects/{project}/regions/{region}/subnetworks/{subnetwork}', ), }; @@ -220,8 +248,11 @@ export class HypercomputeClusterClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listClusters: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'clusters') + listClusters: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'clusters', + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -230,45 +261,85 @@ export class HypercomputeClusterClient { // rather than holding a request open. const lroOptions: GrpcClientOptions = { auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1beta/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1beta/{name=projects/*}/locations',},{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1beta/{name=projects/*/locations/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1beta/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1beta/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1beta/{name=projects/*/locations/*}/operations',}]; + lroOptions.httpRules = [ + { + selector: 'google.cloud.location.Locations.GetLocation', + get: '/v1beta/{name=projects/*/locations/*}', + }, + { + selector: 'google.cloud.location.Locations.ListLocations', + get: '/v1beta/{name=projects/*}/locations', + }, + { + selector: 'google.longrunning.Operations.CancelOperation', + post: '/v1beta/{name=projects/*/locations/*/operations/*}:cancel', + body: '*', + }, + { + selector: 'google.longrunning.Operations.DeleteOperation', + delete: '/v1beta/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v1beta/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v1beta/{name=projects/*/locations/*}/operations', + }, + ]; } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); const createClusterResponse = protoFilesRoot.lookup( - '.google.cloud.hypercomputecluster.v1beta.Cluster') as gax.protobuf.Type; + '.google.cloud.hypercomputecluster.v1beta.Cluster', + ) as gax.protobuf.Type; const createClusterMetadata = protoFilesRoot.lookup( - '.google.cloud.hypercomputecluster.v1beta.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.hypercomputecluster.v1beta.OperationMetadata', + ) as gax.protobuf.Type; const updateClusterResponse = protoFilesRoot.lookup( - '.google.cloud.hypercomputecluster.v1beta.Cluster') as gax.protobuf.Type; + '.google.cloud.hypercomputecluster.v1beta.Cluster', + ) as gax.protobuf.Type; const updateClusterMetadata = protoFilesRoot.lookup( - '.google.cloud.hypercomputecluster.v1beta.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.hypercomputecluster.v1beta.OperationMetadata', + ) as gax.protobuf.Type; const deleteClusterResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteClusterMetadata = protoFilesRoot.lookup( - '.google.cloud.hypercomputecluster.v1beta.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.hypercomputecluster.v1beta.OperationMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { createCluster: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createClusterResponse.decode.bind(createClusterResponse), - createClusterMetadata.decode.bind(createClusterMetadata)), + createClusterMetadata.decode.bind(createClusterMetadata), + ), updateCluster: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateClusterResponse.decode.bind(updateClusterResponse), - updateClusterMetadata.decode.bind(updateClusterMetadata)), + updateClusterMetadata.decode.bind(updateClusterMetadata), + ), deleteCluster: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteClusterResponse.decode.bind(deleteClusterResponse), - deleteClusterMetadata.decode.bind(deleteClusterMetadata)) + deleteClusterMetadata.decode.bind(deleteClusterMetadata), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.hypercomputecluster.v1beta.HypercomputeCluster', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.hypercomputecluster.v1beta.HypercomputeCluster', + 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 @@ -299,28 +370,40 @@ export class HypercomputeClusterClient { // Put together the "service stub" for // google.cloud.hypercomputecluster.v1beta.HypercomputeCluster. this.hypercomputeClusterStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.hypercomputecluster.v1beta.HypercomputeCluster') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.hypercomputecluster.v1beta.HypercomputeCluster, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.hypercomputecluster.v1beta.HypercomputeCluster', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.hypercomputecluster.v1beta + .HypercomputeCluster, + 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 hypercomputeClusterStubMethods = - ['listClusters', 'getCluster', 'createCluster', 'updateCluster', 'deleteCluster']; + const hypercomputeClusterStubMethods = [ + 'listClusters', + 'getCluster', + 'createCluster', + 'updateCluster', + 'deleteCluster', + ]; for (const methodName of hypercomputeClusterStubMethods) { const callPromise = this.hypercomputeClusterStub.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] || @@ -330,7 +413,7 @@ export class HypercomputeClusterClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -345,8 +428,14 @@ export class HypercomputeClusterClient { * @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 'hypercomputecluster.googleapis.com'; } @@ -357,8 +446,14 @@ export class HypercomputeClusterClient { * @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 'hypercomputecluster.googleapis.com'; } @@ -389,9 +484,7 @@ export class HypercomputeClusterClient { * @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; @@ -400,8 +493,9 @@ export class HypercomputeClusterClient { * 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; @@ -412,546 +506,806 @@ export class HypercomputeClusterClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Gets details of a single Cluster. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the cluster to retrieve, in the format - * `projects/{project}/locations/{location}/clusters/{cluster}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.hypercomputecluster.v1beta.Cluster|Cluster}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/hypercompute_cluster.get_cluster.js - * region_tag:hypercomputecluster_v1beta_generated_HypercomputeCluster_GetCluster_async - */ + /** + * Gets details of a single Cluster. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the cluster to retrieve, in the format + * `projects/{project}/locations/{location}/clusters/{cluster}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.hypercomputecluster.v1beta.Cluster|Cluster}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/hypercompute_cluster.get_cluster.js + * region_tag:hypercomputecluster_v1beta_generated_HypercomputeCluster_GetCluster_async + */ getCluster( - request?: protos.google.cloud.hypercomputecluster.v1beta.IGetClusterRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.hypercomputecluster.v1beta.ICluster, - protos.google.cloud.hypercomputecluster.v1beta.IGetClusterRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.hypercomputecluster.v1beta.IGetClusterRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.hypercomputecluster.v1beta.ICluster, + ( + | protos.google.cloud.hypercomputecluster.v1beta.IGetClusterRequest + | undefined + ), + {} | undefined, + ] + >; getCluster( - request: protos.google.cloud.hypercomputecluster.v1beta.IGetClusterRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.hypercomputecluster.v1beta.ICluster, - protos.google.cloud.hypercomputecluster.v1beta.IGetClusterRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.hypercomputecluster.v1beta.IGetClusterRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.hypercomputecluster.v1beta.ICluster, + | protos.google.cloud.hypercomputecluster.v1beta.IGetClusterRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getCluster( - request: protos.google.cloud.hypercomputecluster.v1beta.IGetClusterRequest, - callback: Callback< - protos.google.cloud.hypercomputecluster.v1beta.ICluster, - protos.google.cloud.hypercomputecluster.v1beta.IGetClusterRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.hypercomputecluster.v1beta.IGetClusterRequest, + callback: Callback< + protos.google.cloud.hypercomputecluster.v1beta.ICluster, + | protos.google.cloud.hypercomputecluster.v1beta.IGetClusterRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getCluster( - request?: protos.google.cloud.hypercomputecluster.v1beta.IGetClusterRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.hypercomputecluster.v1beta.ICluster, - protos.google.cloud.hypercomputecluster.v1beta.IGetClusterRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.hypercomputecluster.v1beta.IGetClusterRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.hypercomputecluster.v1beta.ICluster, - protos.google.cloud.hypercomputecluster.v1beta.IGetClusterRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.hypercomputecluster.v1beta.ICluster, - protos.google.cloud.hypercomputecluster.v1beta.IGetClusterRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.hypercomputecluster.v1beta.IGetClusterRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.hypercomputecluster.v1beta.ICluster, + | protos.google.cloud.hypercomputecluster.v1beta.IGetClusterRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.hypercomputecluster.v1beta.ICluster, + ( + | protos.google.cloud.hypercomputecluster.v1beta.IGetClusterRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getCluster request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.hypercomputecluster.v1beta.ICluster, - protos.google.cloud.hypercomputecluster.v1beta.IGetClusterRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.hypercomputecluster.v1beta.ICluster, + | protos.google.cloud.hypercomputecluster.v1beta.IGetClusterRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getCluster response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getCluster(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.hypercomputecluster.v1beta.ICluster, - protos.google.cloud.hypercomputecluster.v1beta.IGetClusterRequest|undefined, - {}|undefined - ]) => { - this._log.info('getCluster response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getCluster(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.hypercomputecluster.v1beta.ICluster, + ( + | protos.google.cloud.hypercomputecluster.v1beta.IGetClusterRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getCluster response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 Cluster in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent location in which the cluster should be created, in the - * format `projects/{project}/locations/{location}`. - * @param {string} request.clusterId - * Required. ID of the cluster to create. Must conform to - * [RFC-1034](https://datatracker.ietf.org/doc/html/rfc1034) (lower-case, - * alphanumeric, and at most 63 characters). - * @param {google.cloud.hypercomputecluster.v1beta.Cluster} request.cluster - * Required. Cluster to create. - * @param {string} [request.requestId] - * Optional. A unique identifier for this request. A random UUID is - * recommended. This request is idempotent if and only if `request_id` is - * provided. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/hypercompute_cluster.create_cluster.js - * region_tag:hypercomputecluster_v1beta_generated_HypercomputeCluster_CreateCluster_async - */ + /** + * Creates a new Cluster in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent location in which the cluster should be created, in the + * format `projects/{project}/locations/{location}`. + * @param {string} request.clusterId + * Required. ID of the cluster to create. Must conform to + * [RFC-1034](https://datatracker.ietf.org/doc/html/rfc1034) (lower-case, + * alphanumeric, and at most 63 characters). + * @param {google.cloud.hypercomputecluster.v1beta.Cluster} request.cluster + * Required. Cluster to create. + * @param {string} [request.requestId] + * Optional. A unique identifier for this request. A random UUID is + * recommended. This request is idempotent if and only if `request_id` is + * provided. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/hypercompute_cluster.create_cluster.js + * region_tag:hypercomputecluster_v1beta_generated_HypercomputeCluster_CreateCluster_async + */ createCluster( - request?: protos.google.cloud.hypercomputecluster.v1beta.ICreateClusterRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.hypercomputecluster.v1beta.ICreateClusterRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.hypercomputecluster.v1beta.ICluster, + protos.google.cloud.hypercomputecluster.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createCluster( - request: protos.google.cloud.hypercomputecluster.v1beta.ICreateClusterRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.hypercomputecluster.v1beta.ICreateClusterRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.hypercomputecluster.v1beta.ICluster, + protos.google.cloud.hypercomputecluster.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createCluster( - request: protos.google.cloud.hypercomputecluster.v1beta.ICreateClusterRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.hypercomputecluster.v1beta.ICreateClusterRequest, + callback: Callback< + LROperation< + protos.google.cloud.hypercomputecluster.v1beta.ICluster, + protos.google.cloud.hypercomputecluster.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createCluster( - request?: protos.google.cloud.hypercomputecluster.v1beta.ICreateClusterRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.hypercomputecluster.v1beta.ICreateClusterRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.hypercomputecluster.v1beta.ICluster, + protos.google.cloud.hypercomputecluster.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.hypercomputecluster.v1beta.ICluster, + protos.google.cloud.hypercomputecluster.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.hypercomputecluster.v1beta.ICluster, + protos.google.cloud.hypercomputecluster.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.hypercomputecluster.v1beta.ICluster, + protos.google.cloud.hypercomputecluster.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createCluster response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createCluster request %j', request); - return this.innerApiCalls.createCluster(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createCluster response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createCluster(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.hypercomputecluster.v1beta.ICluster, + protos.google.cloud.hypercomputecluster.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createCluster response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createCluster()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/hypercompute_cluster.create_cluster.js - * region_tag:hypercomputecluster_v1beta_generated_HypercomputeCluster_CreateCluster_async - */ - async checkCreateClusterProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createCluster()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/hypercompute_cluster.create_cluster.js + * region_tag:hypercomputecluster_v1beta_generated_HypercomputeCluster_CreateCluster_async + */ + async checkCreateClusterProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.hypercomputecluster.v1beta.Cluster, + protos.google.cloud.hypercomputecluster.v1beta.OperationMetadata + > + > { this._log.info('createCluster long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createCluster, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createCluster, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.hypercomputecluster.v1beta.Cluster, + protos.google.cloud.hypercomputecluster.v1beta.OperationMetadata + >; } -/** - * Updates the parameters of a single Cluster. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.hypercomputecluster.v1beta.Cluster} request.cluster - * Required. Cluster to update. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. Mask specifying which fields in the cluster to update. All paths - * must be specified explicitly - wildcards are not supported. At least one - * path must be provided. - * @param {string} [request.requestId] - * Optional. A unique identifier for this request. A random UUID is - * recommended. This request is idempotent if and only if `request_id` is - * provided. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/hypercompute_cluster.update_cluster.js - * region_tag:hypercomputecluster_v1beta_generated_HypercomputeCluster_UpdateCluster_async - */ + /** + * Updates the parameters of a single Cluster. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.hypercomputecluster.v1beta.Cluster} request.cluster + * Required. Cluster to update. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. Mask specifying which fields in the cluster to update. All paths + * must be specified explicitly - wildcards are not supported. At least one + * path must be provided. + * @param {string} [request.requestId] + * Optional. A unique identifier for this request. A random UUID is + * recommended. This request is idempotent if and only if `request_id` is + * provided. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/hypercompute_cluster.update_cluster.js + * region_tag:hypercomputecluster_v1beta_generated_HypercomputeCluster_UpdateCluster_async + */ updateCluster( - request?: protos.google.cloud.hypercomputecluster.v1beta.IUpdateClusterRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.hypercomputecluster.v1beta.IUpdateClusterRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.hypercomputecluster.v1beta.ICluster, + protos.google.cloud.hypercomputecluster.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateCluster( - request: protos.google.cloud.hypercomputecluster.v1beta.IUpdateClusterRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.hypercomputecluster.v1beta.IUpdateClusterRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.hypercomputecluster.v1beta.ICluster, + protos.google.cloud.hypercomputecluster.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateCluster( - request: protos.google.cloud.hypercomputecluster.v1beta.IUpdateClusterRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.hypercomputecluster.v1beta.IUpdateClusterRequest, + callback: Callback< + LROperation< + protos.google.cloud.hypercomputecluster.v1beta.ICluster, + protos.google.cloud.hypercomputecluster.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateCluster( - request?: protos.google.cloud.hypercomputecluster.v1beta.IUpdateClusterRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.hypercomputecluster.v1beta.IUpdateClusterRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.hypercomputecluster.v1beta.ICluster, + protos.google.cloud.hypercomputecluster.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.hypercomputecluster.v1beta.ICluster, + protos.google.cloud.hypercomputecluster.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.hypercomputecluster.v1beta.ICluster, + protos.google.cloud.hypercomputecluster.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'cluster.name': request.cluster!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'cluster.name': request.cluster!.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.hypercomputecluster.v1beta.ICluster, + protos.google.cloud.hypercomputecluster.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateCluster response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateCluster request %j', request); - return this.innerApiCalls.updateCluster(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateCluster response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateCluster(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.hypercomputecluster.v1beta.ICluster, + protos.google.cloud.hypercomputecluster.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateCluster response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateCluster()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/hypercompute_cluster.update_cluster.js - * region_tag:hypercomputecluster_v1beta_generated_HypercomputeCluster_UpdateCluster_async - */ - async checkUpdateClusterProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateCluster()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/hypercompute_cluster.update_cluster.js + * region_tag:hypercomputecluster_v1beta_generated_HypercomputeCluster_UpdateCluster_async + */ + async checkUpdateClusterProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.hypercomputecluster.v1beta.Cluster, + protos.google.cloud.hypercomputecluster.v1beta.OperationMetadata + > + > { this._log.info('updateCluster long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.updateCluster, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateCluster, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.hypercomputecluster.v1beta.Cluster, + protos.google.cloud.hypercomputecluster.v1beta.OperationMetadata + >; } -/** - * Deletes a single Cluster. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the cluster to delete, in the format - * `projects/{project}/locations/{location}/clusters/{cluster}`. - * @param {string} [request.requestId] - * Optional. A unique identifier for this request. A random UUID is - * recommended. This request is idempotent if and only if `request_id` is - * provided. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/hypercompute_cluster.delete_cluster.js - * region_tag:hypercomputecluster_v1beta_generated_HypercomputeCluster_DeleteCluster_async - */ + /** + * Deletes a single Cluster. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the cluster to delete, in the format + * `projects/{project}/locations/{location}/clusters/{cluster}`. + * @param {string} [request.requestId] + * Optional. A unique identifier for this request. A random UUID is + * recommended. This request is idempotent if and only if `request_id` is + * provided. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/hypercompute_cluster.delete_cluster.js + * region_tag:hypercomputecluster_v1beta_generated_HypercomputeCluster_DeleteCluster_async + */ deleteCluster( - request?: protos.google.cloud.hypercomputecluster.v1beta.IDeleteClusterRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.hypercomputecluster.v1beta.IDeleteClusterRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.hypercomputecluster.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteCluster( - request: protos.google.cloud.hypercomputecluster.v1beta.IDeleteClusterRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.hypercomputecluster.v1beta.IDeleteClusterRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.hypercomputecluster.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteCluster( - request: protos.google.cloud.hypercomputecluster.v1beta.IDeleteClusterRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.hypercomputecluster.v1beta.IDeleteClusterRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.hypercomputecluster.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteCluster( - request?: protos.google.cloud.hypercomputecluster.v1beta.IDeleteClusterRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.hypercomputecluster.v1beta.IDeleteClusterRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.hypercomputecluster.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.hypercomputecluster.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.hypercomputecluster.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.hypercomputecluster.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteCluster response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteCluster request %j', request); - return this.innerApiCalls.deleteCluster(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteCluster response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteCluster(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.hypercomputecluster.v1beta.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteCluster response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteCluster()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/hypercompute_cluster.delete_cluster.js - * region_tag:hypercomputecluster_v1beta_generated_HypercomputeCluster_DeleteCluster_async - */ - async checkDeleteClusterProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteCluster()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/hypercompute_cluster.delete_cluster.js + * region_tag:hypercomputecluster_v1beta_generated_HypercomputeCluster_DeleteCluster_async + */ + async checkDeleteClusterProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.hypercomputecluster.v1beta.OperationMetadata + > + > { this._log.info('deleteCluster long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteCluster, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteCluster, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.hypercomputecluster.v1beta.OperationMetadata + >; } - /** - * Lists Clusters in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent location of the clusters to list, in the format - * `projects/{project}/locations/{location}`. - * @param {number} [request.pageSize] - * Optional. Maximum number of clusters to return. The service may return - * fewer than this value. - * @param {string} [request.pageToken] - * Optional. A page token received from a previous `ListClusters` call. - * Provide this to retrieve the subsequent page. When paginating, all other - * parameters provided to `ListClusters` must match the call that provided the - * page token. - * @param {string} [request.filter] - * Optional. [Filter](https://google.aip.dev/160) to apply to the returned - * results. - * @param {string} [request.orderBy] - * Optional. How to order the resulting clusters. Must be one of the following - * strings: - * - * * `name` - * * `name desc` - * * `create_time` - * * `create_time desc` - * - * If not specified, clusters will be returned in an arbitrary 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.hypercomputecluster.v1beta.Cluster|Cluster}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listClustersAsync()` - * method described below for async iteration which you can stop as 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 Clusters in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent location of the clusters to list, in the format + * `projects/{project}/locations/{location}`. + * @param {number} [request.pageSize] + * Optional. Maximum number of clusters to return. The service may return + * fewer than this value. + * @param {string} [request.pageToken] + * Optional. A page token received from a previous `ListClusters` call. + * Provide this to retrieve the subsequent page. When paginating, all other + * parameters provided to `ListClusters` must match the call that provided the + * page token. + * @param {string} [request.filter] + * Optional. [Filter](https://google.aip.dev/160) to apply to the returned + * results. + * @param {string} [request.orderBy] + * Optional. How to order the resulting clusters. Must be one of the following + * strings: + * + * * `name` + * * `name desc` + * * `create_time` + * * `create_time desc` + * + * If not specified, clusters will be returned in an arbitrary 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.hypercomputecluster.v1beta.Cluster|Cluster}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listClustersAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listClusters( - request?: protos.google.cloud.hypercomputecluster.v1beta.IListClustersRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.hypercomputecluster.v1beta.ICluster[], - protos.google.cloud.hypercomputecluster.v1beta.IListClustersRequest|null, - protos.google.cloud.hypercomputecluster.v1beta.IListClustersResponse - ]>; + request?: protos.google.cloud.hypercomputecluster.v1beta.IListClustersRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.hypercomputecluster.v1beta.ICluster[], + protos.google.cloud.hypercomputecluster.v1beta.IListClustersRequest | null, + protos.google.cloud.hypercomputecluster.v1beta.IListClustersResponse, + ] + >; listClusters( - request: protos.google.cloud.hypercomputecluster.v1beta.IListClustersRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.hypercomputecluster.v1beta.IListClustersRequest, - protos.google.cloud.hypercomputecluster.v1beta.IListClustersResponse|null|undefined, - protos.google.cloud.hypercomputecluster.v1beta.ICluster>): void; + request: protos.google.cloud.hypercomputecluster.v1beta.IListClustersRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.hypercomputecluster.v1beta.IListClustersRequest, + | protos.google.cloud.hypercomputecluster.v1beta.IListClustersResponse + | null + | undefined, + protos.google.cloud.hypercomputecluster.v1beta.ICluster + >, + ): void; listClusters( - request: protos.google.cloud.hypercomputecluster.v1beta.IListClustersRequest, - callback: PaginationCallback< - protos.google.cloud.hypercomputecluster.v1beta.IListClustersRequest, - protos.google.cloud.hypercomputecluster.v1beta.IListClustersResponse|null|undefined, - protos.google.cloud.hypercomputecluster.v1beta.ICluster>): void; + request: protos.google.cloud.hypercomputecluster.v1beta.IListClustersRequest, + callback: PaginationCallback< + protos.google.cloud.hypercomputecluster.v1beta.IListClustersRequest, + | protos.google.cloud.hypercomputecluster.v1beta.IListClustersResponse + | null + | undefined, + protos.google.cloud.hypercomputecluster.v1beta.ICluster + >, + ): void; listClusters( - request?: protos.google.cloud.hypercomputecluster.v1beta.IListClustersRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.hypercomputecluster.v1beta.IListClustersRequest, - protos.google.cloud.hypercomputecluster.v1beta.IListClustersResponse|null|undefined, - protos.google.cloud.hypercomputecluster.v1beta.ICluster>, - callback?: PaginationCallback< + request?: protos.google.cloud.hypercomputecluster.v1beta.IListClustersRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.hypercomputecluster.v1beta.IListClustersRequest, - protos.google.cloud.hypercomputecluster.v1beta.IListClustersResponse|null|undefined, - protos.google.cloud.hypercomputecluster.v1beta.ICluster>): - Promise<[ - protos.google.cloud.hypercomputecluster.v1beta.ICluster[], - protos.google.cloud.hypercomputecluster.v1beta.IListClustersRequest|null, - protos.google.cloud.hypercomputecluster.v1beta.IListClustersResponse - ]>|void { + | protos.google.cloud.hypercomputecluster.v1beta.IListClustersResponse + | null + | undefined, + protos.google.cloud.hypercomputecluster.v1beta.ICluster + >, + callback?: PaginationCallback< + protos.google.cloud.hypercomputecluster.v1beta.IListClustersRequest, + | protos.google.cloud.hypercomputecluster.v1beta.IListClustersResponse + | null + | undefined, + protos.google.cloud.hypercomputecluster.v1beta.ICluster + >, + ): Promise< + [ + protos.google.cloud.hypercomputecluster.v1beta.ICluster[], + protos.google.cloud.hypercomputecluster.v1beta.IListClustersRequest | null, + protos.google.cloud.hypercomputecluster.v1beta.IListClustersResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-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.hypercomputecluster.v1beta.IListClustersRequest, - protos.google.cloud.hypercomputecluster.v1beta.IListClustersResponse|null|undefined, - protos.google.cloud.hypercomputecluster.v1beta.ICluster>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.hypercomputecluster.v1beta.IListClustersRequest, + | protos.google.cloud.hypercomputecluster.v1beta.IListClustersResponse + | null + | undefined, + protos.google.cloud.hypercomputecluster.v1beta.ICluster + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listClusters values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -960,145 +1314,150 @@ export class HypercomputeClusterClient { this._log.info('listClusters request %j', request); return this.innerApiCalls .listClusters(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.hypercomputecluster.v1beta.ICluster[], - protos.google.cloud.hypercomputecluster.v1beta.IListClustersRequest|null, - protos.google.cloud.hypercomputecluster.v1beta.IListClustersResponse - ]) => { - this._log.info('listClusters values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.hypercomputecluster.v1beta.ICluster[], + protos.google.cloud.hypercomputecluster.v1beta.IListClustersRequest | null, + protos.google.cloud.hypercomputecluster.v1beta.IListClustersResponse, + ]) => { + this._log.info('listClusters values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listClusters`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent location of the clusters to list, in the format - * `projects/{project}/locations/{location}`. - * @param {number} [request.pageSize] - * Optional. Maximum number of clusters to return. The service may return - * fewer than this value. - * @param {string} [request.pageToken] - * Optional. A page token received from a previous `ListClusters` call. - * Provide this to retrieve the subsequent page. When paginating, all other - * parameters provided to `ListClusters` must match the call that provided the - * page token. - * @param {string} [request.filter] - * Optional. [Filter](https://google.aip.dev/160) to apply to the returned - * results. - * @param {string} [request.orderBy] - * Optional. How to order the resulting clusters. Must be one of the following - * strings: - * - * * `name` - * * `name desc` - * * `create_time` - * * `create_time desc` - * - * If not specified, clusters will be returned in an arbitrary 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.hypercomputecluster.v1beta.Cluster|Cluster} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listClustersAsync()` - * method described below for async iteration which you can stop as 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 `listClusters`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent location of the clusters to list, in the format + * `projects/{project}/locations/{location}`. + * @param {number} [request.pageSize] + * Optional. Maximum number of clusters to return. The service may return + * fewer than this value. + * @param {string} [request.pageToken] + * Optional. A page token received from a previous `ListClusters` call. + * Provide this to retrieve the subsequent page. When paginating, all other + * parameters provided to `ListClusters` must match the call that provided the + * page token. + * @param {string} [request.filter] + * Optional. [Filter](https://google.aip.dev/160) to apply to the returned + * results. + * @param {string} [request.orderBy] + * Optional. How to order the resulting clusters. Must be one of the following + * strings: + * + * * `name` + * * `name desc` + * * `create_time` + * * `create_time desc` + * + * If not specified, clusters will be returned in an arbitrary 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.hypercomputecluster.v1beta.Cluster|Cluster} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listClustersAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listClustersStream( - request?: protos.google.cloud.hypercomputecluster.v1beta.IListClustersRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.hypercomputecluster.v1beta.IListClustersRequest, + 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['listClusters']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listClusters stream %j', request); return this.descriptors.page.listClusters.createStream( this.innerApiCalls.listClusters as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listClusters`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used 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 location of the clusters to list, in the format - * `projects/{project}/locations/{location}`. - * @param {number} [request.pageSize] - * Optional. Maximum number of clusters to return. The service may return - * fewer than this value. - * @param {string} [request.pageToken] - * Optional. A page token received from a previous `ListClusters` call. - * Provide this to retrieve the subsequent page. When paginating, all other - * parameters provided to `ListClusters` must match the call that provided the - * page token. - * @param {string} [request.filter] - * Optional. [Filter](https://google.aip.dev/160) to apply to the returned - * results. - * @param {string} [request.orderBy] - * Optional. How to order the resulting clusters. Must be one of the following - * strings: - * - * * `name` - * * `name desc` - * * `create_time` - * * `create_time desc` - * - * If not specified, clusters will be returned in an arbitrary 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.hypercomputecluster.v1beta.Cluster|Cluster}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta/hypercompute_cluster.list_clusters.js - * region_tag:hypercomputecluster_v1beta_generated_HypercomputeCluster_ListClusters_async - */ + /** + * Equivalent to `listClusters`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used 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 location of the clusters to list, in the format + * `projects/{project}/locations/{location}`. + * @param {number} [request.pageSize] + * Optional. Maximum number of clusters to return. The service may return + * fewer than this value. + * @param {string} [request.pageToken] + * Optional. A page token received from a previous `ListClusters` call. + * Provide this to retrieve the subsequent page. When paginating, all other + * parameters provided to `ListClusters` must match the call that provided the + * page token. + * @param {string} [request.filter] + * Optional. [Filter](https://google.aip.dev/160) to apply to the returned + * results. + * @param {string} [request.orderBy] + * Optional. How to order the resulting clusters. Must be one of the following + * strings: + * + * * `name` + * * `name desc` + * * `create_time` + * * `create_time desc` + * + * If not specified, clusters will be returned in an arbitrary 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.hypercomputecluster.v1beta.Cluster|Cluster}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta/hypercompute_cluster.list_clusters.js + * region_tag:hypercomputecluster_v1beta_generated_HypercomputeCluster_ListClusters_async + */ listClustersAsync( - request?: protos.google.cloud.hypercomputecluster.v1beta.IListClustersRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.hypercomputecluster.v1beta.IListClustersRequest, + 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['listClusters']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listClusters iterate %j', request); return this.descriptors.page.listClusters.asyncIterate( this.innerApiCalls['listClusters'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** + + /** * Gets information about a location. * * @param {Object} request @@ -1133,12 +1492,11 @@ export class HypercomputeClusterClient { | 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. @@ -1171,12 +1529,12 @@ export class HypercomputeClusterClient { */ 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. @@ -1219,22 +1577,22 @@ export class HypercomputeClusterClient { 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); } /** @@ -1269,15 +1627,15 @@ export class HypercomputeClusterClient { */ 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); } /** @@ -1311,7 +1669,7 @@ export class HypercomputeClusterClient { * await client.cancelOperation({name: ''}); * ``` */ - cancelOperation( + cancelOperation( request: protos.google.longrunning.CancelOperationRequest, optionsOrCallback?: | gax.CallOptions @@ -1324,25 +1682,24 @@ export class HypercomputeClusterClient { 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 @@ -1381,22 +1738,22 @@ export class HypercomputeClusterClient { 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); } @@ -1411,7 +1768,7 @@ export class HypercomputeClusterClient { * @param {string} bucket * @returns {string} Resource name string. */ - bucketPath(project:string,bucket:string) { + bucketPath(project: string, bucket: string) { return this.pathTemplates.bucketPathTemplate.render({ project: project, bucket: bucket, @@ -1448,7 +1805,7 @@ export class HypercomputeClusterClient { * @param {string} cluster * @returns {string} Resource name string. */ - clusterPath(project:string,location:string,cluster:string) { + clusterPath(project: string, location: string, cluster: string) { return this.pathTemplates.clusterPathTemplate.render({ project: project, location: location, @@ -1497,7 +1854,7 @@ export class HypercomputeClusterClient { * @param {string} instance * @returns {string} Resource name string. */ - computeInstancePath(project:string,zone:string,instance:string) { + computeInstancePath(project: string, zone: string, instance: string) { return this.pathTemplates.computeInstancePathTemplate.render({ project: project, zone: zone, @@ -1513,7 +1870,9 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the project. */ matchProjectFromComputeInstanceName(computeInstanceName: string) { - return this.pathTemplates.computeInstancePathTemplate.match(computeInstanceName).project; + return this.pathTemplates.computeInstancePathTemplate.match( + computeInstanceName, + ).project; } /** @@ -1524,7 +1883,9 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the zone. */ matchZoneFromComputeInstanceName(computeInstanceName: string) { - return this.pathTemplates.computeInstancePathTemplate.match(computeInstanceName).zone; + return this.pathTemplates.computeInstancePathTemplate.match( + computeInstanceName, + ).zone; } /** @@ -1535,7 +1896,9 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the instance. */ matchInstanceFromComputeInstanceName(computeInstanceName: string) { - return this.pathTemplates.computeInstancePathTemplate.match(computeInstanceName).instance; + return this.pathTemplates.computeInstancePathTemplate.match( + computeInstanceName, + ).instance; } /** @@ -1546,7 +1909,7 @@ export class HypercomputeClusterClient { * @param {string} disk_type * @returns {string} Resource name string. */ - diskTypePath(project:string,zone:string,diskType:string) { + diskTypePath(project: string, zone: string, diskType: string) { return this.pathTemplates.diskTypePathTemplate.render({ project: project, zone: zone, @@ -1584,7 +1947,8 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the disk_type. */ matchDiskTypeFromDiskTypeName(diskTypeName: string) { - return this.pathTemplates.diskTypePathTemplate.match(diskTypeName).disk_type; + return this.pathTemplates.diskTypePathTemplate.match(diskTypeName) + .disk_type; } /** @@ -1594,7 +1958,7 @@ export class HypercomputeClusterClient { * @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, @@ -1631,7 +1995,7 @@ export class HypercomputeClusterClient { * @param {string} instance * @returns {string} Resource name string. */ - lustreInstancePath(project:string,location:string,instance:string) { + lustreInstancePath(project: string, location: string, instance: string) { return this.pathTemplates.lustreInstancePathTemplate.render({ project: project, location: location, @@ -1647,7 +2011,9 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the project. */ matchProjectFromLustreInstanceName(lustreInstanceName: string) { - return this.pathTemplates.lustreInstancePathTemplate.match(lustreInstanceName).project; + return this.pathTemplates.lustreInstancePathTemplate.match( + lustreInstanceName, + ).project; } /** @@ -1658,7 +2024,9 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the location. */ matchLocationFromLustreInstanceName(lustreInstanceName: string) { - return this.pathTemplates.lustreInstancePathTemplate.match(lustreInstanceName).location; + return this.pathTemplates.lustreInstancePathTemplate.match( + lustreInstanceName, + ).location; } /** @@ -1669,7 +2037,9 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the instance. */ matchInstanceFromLustreInstanceName(lustreInstanceName: string) { - return this.pathTemplates.lustreInstancePathTemplate.match(lustreInstanceName).instance; + return this.pathTemplates.lustreInstancePathTemplate.match( + lustreInstanceName, + ).instance; } /** @@ -1679,7 +2049,7 @@ export class HypercomputeClusterClient { * @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, @@ -1714,7 +2084,7 @@ export class HypercomputeClusterClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -1739,7 +2109,7 @@ export class HypercomputeClusterClient { * @param {string} reservation * @returns {string} Resource name string. */ - reservationPath(project:string,zone:string,reservation:string) { + reservationPath(project: string, zone: string, reservation: string) { return this.pathTemplates.reservationPathTemplate.render({ project: project, zone: zone, @@ -1755,7 +2125,8 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the project. */ matchProjectFromReservationName(reservationName: string) { - return this.pathTemplates.reservationPathTemplate.match(reservationName).project; + return this.pathTemplates.reservationPathTemplate.match(reservationName) + .project; } /** @@ -1766,7 +2137,8 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the zone. */ matchZoneFromReservationName(reservationName: string) { - return this.pathTemplates.reservationPathTemplate.match(reservationName).zone; + return this.pathTemplates.reservationPathTemplate.match(reservationName) + .zone; } /** @@ -1777,7 +2149,8 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the reservation. */ matchReservationFromReservationName(reservationName: string) { - return this.pathTemplates.reservationPathTemplate.match(reservationName).reservation; + return this.pathTemplates.reservationPathTemplate.match(reservationName) + .reservation; } /** @@ -1788,7 +2161,7 @@ export class HypercomputeClusterClient { * @param {string} subnetwork * @returns {string} Resource name string. */ - subnetworkPath(project:string,region:string,subnetwork:string) { + subnetworkPath(project: string, region: string, subnetwork: string) { return this.pathTemplates.subnetworkPathTemplate.render({ project: project, region: region, @@ -1804,7 +2177,8 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the project. */ matchProjectFromSubnetworkName(subnetworkName: string) { - return this.pathTemplates.subnetworkPathTemplate.match(subnetworkName).project; + return this.pathTemplates.subnetworkPathTemplate.match(subnetworkName) + .project; } /** @@ -1815,7 +2189,8 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the region. */ matchRegionFromSubnetworkName(subnetworkName: string) { - return this.pathTemplates.subnetworkPathTemplate.match(subnetworkName).region; + return this.pathTemplates.subnetworkPathTemplate.match(subnetworkName) + .region; } /** @@ -1826,7 +2201,8 @@ export class HypercomputeClusterClient { * @returns {string} A string representing the subnetwork. */ matchSubnetworkFromSubnetworkName(subnetworkName: string) { - return this.pathTemplates.subnetworkPathTemplate.match(subnetworkName).subnetwork; + return this.pathTemplates.subnetworkPathTemplate.match(subnetworkName) + .subnetwork; } /** @@ -1837,14 +2213,16 @@ export class HypercomputeClusterClient { */ close(): Promise { if (this.hypercomputeClusterStub && !this._terminated) { - return this.hypercomputeClusterStub.then(stub => { + return this.hypercomputeClusterStub.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-hypercomputecluster/src/v1beta/index.ts b/packages/google-cloud-hypercomputecluster/src/v1beta/index.ts index ee3f58bb3a68..9b93e8506ac2 100644 --- a/packages/google-cloud-hypercomputecluster/src/v1beta/index.ts +++ b/packages/google-cloud-hypercomputecluster/src/v1beta/index.ts @@ -16,4 +16,4 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {HypercomputeClusterClient} from './hypercompute_cluster_client'; +export { HypercomputeClusterClient } from './hypercompute_cluster_client'; diff --git a/packages/google-cloud-hypercomputecluster/system-test/fixtures/sample/src/index.ts b/packages/google-cloud-hypercomputecluster/system-test/fixtures/sample/src/index.ts index b6d93791f63c..b725da65fb48 100644 --- a/packages/google-cloud-hypercomputecluster/system-test/fixtures/sample/src/index.ts +++ b/packages/google-cloud-hypercomputecluster/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 {HypercomputeClusterClient} from '@google-cloud/hypercomputecluster'; +import { HypercomputeClusterClient } from '@google-cloud/hypercomputecluster'; // check that the client class type name can be used -function doStuffWithHypercomputeClusterClient(client: HypercomputeClusterClient) { +function doStuffWithHypercomputeClusterClient( + client: HypercomputeClusterClient, +) { client.close(); } diff --git a/packages/google-cloud-hypercomputecluster/system-test/install.ts b/packages/google-cloud-hypercomputecluster/system-test/install.ts index f66069aa3940..ccf167042d2e 100644 --- a/packages/google-cloud-hypercomputecluster/system-test/install.ts +++ b/packages/google-cloud-hypercomputecluster/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-hypercomputecluster/test/gapic_hypercompute_cluster_v1.ts b/packages/google-cloud-hypercomputecluster/test/gapic_hypercompute_cluster_v1.ts index 6eb86bfce14a..b5f8d5e91f7f 100644 --- a/packages/google-cloud-hypercomputecluster/test/gapic_hypercompute_cluster_v1.ts +++ b/packages/google-cloud-hypercomputecluster/test/gapic_hypercompute_cluster_v1.ts @@ -19,1922 +19,2603 @@ 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 hypercomputeclusterModule 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.HypercomputeClusterClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'hypercomputecluster.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient(); - 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 = hypercomputeclusterModule.v1.HypercomputeClusterClient.servicePath; - assert.strictEqual(servicePath, 'hypercomputecluster.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = hypercomputeclusterModule.v1.HypercomputeClusterClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'hypercomputecluster.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'hypercomputecluster.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'hypercomputecluster.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 hypercomputeclusterModule.v1.HypercomputeClusterClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'hypercomputecluster.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 hypercomputeclusterModule.v1.HypercomputeClusterClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'hypercomputecluster.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 hypercomputeclusterModule.v1.HypercomputeClusterClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); - - it('has port', () => { - const port = hypercomputeclusterModule.v1.HypercomputeClusterClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.hypercomputeClusterStub, undefined); - await client.initialize(); - assert(client.hypercomputeClusterStub); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = + new hypercomputeclusterModule.v1.HypercomputeClusterClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'hypercomputecluster.googleapis.com'); + }); - it('has close method for the initialized client', done => { - const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.hypercomputeClusterStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has universeDomain', () => { + const client = + new hypercomputeclusterModule.v1.HypercomputeClusterClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('has close method for the non-initialized client', done => { - const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.hypercomputeClusterStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + hypercomputeclusterModule.v1.HypercomputeClusterClient.servicePath; + assert.strictEqual(servicePath, 'hypercomputecluster.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + hypercomputeclusterModule.v1.HypercomputeClusterClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'hypercomputecluster.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient( + { universeDomain: 'example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'hypercomputecluster.example.com'); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient( + { universe_domain: 'example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'hypercomputecluster.example.com'); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = + new hypercomputeclusterModule.v1.HypercomputeClusterClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'hypercomputecluster.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 hypercomputeclusterModule.v1.HypercomputeClusterClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual( + servicePath, + 'hypercomputecluster.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 hypercomputeclusterModule.v1.HypercomputeClusterClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); }); - describe('getCluster', () => { - it('invokes getCluster without error', async () => { - const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1.GetClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1.GetClusterRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1.Cluster() - ); - client.innerApiCalls.getCluster = stubSimpleCall(expectedResponse); - const [response] = await client.getCluster(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has port', () => { + const port = hypercomputeclusterModule.v1.HypercomputeClusterClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('invokes getCluster without error using callback', async () => { - const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1.GetClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1.GetClusterRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1.Cluster() - ); - client.innerApiCalls.getCluster = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getCluster( - request, - (err?: Error|null, result?: protos.google.cloud.hypercomputecluster.v1.ICluster|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCluster 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 hypercomputeclusterModule.v1.HypercomputeClusterClient(); + assert(client); + }); - it('invokes getCluster with error', async () => { - const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1.GetClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1.GetClusterRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getCluster = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getCluster(request), expectedError); - const actualRequest = (client.innerApiCalls.getCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCluster 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 hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + fallback: true, + }, + ); + assert(client); + }); - it('invokes getCluster with closed client', async () => { - const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1.GetClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1.GetClusterRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getCluster(request), expectedError); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + assert.strictEqual(client.hypercomputeClusterStub, undefined); + await client.initialize(); + assert(client.hypercomputeClusterStub); }); - describe('createCluster', () => { - it('invokes createCluster without error', async () => { - const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1.CreateClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1.CreateClusterRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createCluster = stubLongRunningCall(expectedResponse); - const [operation] = await client.createCluster(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCluster 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 hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + client.initialize().catch((err) => { + throw err; + }); + assert(client.hypercomputeClusterStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes createCluster without error using callback', async () => { - const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1.CreateClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1.CreateClusterRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createCluster = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createCluster( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCluster 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 hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + assert.strictEqual(client.hypercomputeClusterStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes createCluster with call error', async () => { - const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1.CreateClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1.CreateClusterRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createCluster = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createCluster(request), expectedError); - const actualRequest = (client.innerApiCalls.createCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCluster 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 hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + 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 createCluster with LRO error', async () => { - const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1.CreateClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1.CreateClusterRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createCluster = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createCluster(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCluster 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 hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + 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('getCluster', () => { + it('invokes getCluster without error', async () => { + const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1.GetClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1.GetClusterRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1.Cluster(), + ); + client.innerApiCalls.getCluster = stubSimpleCall(expectedResponse); + const [response] = await client.getCluster(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateClusterProgress without error', async () => { - const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateClusterProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes getCluster without error using callback', async () => { + const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1.GetClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1.GetClusterRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1.Cluster(), + ); + client.innerApiCalls.getCluster = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getCluster( + request, + ( + err?: Error | null, + result?: protos.google.cloud.hypercomputecluster.v1.ICluster | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateClusterProgress with error', async () => { - const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes getCluster with error', async () => { + const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1.GetClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1.GetClusterRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getCluster = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getCluster(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateClusterProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes getCluster with closed client', async () => { + const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1.GetClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1.GetClusterRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getCluster(request), expectedError); + }); + }); + + describe('createCluster', () => { + it('invokes createCluster without error', async () => { + const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1.CreateClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1.CreateClusterRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createCluster = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createCluster(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateCluster', () => { - it('invokes updateCluster without error', async () => { - const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1.UpdateClusterRequest() - ); - request.cluster ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1.UpdateClusterRequest', ['cluster', 'name']); - request.cluster.name = defaultValue1; - const expectedHeaderRequestParams = `cluster.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateCluster = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateCluster(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createCluster without error using callback', async () => { + const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1.CreateClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1.CreateClusterRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createCluster = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createCluster( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.hypercomputecluster.v1.ICluster, + protos.google.cloud.hypercomputecluster.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.hypercomputecluster.v1.ICluster, + protos.google.cloud.hypercomputecluster.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateCluster without error using callback', async () => { - const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1.UpdateClusterRequest() - ); - request.cluster ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1.UpdateClusterRequest', ['cluster', 'name']); - request.cluster.name = defaultValue1; - const expectedHeaderRequestParams = `cluster.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateCluster = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateCluster( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createCluster with call error', async () => { + const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1.CreateClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1.CreateClusterRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createCluster = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createCluster(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateCluster with call error', async () => { - const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1.UpdateClusterRequest() - ); - request.cluster ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1.UpdateClusterRequest', ['cluster', 'name']); - request.cluster.name = defaultValue1; - const expectedHeaderRequestParams = `cluster.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateCluster = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateCluster(request), expectedError); - const actualRequest = (client.innerApiCalls.updateCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createCluster with LRO error', async () => { + const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1.CreateClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1.CreateClusterRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createCluster = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createCluster(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateCluster with LRO error', async () => { - const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1.UpdateClusterRequest() - ); - request.cluster ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1.UpdateClusterRequest', ['cluster', 'name']); - request.cluster.name = defaultValue1; - const expectedHeaderRequestParams = `cluster.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateCluster = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateCluster(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateClusterProgress without error', async () => { + const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateClusterProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkUpdateClusterProgress without error', async () => { - const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateClusterProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkCreateClusterProgress with error', async () => { + const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateClusterProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateCluster', () => { + it('invokes updateCluster without error', async () => { + const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1.UpdateClusterRequest(), + ); + request.cluster ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1.UpdateClusterRequest', + ['cluster', 'name'], + ); + request.cluster.name = defaultValue1; + const expectedHeaderRequestParams = `cluster.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateCluster = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateCluster(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateClusterProgress with error', async () => { - const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes updateCluster without error using callback', async () => { + const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1.UpdateClusterRequest(), + ); + request.cluster ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1.UpdateClusterRequest', + ['cluster', 'name'], + ); + request.cluster.name = defaultValue1; + const expectedHeaderRequestParams = `cluster.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateCluster = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateCluster( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.hypercomputecluster.v1.ICluster, + protos.google.cloud.hypercomputecluster.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.hypercomputecluster.v1.ICluster, + protos.google.cloud.hypercomputecluster.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateClusterProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes updateCluster with call error', async () => { + const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1.UpdateClusterRequest(), + ); + request.cluster ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1.UpdateClusterRequest', + ['cluster', 'name'], + ); + request.cluster.name = defaultValue1; + const expectedHeaderRequestParams = `cluster.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateCluster = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateCluster(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteCluster', () => { - it('invokes deleteCluster without error', async () => { - const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1.DeleteClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1.DeleteClusterRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteCluster = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteCluster(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateCluster with LRO error', async () => { + const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1.UpdateClusterRequest(), + ); + request.cluster ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1.UpdateClusterRequest', + ['cluster', 'name'], + ); + request.cluster.name = defaultValue1; + const expectedHeaderRequestParams = `cluster.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateCluster = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateCluster(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteCluster without error using callback', async () => { - const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1.DeleteClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1.DeleteClusterRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteCluster = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteCluster( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateClusterProgress without error', async () => { + const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdateClusterProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes deleteCluster with call error', async () => { - const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1.DeleteClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1.DeleteClusterRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteCluster = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteCluster(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateClusterProgress with error', async () => { + const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateClusterProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteCluster', () => { + it('invokes deleteCluster without error', async () => { + const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1.DeleteClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1.DeleteClusterRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteCluster = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteCluster(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteCluster with LRO error', async () => { - const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1.DeleteClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1.DeleteClusterRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteCluster = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteCluster(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteCluster without error using callback', async () => { + const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1.DeleteClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1.DeleteClusterRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteCluster = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteCluster( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.hypercomputecluster.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.hypercomputecluster.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteClusterProgress without error', async () => { - const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteClusterProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes deleteCluster with call error', async () => { + const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1.DeleteClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1.DeleteClusterRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteCluster = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteCluster(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteClusterProgress with error', async () => { - const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes deleteCluster with LRO error', async () => { + const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1.DeleteClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1.DeleteClusterRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteCluster = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteCluster(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteClusterProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkDeleteClusterProgress without error', async () => { + const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteClusterProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('listClusters', () => { - it('invokes listClusters without error', async () => { - const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1.ListClustersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1.ListClustersRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1.Cluster()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1.Cluster()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1.Cluster()), - ]; - client.innerApiCalls.listClusters = stubSimpleCall(expectedResponse); - const [response] = await client.listClusters(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listClusters as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listClusters as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteClusterProgress with error', async () => { + const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteClusterProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listClusters', () => { + it('invokes listClusters without error', async () => { + const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1.ListClustersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1.ListClustersRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1.Cluster(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1.Cluster(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1.Cluster(), + ), + ]; + client.innerApiCalls.listClusters = stubSimpleCall(expectedResponse); + const [response] = await client.listClusters(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listClusters as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listClusters as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listClusters without error using callback', async () => { - const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1.ListClustersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1.ListClustersRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1.Cluster()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1.Cluster()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1.Cluster()), - ]; - client.innerApiCalls.listClusters = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listClusters( - request, - (err?: Error|null, result?: protos.google.cloud.hypercomputecluster.v1.ICluster[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listClusters as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listClusters as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listClusters without error using callback', async () => { + const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1.ListClustersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1.ListClustersRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1.Cluster(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1.Cluster(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1.Cluster(), + ), + ]; + client.innerApiCalls.listClusters = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listClusters( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.hypercomputecluster.v1.ICluster[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listClusters as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listClusters as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listClusters with error', async () => { - const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1.ListClustersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1.ListClustersRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listClusters = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listClusters(request), expectedError); - const actualRequest = (client.innerApiCalls.listClusters as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listClusters as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listClusters with error', async () => { + const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1.ListClustersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1.ListClustersRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listClusters = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listClusters(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listClusters as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listClusters as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listClustersStream without error', async () => { - const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1.ListClustersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1.ListClustersRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1.Cluster()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1.Cluster()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1.Cluster()), - ]; - client.descriptors.page.listClusters.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listClustersStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.hypercomputecluster.v1.Cluster[] = []; - stream.on('data', (response: protos.google.cloud.hypercomputecluster.v1.Cluster) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listClusters.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listClusters, request)); - assert( - (client.descriptors.page.listClusters.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listClustersStream without error', async () => { + const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1.ListClustersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1.ListClustersRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1.Cluster(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1.Cluster(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1.Cluster(), + ), + ]; + client.descriptors.page.listClusters.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listClustersStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.hypercomputecluster.v1.Cluster[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.hypercomputecluster.v1.Cluster) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listClusters.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listClusters, request), + ); + assert( + (client.descriptors.page.listClusters.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listClustersStream with error', async () => { - const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1.ListClustersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1.ListClustersRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listClusters.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listClustersStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.hypercomputecluster.v1.Cluster[] = []; - stream.on('data', (response: protos.google.cloud.hypercomputecluster.v1.Cluster) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listClusters.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listClusters, request)); - assert( - (client.descriptors.page.listClusters.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listClustersStream with error', async () => { + const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1.ListClustersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1.ListClustersRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listClusters.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listClustersStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.hypercomputecluster.v1.Cluster[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.hypercomputecluster.v1.Cluster) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listClusters.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listClusters, request), + ); + assert( + (client.descriptors.page.listClusters.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listClusters without error', async () => { - const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1.ListClustersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1.ListClustersRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1.Cluster()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1.Cluster()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1.Cluster()), - ]; - client.descriptors.page.listClusters.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.hypercomputecluster.v1.ICluster[] = []; - const iterable = client.listClustersAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listClusters.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listClusters.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listClusters without error', async () => { + const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1.ListClustersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1.ListClustersRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1.Cluster(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1.Cluster(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1.Cluster(), + ), + ]; + client.descriptors.page.listClusters.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.hypercomputecluster.v1.ICluster[] = + []; + const iterable = client.listClustersAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listClusters.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listClusters.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listClusters with error', async () => { - const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1.ListClustersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1.ListClustersRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listClusters.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listClustersAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.hypercomputecluster.v1.ICluster[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listClusters.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listClusters.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listClusters with error', async () => { + const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1.ListClustersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1.ListClustersRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listClusters.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listClustersAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.hypercomputecluster.v1.ICluster[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listClusters.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listClusters.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 hypercomputeclusterModule.v1.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - 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 hypercomputeclusterModule.v1.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - 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 hypercomputeclusterModule.v1.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - 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 hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + 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 hypercomputeclusterModule.v1.HypercomputeClusterClient({ - 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 hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + 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 hypercomputeclusterModule.v1.HypercomputeClusterClient({ - 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 hypercomputeclusterModule.v1.HypercomputeClusterClient({ - 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 hypercomputeclusterModule.v1.HypercomputeClusterClient({ - 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 hypercomputeclusterModule.v1.HypercomputeClusterClient({ - 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 hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + 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 hypercomputeclusterModule.v1.HypercomputeClusterClient({ - 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 hypercomputeclusterModule.v1.HypercomputeClusterClient({ - 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 hypercomputeclusterModule.v1.HypercomputeClusterClient({ - 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 hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + 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 hypercomputeclusterModule.v1.HypercomputeClusterClient({ - 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 hypercomputeclusterModule.v1.HypercomputeClusterClient({ - 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 hypercomputeclusterModule.v1.HypercomputeClusterClient({ - 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 hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + 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 hypercomputeclusterModule.v1.HypercomputeClusterClient({ - 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 hypercomputeclusterModule.v1.HypercomputeClusterClient({ - 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 hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + 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 hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + 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 hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + 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 hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + 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 hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + 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 hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + 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 hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + 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 hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + 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 hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + 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 hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + 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 hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + 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('bucket', async () => { + const fakePath = '/rendered/path/bucket'; + const expectedParameters = { + project: 'projectValue', + bucket: 'bucketValue', + }; + const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.bucketPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.bucketPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('bucketPath', () => { + const result = client.bucketPath('projectValue', 'bucketValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.bucketPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromBucketName', () => { + const result = client.matchProjectFromBucketName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.bucketPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchBucketFromBucketName', () => { + const result = client.matchBucketFromBucketName(fakePath); + assert.strictEqual(result, 'bucketValue'); + assert( + (client.pathTemplates.bucketPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); - describe('Path templates', () => { - - describe('bucket', async () => { - const fakePath = "/rendered/path/bucket"; - const expectedParameters = { - project: "projectValue", - bucket: "bucketValue", - }; - const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.bucketPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.bucketPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('bucketPath', () => { - const result = client.bucketPath("projectValue", "bucketValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.bucketPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromBucketName', () => { - const result = client.matchProjectFromBucketName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.bucketPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBucketFromBucketName', () => { - const result = client.matchBucketFromBucketName(fakePath); - assert.strictEqual(result, "bucketValue"); - assert((client.pathTemplates.bucketPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('cluster', async () => { - const fakePath = "/rendered/path/cluster"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - cluster: "clusterValue", - }; - const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.clusterPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.clusterPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('clusterPath', () => { - const result = client.clusterPath("projectValue", "locationValue", "clusterValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.clusterPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromClusterName', () => { - const result = client.matchProjectFromClusterName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.clusterPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromClusterName', () => { - const result = client.matchLocationFromClusterName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.clusterPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchClusterFromClusterName', () => { - const result = client.matchClusterFromClusterName(fakePath); - assert.strictEqual(result, "clusterValue"); - assert((client.pathTemplates.clusterPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('computeInstance', async () => { - const fakePath = "/rendered/path/computeInstance"; - const expectedParameters = { - project: "projectValue", - zone: "zoneValue", - instance: "instanceValue", - }; - const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.computeInstancePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.computeInstancePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('computeInstancePath', () => { - const result = client.computeInstancePath("projectValue", "zoneValue", "instanceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.computeInstancePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromComputeInstanceName', () => { - const result = client.matchProjectFromComputeInstanceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.computeInstancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchZoneFromComputeInstanceName', () => { - const result = client.matchZoneFromComputeInstanceName(fakePath); - assert.strictEqual(result, "zoneValue"); - assert((client.pathTemplates.computeInstancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInstanceFromComputeInstanceName', () => { - const result = client.matchInstanceFromComputeInstanceName(fakePath); - assert.strictEqual(result, "instanceValue"); - assert((client.pathTemplates.computeInstancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('diskType', async () => { - const fakePath = "/rendered/path/diskType"; - const expectedParameters = { - project: "projectValue", - zone: "zoneValue", - disk_type: "diskTypeValue", - }; - const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.diskTypePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.diskTypePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('diskTypePath', () => { - const result = client.diskTypePath("projectValue", "zoneValue", "diskTypeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.diskTypePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromDiskTypeName', () => { - const result = client.matchProjectFromDiskTypeName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.diskTypePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchZoneFromDiskTypeName', () => { - const result = client.matchZoneFromDiskTypeName(fakePath); - assert.strictEqual(result, "zoneValue"); - assert((client.pathTemplates.diskTypePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDiskTypeFromDiskTypeName', () => { - const result = client.matchDiskTypeFromDiskTypeName(fakePath); - assert.strictEqual(result, "diskTypeValue"); - assert((client.pathTemplates.diskTypePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('fileInstance', async () => { - const fakePath = "/rendered/path/fileInstance"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - instance: "instanceValue", - }; - const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.fileInstancePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.fileInstancePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('fileInstancePath', () => { - const result = client.fileInstancePath("projectValue", "locationValue", "instanceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.fileInstancePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromFileInstanceName', () => { - const result = client.matchProjectFromFileInstanceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.fileInstancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromFileInstanceName', () => { - const result = client.matchLocationFromFileInstanceName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.fileInstancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInstanceFromFileInstanceName', () => { - const result = client.matchInstanceFromFileInstanceName(fakePath); - assert.strictEqual(result, "instanceValue"); - assert((client.pathTemplates.fileInstancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('location', async () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('network', async () => { - const fakePath = "/rendered/path/network"; - const expectedParameters = { - project: "projectValue", - network: "networkValue", - }; - const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.networkPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.networkPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('networkPath', () => { - const result = client.networkPath("projectValue", "networkValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.networkPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromNetworkName', () => { - const result = client.matchProjectFromNetworkName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.networkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchNetworkFromNetworkName', () => { - const result = client.matchNetworkFromNetworkName(fakePath); - assert.strictEqual(result, "networkValue"); - assert((client.pathTemplates.networkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('project', async () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient({ - 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('cluster', async () => { + const fakePath = '/rendered/path/cluster'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + cluster: 'clusterValue', + }; + const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.clusterPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.clusterPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('clusterPath', () => { + const result = client.clusterPath( + 'projectValue', + 'locationValue', + 'clusterValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.clusterPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromClusterName', () => { + const result = client.matchProjectFromClusterName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.clusterPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromClusterName', () => { + const result = client.matchLocationFromClusterName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.clusterPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchClusterFromClusterName', () => { + const result = client.matchClusterFromClusterName(fakePath); + assert.strictEqual(result, 'clusterValue'); + assert( + (client.pathTemplates.clusterPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('reservation', async () => { - const fakePath = "/rendered/path/reservation"; - const expectedParameters = { - project: "projectValue", - zone: "zoneValue", - reservation: "reservationValue", - }; - const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.reservationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.reservationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('reservationPath', () => { - const result = client.reservationPath("projectValue", "zoneValue", "reservationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.reservationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + describe('computeInstance', async () => { + const fakePath = '/rendered/path/computeInstance'; + const expectedParameters = { + project: 'projectValue', + zone: 'zoneValue', + instance: 'instanceValue', + }; + const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.computeInstancePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.computeInstancePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('computeInstancePath', () => { + const result = client.computeInstancePath( + 'projectValue', + 'zoneValue', + 'instanceValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.computeInstancePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromComputeInstanceName', () => { + const result = client.matchProjectFromComputeInstanceName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.computeInstancePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchZoneFromComputeInstanceName', () => { + const result = client.matchZoneFromComputeInstanceName(fakePath); + assert.strictEqual(result, 'zoneValue'); + assert( + (client.pathTemplates.computeInstancePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchInstanceFromComputeInstanceName', () => { + const result = client.matchInstanceFromComputeInstanceName(fakePath); + assert.strictEqual(result, 'instanceValue'); + assert( + (client.pathTemplates.computeInstancePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchProjectFromReservationName', () => { - const result = client.matchProjectFromReservationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.reservationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('diskType', async () => { + const fakePath = '/rendered/path/diskType'; + const expectedParameters = { + project: 'projectValue', + zone: 'zoneValue', + disk_type: 'diskTypeValue', + }; + const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.diskTypePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.diskTypePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('diskTypePath', () => { + const result = client.diskTypePath( + 'projectValue', + 'zoneValue', + 'diskTypeValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.diskTypePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromDiskTypeName', () => { + const result = client.matchProjectFromDiskTypeName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.diskTypePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchZoneFromDiskTypeName', () => { + const result = client.matchZoneFromDiskTypeName(fakePath); + assert.strictEqual(result, 'zoneValue'); + assert( + (client.pathTemplates.diskTypePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchDiskTypeFromDiskTypeName', () => { + const result = client.matchDiskTypeFromDiskTypeName(fakePath); + assert.strictEqual(result, 'diskTypeValue'); + assert( + (client.pathTemplates.diskTypePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchZoneFromReservationName', () => { - const result = client.matchZoneFromReservationName(fakePath); - assert.strictEqual(result, "zoneValue"); - assert((client.pathTemplates.reservationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('fileInstance', async () => { + const fakePath = '/rendered/path/fileInstance'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + instance: 'instanceValue', + }; + const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.fileInstancePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.fileInstancePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('fileInstancePath', () => { + const result = client.fileInstancePath( + 'projectValue', + 'locationValue', + 'instanceValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.fileInstancePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromFileInstanceName', () => { + const result = client.matchProjectFromFileInstanceName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.fileInstancePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromFileInstanceName', () => { + const result = client.matchLocationFromFileInstanceName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.fileInstancePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchInstanceFromFileInstanceName', () => { + const result = client.matchInstanceFromFileInstanceName(fakePath); + assert.strictEqual(result, 'instanceValue'); + assert( + (client.pathTemplates.fileInstancePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchReservationFromReservationName', () => { - const result = client.matchReservationFromReservationName(fakePath); - assert.strictEqual(result, "reservationValue"); - assert((client.pathTemplates.reservationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('location', async () => { + const fakePath = '/rendered/path/location'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + 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('subnetwork', async () => { - const fakePath = "/rendered/path/subnetwork"; - const expectedParameters = { - project: "projectValue", - region: "regionValue", - subnetwork: "subnetworkValue", - }; - const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.subnetworkPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.subnetworkPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('subnetworkPath', () => { - const result = client.subnetworkPath("projectValue", "regionValue", "subnetworkValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.subnetworkPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + describe('network', async () => { + const fakePath = '/rendered/path/network'; + const expectedParameters = { + project: 'projectValue', + network: 'networkValue', + }; + const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.networkPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.networkPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('networkPath', () => { + const result = client.networkPath('projectValue', 'networkValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.networkPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromNetworkName', () => { + const result = client.matchProjectFromNetworkName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.networkPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchNetworkFromNetworkName', () => { + const result = client.matchNetworkFromNetworkName(fakePath); + assert.strictEqual(result, 'networkValue'); + assert( + (client.pathTemplates.networkPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchProjectFromSubnetworkName', () => { - const result = client.matchProjectFromSubnetworkName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.subnetworkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('project', async () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + 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('matchRegionFromSubnetworkName', () => { - const result = client.matchRegionFromSubnetworkName(fakePath); - assert.strictEqual(result, "regionValue"); - assert((client.pathTemplates.subnetworkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('reservation', async () => { + const fakePath = '/rendered/path/reservation'; + const expectedParameters = { + project: 'projectValue', + zone: 'zoneValue', + reservation: 'reservationValue', + }; + const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.reservationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.reservationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('reservationPath', () => { + const result = client.reservationPath( + 'projectValue', + 'zoneValue', + 'reservationValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.reservationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromReservationName', () => { + const result = client.matchProjectFromReservationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.reservationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchZoneFromReservationName', () => { + const result = client.matchZoneFromReservationName(fakePath); + assert.strictEqual(result, 'zoneValue'); + assert( + (client.pathTemplates.reservationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchReservationFromReservationName', () => { + const result = client.matchReservationFromReservationName(fakePath); + assert.strictEqual(result, 'reservationValue'); + assert( + (client.pathTemplates.reservationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchSubnetworkFromSubnetworkName', () => { - const result = client.matchSubnetworkFromSubnetworkName(fakePath); - assert.strictEqual(result, "subnetworkValue"); - assert((client.pathTemplates.subnetworkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('subnetwork', async () => { + const fakePath = '/rendered/path/subnetwork'; + const expectedParameters = { + project: 'projectValue', + region: 'regionValue', + subnetwork: 'subnetworkValue', + }; + const client = new hypercomputeclusterModule.v1.HypercomputeClusterClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.subnetworkPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.subnetworkPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('subnetworkPath', () => { + const result = client.subnetworkPath( + 'projectValue', + 'regionValue', + 'subnetworkValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.subnetworkPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromSubnetworkName', () => { + const result = client.matchProjectFromSubnetworkName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.subnetworkPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRegionFromSubnetworkName', () => { + const result = client.matchRegionFromSubnetworkName(fakePath); + assert.strictEqual(result, 'regionValue'); + assert( + (client.pathTemplates.subnetworkPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchSubnetworkFromSubnetworkName', () => { + const result = client.matchSubnetworkFromSubnetworkName(fakePath); + assert.strictEqual(result, 'subnetworkValue'); + assert( + (client.pathTemplates.subnetworkPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-hypercomputecluster/test/gapic_hypercompute_cluster_v1alpha.ts b/packages/google-cloud-hypercomputecluster/test/gapic_hypercompute_cluster_v1alpha.ts index 05108e2f7d2d..397cabecba7e 100644 --- a/packages/google-cloud-hypercomputecluster/test/gapic_hypercompute_cluster_v1alpha.ts +++ b/packages/google-cloud-hypercomputecluster/test/gapic_hypercompute_cluster_v1alpha.ts @@ -19,2807 +19,3823 @@ 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 hypercomputeclusterModule 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('v1alpha.HypercomputeClusterClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'hypercomputecluster.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient(); - 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 = hypercomputeclusterModule.v1alpha.HypercomputeClusterClient.servicePath; - assert.strictEqual(servicePath, 'hypercomputecluster.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = hypercomputeclusterModule.v1alpha.HypercomputeClusterClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'hypercomputecluster.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'hypercomputecluster.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'hypercomputecluster.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 hypercomputeclusterModule.v1alpha.HypercomputeClusterClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'hypercomputecluster.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 hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'hypercomputecluster.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 hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'hypercomputecluster.googleapis.com'); + }); - it('has port', () => { - const port = hypercomputeclusterModule.v1alpha.HypercomputeClusterClient.port; - assert(port); - assert(typeof port === 'number'); - }); + it('has universeDomain', () => { + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('should create a client with no option', () => { - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient(); - assert(client); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + hypercomputeclusterModule.v1alpha.HypercomputeClusterClient + .servicePath; + assert.strictEqual(servicePath, 'hypercomputecluster.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + hypercomputeclusterModule.v1alpha.HypercomputeClusterClient + .apiEndpoint; + assert.strictEqual(apiEndpoint, 'hypercomputecluster.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + universeDomain: 'example.com', }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'hypercomputecluster.example.com'); + }); - it('should create a client with gRPC fallback', () => { - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - fallback: true, - }); - assert(client); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + universe_domain: 'example.com', }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'hypercomputecluster.example.com'); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.hypercomputeClusterStub, undefined); - await client.initialize(); - assert(client.hypercomputeClusterStub); + 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 hypercomputeclusterModule.v1alpha.HypercomputeClusterClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'hypercomputecluster.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 hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual( + servicePath, + 'hypercomputecluster.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 hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('has close method for the initialized client', done => { - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.hypercomputeClusterStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has port', () => { + const port = + hypercomputeclusterModule.v1alpha.HypercomputeClusterClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has close method for the non-initialized client', done => { - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.hypercomputeClusterStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('should create a client with no option', () => { + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient(); + assert(client); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - 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 hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + fallback: true, }); + assert(client); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - 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 hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + assert.strictEqual(client.hypercomputeClusterStub, undefined); + await client.initialize(); + assert(client.hypercomputeClusterStub); }); - describe('getCluster', () => { - it('invokes getCluster without error', async () => { - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.GetClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.GetClusterRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.Cluster() - ); - client.innerApiCalls.getCluster = stubSimpleCall(expectedResponse); - const [response] = await client.getCluster(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getCluster without error using callback', async () => { - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.GetClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.GetClusterRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.Cluster() - ); - client.innerApiCalls.getCluster = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getCluster( - request, - (err?: Error|null, result?: protos.google.cloud.hypercomputecluster.v1alpha.ICluster|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getCluster with error', async () => { - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.GetClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.GetClusterRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getCluster = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getCluster(request), expectedError); - const actualRequest = (client.innerApiCalls.getCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getCluster with closed client', async () => { - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.GetClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.GetClusterRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getCluster(request), expectedError); - }); - }); - - describe('getNode', () => { - it('invokes getNode without error', async () => { - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.GetNodeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.GetNodeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.Node() - ); - client.innerApiCalls.getNode = stubSimpleCall(expectedResponse); - const [response] = await client.getNode(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getNode as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getNode as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getNode without error using callback', async () => { - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.GetNodeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.GetNodeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.Node() - ); - client.innerApiCalls.getNode = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getNode( - request, - (err?: Error|null, result?: protos.google.cloud.hypercomputecluster.v1alpha.INode|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getNode as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getNode as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getNode with error', async () => { - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.GetNodeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.GetNodeRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getNode = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getNode(request), expectedError); - const actualRequest = (client.innerApiCalls.getNode as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getNode as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getNode with closed client', async () => { - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.GetNodeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.GetNodeRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getNode(request), expectedError); - }); - }); - - describe('createCluster', () => { - it('invokes createCluster without error', async () => { - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.CreateClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.CreateClusterRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createCluster = stubLongRunningCall(expectedResponse); - const [operation] = await client.createCluster(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createCluster without error using callback', async () => { - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.CreateClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.CreateClusterRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createCluster = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createCluster( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createCluster with call error', async () => { - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.CreateClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.CreateClusterRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createCluster = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createCluster(request), expectedError); - const actualRequest = (client.innerApiCalls.createCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createCluster with LRO error', async () => { - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.CreateClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.CreateClusterRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createCluster = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createCluster(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateClusterProgress without error', async () => { - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateClusterProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateClusterProgress with error', async () => { - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateClusterProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); + it('has close method for the initialized client', (done) => { + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.hypercomputeClusterStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('updateCluster', () => { - it('invokes updateCluster without error', async () => { - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.UpdateClusterRequest() - ); - request.cluster ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.UpdateClusterRequest', ['cluster', 'name']); - request.cluster.name = defaultValue1; - const expectedHeaderRequestParams = `cluster.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateCluster = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateCluster(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateCluster without error using callback', async () => { - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.UpdateClusterRequest() - ); - request.cluster ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.UpdateClusterRequest', ['cluster', 'name']); - request.cluster.name = defaultValue1; - const expectedHeaderRequestParams = `cluster.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateCluster = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateCluster( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateCluster with call error', async () => { - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.UpdateClusterRequest() - ); - request.cluster ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.UpdateClusterRequest', ['cluster', 'name']); - request.cluster.name = defaultValue1; - const expectedHeaderRequestParams = `cluster.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateCluster = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateCluster(request), expectedError); - const actualRequest = (client.innerApiCalls.updateCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateCluster with LRO error', async () => { - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.UpdateClusterRequest() - ); - request.cluster ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.UpdateClusterRequest', ['cluster', 'name']); - request.cluster.name = defaultValue1; - const expectedHeaderRequestParams = `cluster.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateCluster = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateCluster(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpdateClusterProgress without error', async () => { - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateClusterProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateClusterProgress with error', async () => { - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateClusterProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); + it('has close method for the non-initialized client', (done) => { + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.hypercomputeClusterStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('deleteCluster', () => { - it('invokes deleteCluster without error', async () => { - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.DeleteClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.DeleteClusterRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteCluster = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteCluster(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteCluster without error using callback', async () => { - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.DeleteClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.DeleteClusterRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteCluster = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteCluster( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteCluster with call error', async () => { - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.DeleteClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.DeleteClusterRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteCluster = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteCluster(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteCluster with LRO error', async () => { - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.DeleteClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.DeleteClusterRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteCluster = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteCluster(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteClusterProgress without error', async () => { - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteClusterProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteClusterProgress with error', async () => { - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - 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 hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + 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.checkDeleteClusterProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + 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('getCluster', () => { + it('invokes getCluster without error', async () => { + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.GetClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.GetClusterRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.Cluster(), + ); + client.innerApiCalls.getCluster = stubSimpleCall(expectedResponse); + const [response] = await client.getCluster(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listClusters', () => { - it('invokes listClusters without error', async () => { - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.ListClustersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.ListClustersRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.Cluster()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.Cluster()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.Cluster()), - ]; - client.innerApiCalls.listClusters = stubSimpleCall(expectedResponse); - const [response] = await client.listClusters(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listClusters as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listClusters as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listClusters without error using callback', async () => { - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.ListClustersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.ListClustersRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.Cluster()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.Cluster()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.Cluster()), - ]; - client.innerApiCalls.listClusters = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listClusters( - request, - (err?: Error|null, result?: protos.google.cloud.hypercomputecluster.v1alpha.ICluster[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listClusters as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listClusters as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listClusters with error', async () => { - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.ListClustersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.ListClustersRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listClusters = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listClusters(request), expectedError); - const actualRequest = (client.innerApiCalls.listClusters as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listClusters as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listClustersStream without error', async () => { - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.ListClustersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.ListClustersRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.Cluster()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.Cluster()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.Cluster()), - ]; - client.descriptors.page.listClusters.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listClustersStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.hypercomputecluster.v1alpha.Cluster[] = []; - stream.on('data', (response: protos.google.cloud.hypercomputecluster.v1alpha.Cluster) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listClusters.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listClusters, request)); - assert( - (client.descriptors.page.listClusters.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listClustersStream with error', async () => { - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.ListClustersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.ListClustersRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listClusters.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listClustersStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.hypercomputecluster.v1alpha.Cluster[] = []; - stream.on('data', (response: protos.google.cloud.hypercomputecluster.v1alpha.Cluster) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listClusters.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listClusters, request)); - assert( - (client.descriptors.page.listClusters.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listClusters without error', async () => { - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.ListClustersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.ListClustersRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.Cluster()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.Cluster()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.Cluster()), - ]; - client.descriptors.page.listClusters.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.hypercomputecluster.v1alpha.ICluster[] = []; - const iterable = client.listClustersAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listClusters.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listClusters.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listClusters with error', async () => { - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.ListClustersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.ListClustersRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listClusters.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listClustersAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.hypercomputecluster.v1alpha.ICluster[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listClusters.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listClusters.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listNodes', () => { - it('invokes listNodes without error', async () => { - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.ListNodesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.ListNodesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.Node()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.Node()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.Node()), - ]; - client.innerApiCalls.listNodes = stubSimpleCall(expectedResponse); - const [response] = await client.listNodes(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listNodes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listNodes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listNodes without error using callback', async () => { - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.ListNodesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.ListNodesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.Node()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.Node()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.Node()), - ]; - client.innerApiCalls.listNodes = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listNodes( - request, - (err?: Error|null, result?: protos.google.cloud.hypercomputecluster.v1alpha.INode[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listNodes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listNodes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listNodes with error', async () => { - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.ListNodesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.ListNodesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listNodes = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listNodes(request), expectedError); - const actualRequest = (client.innerApiCalls.listNodes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listNodes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listNodesStream without error', async () => { - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.ListNodesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.ListNodesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.Node()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.Node()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.Node()), - ]; - client.descriptors.page.listNodes.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listNodesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.hypercomputecluster.v1alpha.Node[] = []; - stream.on('data', (response: protos.google.cloud.hypercomputecluster.v1alpha.Node) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listNodes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listNodes, request)); - assert( - (client.descriptors.page.listNodes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listNodesStream with error', async () => { - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.ListNodesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.ListNodesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listNodes.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listNodesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.hypercomputecluster.v1alpha.Node[] = []; - stream.on('data', (response: protos.google.cloud.hypercomputecluster.v1alpha.Node) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listNodes.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listNodes, request)); - assert( - (client.descriptors.page.listNodes.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listNodes without error', async () => { - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.ListNodesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.ListNodesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.Node()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.Node()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.Node()), - ]; - client.descriptors.page.listNodes.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.hypercomputecluster.v1alpha.INode[] = []; - const iterable = client.listNodesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listNodes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listNodes.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listNodes with error', async () => { - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.ListNodesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.ListNodesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listNodes.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listNodesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.hypercomputecluster.v1alpha.INode[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listNodes.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listNodes.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 hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - 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 hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - 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 hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - 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 hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - 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 getCluster without error using callback', async () => { + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.GetClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.GetClusterRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.Cluster(), + ); + client.innerApiCalls.getCluster = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getCluster( + request, + ( + err?: Error | null, + result?: protos.google.cloud.hypercomputecluster.v1alpha.ICluster | 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 hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - 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 hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - 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 hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - 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 hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - 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 hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - 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 hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - 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 hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - 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 hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - 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 hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - 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 hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - 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 hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - 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 hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - 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.getCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('Path templates', () => { - - describe('bucket', async () => { - const fakePath = "/rendered/path/bucket"; - const expectedParameters = { - project: "projectValue", - bucket: "bucketValue", - }; - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.bucketPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.bucketPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('bucketPath', () => { - const result = client.bucketPath("projectValue", "bucketValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.bucketPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromBucketName', () => { - const result = client.matchProjectFromBucketName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.bucketPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBucketFromBucketName', () => { - const result = client.matchBucketFromBucketName(fakePath); - assert.strictEqual(result, "bucketValue"); - assert((client.pathTemplates.bucketPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('cluster', async () => { - const fakePath = "/rendered/path/cluster"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - cluster: "clusterValue", - }; - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.clusterPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.clusterPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('clusterPath', () => { - const result = client.clusterPath("projectValue", "locationValue", "clusterValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.clusterPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromClusterName', () => { - const result = client.matchProjectFromClusterName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.clusterPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromClusterName', () => { - const result = client.matchLocationFromClusterName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.clusterPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchClusterFromClusterName', () => { - const result = client.matchClusterFromClusterName(fakePath); - assert.strictEqual(result, "clusterValue"); - assert((client.pathTemplates.clusterPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('computeInstance', async () => { - const fakePath = "/rendered/path/computeInstance"; - const expectedParameters = { - project: "projectValue", - zone: "zoneValue", - instance: "instanceValue", - }; - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.computeInstancePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.computeInstancePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('computeInstancePath', () => { - const result = client.computeInstancePath("projectValue", "zoneValue", "instanceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.computeInstancePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromComputeInstanceName', () => { - const result = client.matchProjectFromComputeInstanceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.computeInstancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchZoneFromComputeInstanceName', () => { - const result = client.matchZoneFromComputeInstanceName(fakePath); - assert.strictEqual(result, "zoneValue"); - assert((client.pathTemplates.computeInstancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInstanceFromComputeInstanceName', () => { - const result = client.matchInstanceFromComputeInstanceName(fakePath); - assert.strictEqual(result, "instanceValue"); - assert((client.pathTemplates.computeInstancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('diskType', async () => { - const fakePath = "/rendered/path/diskType"; - const expectedParameters = { - project: "projectValue", - zone: "zoneValue", - disk_type: "diskTypeValue", - }; - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.diskTypePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.diskTypePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('diskTypePath', () => { - const result = client.diskTypePath("projectValue", "zoneValue", "diskTypeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.diskTypePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromDiskTypeName', () => { - const result = client.matchProjectFromDiskTypeName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.diskTypePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchZoneFromDiskTypeName', () => { - const result = client.matchZoneFromDiskTypeName(fakePath); - assert.strictEqual(result, "zoneValue"); - assert((client.pathTemplates.diskTypePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDiskTypeFromDiskTypeName', () => { - const result = client.matchDiskTypeFromDiskTypeName(fakePath); - assert.strictEqual(result, "diskTypeValue"); - assert((client.pathTemplates.diskTypePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('image', async () => { - const fakePath = "/rendered/path/image"; - const expectedParameters = { - project: "projectValue", - image: "imageValue", - }; - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.imagePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.imagePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('imagePath', () => { - const result = client.imagePath("projectValue", "imageValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.imagePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromImageName', () => { - const result = client.matchProjectFromImageName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.imagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchImageFromImageName', () => { - const result = client.matchImageFromImageName(fakePath); - assert.strictEqual(result, "imageValue"); - assert((client.pathTemplates.imagePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('instance', async () => { - const fakePath = "/rendered/path/instance"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - instance: "instanceValue", - }; - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.instancePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.instancePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('instancePath', () => { - const result = client.instancePath("projectValue", "locationValue", "instanceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.instancePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromInstanceName', () => { - const result = client.matchProjectFromInstanceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromInstanceName', () => { - const result = client.matchLocationFromInstanceName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInstanceFromInstanceName', () => { - const result = client.matchInstanceFromInstanceName(fakePath); - assert.strictEqual(result, "instanceValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('location', async () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - 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('machineLearningRun', async () => { - const fakePath = "/rendered/path/machineLearningRun"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - machine_learning_run: "machineLearningRunValue", - }; - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.machineLearningRunPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.machineLearningRunPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('machineLearningRunPath', () => { - const result = client.machineLearningRunPath("projectValue", "locationValue", "machineLearningRunValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.machineLearningRunPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromMachineLearningRunName', () => { - const result = client.matchProjectFromMachineLearningRunName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.machineLearningRunPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromMachineLearningRunName', () => { - const result = client.matchLocationFromMachineLearningRunName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.machineLearningRunPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchMachineLearningRunFromMachineLearningRunName', () => { - const result = client.matchMachineLearningRunFromMachineLearningRunName(fakePath); - assert.strictEqual(result, "machineLearningRunValue"); - assert((client.pathTemplates.machineLearningRunPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('monitoredEvent', async () => { - const fakePath = "/rendered/path/monitoredEvent"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - machine_learning_run: "machineLearningRunValue", - monitored_event: "monitoredEventValue", - }; - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.monitoredEventPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.monitoredEventPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('monitoredEventPath', () => { - const result = client.monitoredEventPath("projectValue", "locationValue", "machineLearningRunValue", "monitoredEventValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.monitoredEventPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromMonitoredEventName', () => { - const result = client.matchProjectFromMonitoredEventName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.monitoredEventPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromMonitoredEventName', () => { - const result = client.matchLocationFromMonitoredEventName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.monitoredEventPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchMachineLearningRunFromMonitoredEventName', () => { - const result = client.matchMachineLearningRunFromMonitoredEventName(fakePath); - assert.strictEqual(result, "machineLearningRunValue"); - assert((client.pathTemplates.monitoredEventPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchMonitoredEventFromMonitoredEventName', () => { - const result = client.matchMonitoredEventFromMonitoredEventName(fakePath); - assert.strictEqual(result, "monitoredEventValue"); - assert((client.pathTemplates.monitoredEventPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('invokes getCluster with error', async () => { + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.GetClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.GetClusterRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getCluster = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getCluster(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('network', async () => { - const fakePath = "/rendered/path/network"; - const expectedParameters = { - project: "projectValue", - network: "networkValue", - }; - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.networkPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.networkPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('networkPath', () => { - const result = client.networkPath("projectValue", "networkValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.networkPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes getCluster with closed client', async () => { + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.GetClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.GetClusterRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getCluster(request), expectedError); + }); + }); + + describe('getNode', () => { + it('invokes getNode without error', async () => { + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.GetNodeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.GetNodeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.Node(), + ); + client.innerApiCalls.getNode = stubSimpleCall(expectedResponse); + const [response] = await client.getNode(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getNode as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getNode as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchProjectFromNetworkName', () => { - const result = client.matchProjectFromNetworkName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.networkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes getNode without error using callback', async () => { + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.GetNodeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.GetNodeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.Node(), + ); + client.innerApiCalls.getNode = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getNode( + request, + ( + err?: Error | null, + result?: protos.google.cloud.hypercomputecluster.v1alpha.INode | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getNode as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getNode as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchNetworkFromNetworkName', () => { - const result = client.matchNetworkFromNetworkName(fakePath); - assert.strictEqual(result, "networkValue"); - assert((client.pathTemplates.networkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('invokes getNode with error', async () => { + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.GetNodeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.GetNodeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getNode = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getNode(request), expectedError); + const actualRequest = (client.innerApiCalls.getNode as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getNode as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('node', async () => { - const fakePath = "/rendered/path/node"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - cluster: "clusterValue", - node: "nodeValue", - }; - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.nodePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.nodePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('nodePath', () => { - const result = client.nodePath("projectValue", "locationValue", "clusterValue", "nodeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.nodePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes getNode with closed client', async () => { + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.GetNodeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.GetNodeRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getNode(request), expectedError); + }); + }); + + describe('createCluster', () => { + it('invokes createCluster without error', async () => { + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.CreateClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.CreateClusterRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createCluster = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createCluster(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchProjectFromNodeName', () => { - const result = client.matchProjectFromNodeName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.nodePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes createCluster without error using callback', async () => { + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.CreateClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.CreateClusterRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createCluster = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createCluster( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.ICluster, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.ICluster, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchLocationFromNodeName', () => { - const result = client.matchLocationFromNodeName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.nodePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes createCluster with call error', async () => { + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.CreateClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.CreateClusterRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createCluster = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createCluster(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchClusterFromNodeName', () => { - const result = client.matchClusterFromNodeName(fakePath); - assert.strictEqual(result, "clusterValue"); - assert((client.pathTemplates.nodePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes createCluster with LRO error', async () => { + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.CreateClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.CreateClusterRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createCluster = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createCluster(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchNodeFromNodeName', () => { - const result = client.matchNodeFromNodeName(fakePath); - assert.strictEqual(result, "nodeValue"); - assert((client.pathTemplates.nodePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('invokes checkCreateClusterProgress without error', async () => { + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateClusterProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - describe('pod', async () => { - const fakePath = "/rendered/path/pod"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - cluster: "clusterValue", - namespace: "namespaceValue", - pod: "podValue", - }; - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.podPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.podPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('podPath', () => { - const result = client.podPath("projectValue", "locationValue", "clusterValue", "namespaceValue", "podValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.podPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes checkCreateClusterProgress with error', async () => { + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateClusterProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateCluster', () => { + it('invokes updateCluster without error', async () => { + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.UpdateClusterRequest(), + ); + request.cluster ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.UpdateClusterRequest', + ['cluster', 'name'], + ); + request.cluster.name = defaultValue1; + const expectedHeaderRequestParams = `cluster.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateCluster = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateCluster(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchProjectFromPodName', () => { - const result = client.matchProjectFromPodName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.podPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes updateCluster without error using callback', async () => { + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.UpdateClusterRequest(), + ); + request.cluster ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.UpdateClusterRequest', + ['cluster', 'name'], + ); + request.cluster.name = defaultValue1; + const expectedHeaderRequestParams = `cluster.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateCluster = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateCluster( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.ICluster, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.ICluster, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchLocationFromPodName', () => { - const result = client.matchLocationFromPodName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.podPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes updateCluster with call error', async () => { + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.UpdateClusterRequest(), + ); + request.cluster ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.UpdateClusterRequest', + ['cluster', 'name'], + ); + request.cluster.name = defaultValue1; + const expectedHeaderRequestParams = `cluster.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateCluster = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateCluster(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchClusterFromPodName', () => { - const result = client.matchClusterFromPodName(fakePath); - assert.strictEqual(result, "clusterValue"); - assert((client.pathTemplates.podPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes updateCluster with LRO error', async () => { + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.UpdateClusterRequest(), + ); + request.cluster ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.UpdateClusterRequest', + ['cluster', 'name'], + ); + request.cluster.name = defaultValue1; + const expectedHeaderRequestParams = `cluster.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateCluster = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateCluster(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchNamespaceFromPodName', () => { - const result = client.matchNamespaceFromPodName(fakePath); - assert.strictEqual(result, "namespaceValue"); - assert((client.pathTemplates.podPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes checkUpdateClusterProgress without error', async () => { + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdateClusterProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('matchPodFromPodName', () => { - const result = client.matchPodFromPodName(fakePath); - assert.strictEqual(result, "podValue"); - assert((client.pathTemplates.podPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('invokes checkUpdateClusterProgress with error', async () => { + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateClusterProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteCluster', () => { + it('invokes deleteCluster without error', async () => { + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.DeleteClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.DeleteClusterRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteCluster = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteCluster(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('profileSession', async () => { - const fakePath = "/rendered/path/profileSession"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - machine_learning_run: "machineLearningRunValue", - profile_session: "profileSessionValue", - }; - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.profileSessionPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.profileSessionPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('profileSessionPath', () => { - const result = client.profileSessionPath("projectValue", "locationValue", "machineLearningRunValue", "profileSessionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.profileSessionPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes deleteCluster without error using callback', async () => { + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.DeleteClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.DeleteClusterRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteCluster = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteCluster( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchProjectFromProfileSessionName', () => { - const result = client.matchProjectFromProfileSessionName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.profileSessionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes deleteCluster with call error', async () => { + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.DeleteClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.DeleteClusterRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteCluster = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteCluster(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchLocationFromProfileSessionName', () => { - const result = client.matchLocationFromProfileSessionName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.profileSessionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes deleteCluster with LRO error', async () => { + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.DeleteClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.DeleteClusterRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteCluster = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteCluster(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchMachineLearningRunFromProfileSessionName', () => { - const result = client.matchMachineLearningRunFromProfileSessionName(fakePath); - assert.strictEqual(result, "machineLearningRunValue"); - assert((client.pathTemplates.profileSessionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes checkDeleteClusterProgress without error', async () => { + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteClusterProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('matchProfileSessionFromProfileSessionName', () => { - const result = client.matchProfileSessionFromProfileSessionName(fakePath); - assert.strictEqual(result, "profileSessionValue"); - assert((client.pathTemplates.profileSessionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('invokes checkDeleteClusterProgress with error', async () => { + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteClusterProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listClusters', () => { + it('invokes listClusters without error', async () => { + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ListClustersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.ListClustersRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.Cluster(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.Cluster(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.Cluster(), + ), + ]; + client.innerApiCalls.listClusters = stubSimpleCall(expectedResponse); + const [response] = await client.listClusters(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listClusters as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listClusters as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('profilerSession', async () => { - const fakePath = "/rendered/path/profilerSession"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - machine_learning_run: "machineLearningRunValue", - profiler_session: "profilerSessionValue", - }; - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.profilerSessionPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.profilerSessionPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('profilerSessionPath', () => { - const result = client.profilerSessionPath("projectValue", "locationValue", "machineLearningRunValue", "profilerSessionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.profilerSessionPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes listClusters without error using callback', async () => { + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ListClustersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.ListClustersRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.Cluster(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.Cluster(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.Cluster(), + ), + ]; + client.innerApiCalls.listClusters = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listClusters( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.hypercomputecluster.v1alpha.ICluster[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listClusters as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listClusters as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchProjectFromProfilerSessionName', () => { - const result = client.matchProjectFromProfilerSessionName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.profilerSessionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes listClusters with error', async () => { + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ListClustersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.ListClustersRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listClusters = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listClusters(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listClusters as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listClusters as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchLocationFromProfilerSessionName', () => { - const result = client.matchLocationFromProfilerSessionName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.profilerSessionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes listClustersStream without error', async () => { + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ListClustersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.ListClustersRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.Cluster(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.Cluster(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.Cluster(), + ), + ]; + client.descriptors.page.listClusters.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listClustersStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.hypercomputecluster.v1alpha.Cluster[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.hypercomputecluster.v1alpha.Cluster, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listClusters.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listClusters, request), + ); + assert( + (client.descriptors.page.listClusters.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('matchMachineLearningRunFromProfilerSessionName', () => { - const result = client.matchMachineLearningRunFromProfilerSessionName(fakePath); - assert.strictEqual(result, "machineLearningRunValue"); - assert((client.pathTemplates.profilerSessionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes listClustersStream with error', async () => { + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ListClustersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.ListClustersRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listClusters.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listClustersStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.hypercomputecluster.v1alpha.Cluster[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.hypercomputecluster.v1alpha.Cluster, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listClusters.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listClusters, request), + ); + assert( + (client.descriptors.page.listClusters.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('matchProfilerSessionFromProfilerSessionName', () => { - const result = client.matchProfilerSessionFromProfilerSessionName(fakePath); - assert.strictEqual(result, "profilerSessionValue"); - assert((client.pathTemplates.profilerSessionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('uses async iteration with listClusters without error', async () => { + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ListClustersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.ListClustersRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.Cluster(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.Cluster(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.Cluster(), + ), + ]; + client.descriptors.page.listClusters.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.hypercomputecluster.v1alpha.ICluster[] = + []; + const iterable = client.listClustersAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listClusters.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listClusters.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - describe('profilerTarget', async () => { - const fakePath = "/rendered/path/profilerTarget"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - machine_learning_run: "machineLearningRunValue", - profiler_target: "profilerTargetValue", - }; - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.profilerTargetPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.profilerTargetPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('profilerTargetPath', () => { - const result = client.profilerTargetPath("projectValue", "locationValue", "machineLearningRunValue", "profilerTargetValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.profilerTargetPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('uses async iteration with listClusters with error', async () => { + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ListClustersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.ListClustersRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listClusters.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listClustersAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.hypercomputecluster.v1alpha.ICluster[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listClusters.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listClusters.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listNodes', () => { + it('invokes listNodes without error', async () => { + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ListNodesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.ListNodesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.Node(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.Node(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.Node(), + ), + ]; + client.innerApiCalls.listNodes = stubSimpleCall(expectedResponse); + const [response] = await client.listNodes(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listNodes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listNodes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchProjectFromProfilerTargetName', () => { - const result = client.matchProjectFromProfilerTargetName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.profilerTargetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes listNodes without error using callback', async () => { + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ListNodesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.ListNodesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.Node(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.Node(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.Node(), + ), + ]; + client.innerApiCalls.listNodes = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listNodes( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.hypercomputecluster.v1alpha.INode[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listNodes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listNodes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchLocationFromProfilerTargetName', () => { - const result = client.matchLocationFromProfilerTargetName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.profilerTargetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes listNodes with error', async () => { + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ListNodesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.ListNodesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listNodes = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listNodes(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listNodes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listNodes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchMachineLearningRunFromProfilerTargetName', () => { - const result = client.matchMachineLearningRunFromProfilerTargetName(fakePath); - assert.strictEqual(result, "machineLearningRunValue"); - assert((client.pathTemplates.profilerTargetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes listNodesStream without error', async () => { + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ListNodesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.ListNodesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.Node(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.Node(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.Node(), + ), + ]; + client.descriptors.page.listNodes.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listNodesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.hypercomputecluster.v1alpha.Node[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.hypercomputecluster.v1alpha.Node) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listNodes.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listNodes, request), + ); + assert( + (client.descriptors.page.listNodes.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('matchProfilerTargetFromProfilerTargetName', () => { - const result = client.matchProfilerTargetFromProfilerTargetName(fakePath); - assert.strictEqual(result, "profilerTargetValue"); - assert((client.pathTemplates.profilerTargetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('invokes listNodesStream with error', async () => { + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ListNodesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.ListNodesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listNodes.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listNodesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.hypercomputecluster.v1alpha.Node[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.hypercomputecluster.v1alpha.Node) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listNodes.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listNodes, request), + ); + assert( + (client.descriptors.page.listNodes.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - describe('project', async () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - 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('uses async iteration with listNodes without error', async () => { + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ListNodesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.ListNodesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.Node(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.Node(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.Node(), + ), + ]; + client.descriptors.page.listNodes.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.hypercomputecluster.v1alpha.INode[] = + []; + const iterable = client.listNodesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listNodes.asyncIterate as SinonStub).getCall(0) + .args[1], + request, + ); + assert( + (client.descriptors.page.listNodes.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].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('uses async iteration with listNodes with error', async () => { + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ListNodesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.ListNodesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listNodes.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError, + ); + const iterable = client.listNodesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.hypercomputecluster.v1alpha.INode[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listNodes.asyncIterate as SinonStub).getCall(0) + .args[1], + request, + ); + assert( + (client.descriptors.page.listNodes.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 hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + 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 hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + 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 hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + 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 hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + 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 hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + 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 hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + 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 hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + 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 hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + 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 hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + 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 hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + 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 hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + 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 hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + 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 hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + 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 hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + 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 hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + 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 hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + 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('bucket', async () => { + const fakePath = '/rendered/path/bucket'; + const expectedParameters = { + project: 'projectValue', + bucket: 'bucketValue', + }; + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.bucketPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.bucketPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('bucketPath', () => { + const result = client.bucketPath('projectValue', 'bucketValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.bucketPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromBucketName', () => { + const result = client.matchProjectFromBucketName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.bucketPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchBucketFromBucketName', () => { + const result = client.matchBucketFromBucketName(fakePath); + assert.strictEqual(result, 'bucketValue'); + assert( + (client.pathTemplates.bucketPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('reservation', async () => { - const fakePath = "/rendered/path/reservation"; - const expectedParameters = { - project: "projectValue", - zone: "zoneValue", - reservation: "reservationValue", - }; - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.reservationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.reservationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('reservationPath', () => { - const result = client.reservationPath("projectValue", "zoneValue", "reservationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.reservationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + describe('cluster', async () => { + const fakePath = '/rendered/path/cluster'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + cluster: 'clusterValue', + }; + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.clusterPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.clusterPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('clusterPath', () => { + const result = client.clusterPath( + 'projectValue', + 'locationValue', + 'clusterValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.clusterPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromClusterName', () => { + const result = client.matchProjectFromClusterName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.clusterPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromClusterName', () => { + const result = client.matchLocationFromClusterName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.clusterPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchClusterFromClusterName', () => { + const result = client.matchClusterFromClusterName(fakePath); + assert.strictEqual(result, 'clusterValue'); + assert( + (client.pathTemplates.clusterPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchProjectFromReservationName', () => { - const result = client.matchProjectFromReservationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.reservationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('computeInstance', async () => { + const fakePath = '/rendered/path/computeInstance'; + const expectedParameters = { + project: 'projectValue', + zone: 'zoneValue', + instance: 'instanceValue', + }; + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.computeInstancePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.computeInstancePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('computeInstancePath', () => { + const result = client.computeInstancePath( + 'projectValue', + 'zoneValue', + 'instanceValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.computeInstancePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromComputeInstanceName', () => { + const result = client.matchProjectFromComputeInstanceName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.computeInstancePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchZoneFromComputeInstanceName', () => { + const result = client.matchZoneFromComputeInstanceName(fakePath); + assert.strictEqual(result, 'zoneValue'); + assert( + (client.pathTemplates.computeInstancePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchInstanceFromComputeInstanceName', () => { + const result = client.matchInstanceFromComputeInstanceName(fakePath); + assert.strictEqual(result, 'instanceValue'); + assert( + (client.pathTemplates.computeInstancePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchZoneFromReservationName', () => { - const result = client.matchZoneFromReservationName(fakePath); - assert.strictEqual(result, "zoneValue"); - assert((client.pathTemplates.reservationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('diskType', async () => { + const fakePath = '/rendered/path/diskType'; + const expectedParameters = { + project: 'projectValue', + zone: 'zoneValue', + disk_type: 'diskTypeValue', + }; + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.diskTypePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.diskTypePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('diskTypePath', () => { + const result = client.diskTypePath( + 'projectValue', + 'zoneValue', + 'diskTypeValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.diskTypePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromDiskTypeName', () => { + const result = client.matchProjectFromDiskTypeName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.diskTypePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchZoneFromDiskTypeName', () => { + const result = client.matchZoneFromDiskTypeName(fakePath); + assert.strictEqual(result, 'zoneValue'); + assert( + (client.pathTemplates.diskTypePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchDiskTypeFromDiskTypeName', () => { + const result = client.matchDiskTypeFromDiskTypeName(fakePath); + assert.strictEqual(result, 'diskTypeValue'); + assert( + (client.pathTemplates.diskTypePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchReservationFromReservationName', () => { - const result = client.matchReservationFromReservationName(fakePath); - assert.strictEqual(result, "reservationValue"); - assert((client.pathTemplates.reservationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('image', async () => { + const fakePath = '/rendered/path/image'; + const expectedParameters = { + project: 'projectValue', + image: 'imageValue', + }; + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.imagePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.imagePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('imagePath', () => { + const result = client.imagePath('projectValue', 'imageValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.imagePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromImageName', () => { + const result = client.matchProjectFromImageName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.imagePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchImageFromImageName', () => { + const result = client.matchImageFromImageName(fakePath); + assert.strictEqual(result, 'imageValue'); + assert( + (client.pathTemplates.imagePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('reservationBlock', async () => { - const fakePath = "/rendered/path/reservationBlock"; - const expectedParameters = { - project: "projectValue", - zone: "zoneValue", - reservation: "reservationValue", - reservation_block: "reservationBlockValue", - }; - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.reservationBlockPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.reservationBlockPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('reservationBlockPath', () => { - const result = client.reservationBlockPath("projectValue", "zoneValue", "reservationValue", "reservationBlockValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.reservationBlockPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + describe('instance', async () => { + const fakePath = '/rendered/path/instance'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + instance: 'instanceValue', + }; + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.instancePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.instancePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('instancePath', () => { + const result = client.instancePath( + 'projectValue', + 'locationValue', + 'instanceValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.instancePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromInstanceName', () => { + const result = client.matchProjectFromInstanceName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromInstanceName', () => { + const result = client.matchLocationFromInstanceName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchInstanceFromInstanceName', () => { + const result = client.matchInstanceFromInstanceName(fakePath); + assert.strictEqual(result, 'instanceValue'); + assert( + (client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchProjectFromReservationBlockName', () => { - const result = client.matchProjectFromReservationBlockName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.reservationBlockPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('location', async () => { + const fakePath = '/rendered/path/location'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + 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('matchZoneFromReservationBlockName', () => { - const result = client.matchZoneFromReservationBlockName(fakePath); - assert.strictEqual(result, "zoneValue"); - assert((client.pathTemplates.reservationBlockPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('machineLearningRun', async () => { + const fakePath = '/rendered/path/machineLearningRun'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + machine_learning_run: 'machineLearningRunValue', + }; + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.machineLearningRunPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.machineLearningRunPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('machineLearningRunPath', () => { + const result = client.machineLearningRunPath( + 'projectValue', + 'locationValue', + 'machineLearningRunValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.machineLearningRunPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromMachineLearningRunName', () => { + const result = client.matchProjectFromMachineLearningRunName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.machineLearningRunPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromMachineLearningRunName', () => { + const result = client.matchLocationFromMachineLearningRunName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.machineLearningRunPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchMachineLearningRunFromMachineLearningRunName', () => { + const result = + client.matchMachineLearningRunFromMachineLearningRunName(fakePath); + assert.strictEqual(result, 'machineLearningRunValue'); + assert( + ( + client.pathTemplates.machineLearningRunPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchReservationFromReservationBlockName', () => { - const result = client.matchReservationFromReservationBlockName(fakePath); - assert.strictEqual(result, "reservationValue"); - assert((client.pathTemplates.reservationBlockPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('monitoredEvent', async () => { + const fakePath = '/rendered/path/monitoredEvent'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + machine_learning_run: 'machineLearningRunValue', + monitored_event: 'monitoredEventValue', + }; + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.monitoredEventPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.monitoredEventPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('monitoredEventPath', () => { + const result = client.monitoredEventPath( + 'projectValue', + 'locationValue', + 'machineLearningRunValue', + 'monitoredEventValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.monitoredEventPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromMonitoredEventName', () => { + const result = client.matchProjectFromMonitoredEventName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.monitoredEventPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromMonitoredEventName', () => { + const result = client.matchLocationFromMonitoredEventName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.monitoredEventPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchMachineLearningRunFromMonitoredEventName', () => { + const result = + client.matchMachineLearningRunFromMonitoredEventName(fakePath); + assert.strictEqual(result, 'machineLearningRunValue'); + assert( + (client.pathTemplates.monitoredEventPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchMonitoredEventFromMonitoredEventName', () => { + const result = + client.matchMonitoredEventFromMonitoredEventName(fakePath); + assert.strictEqual(result, 'monitoredEventValue'); + assert( + (client.pathTemplates.monitoredEventPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchReservationBlockFromReservationBlockName', () => { - const result = client.matchReservationBlockFromReservationBlockName(fakePath); - assert.strictEqual(result, "reservationBlockValue"); - assert((client.pathTemplates.reservationBlockPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('network', async () => { + const fakePath = '/rendered/path/network'; + const expectedParameters = { + project: 'projectValue', + network: 'networkValue', + }; + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + 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('reservationSubBlock', async () => { - const fakePath = "/rendered/path/reservationSubBlock"; - const expectedParameters = { - project: "projectValue", - zone: "zoneValue", - reservation: "reservationValue", - reservation_block: "reservationBlockValue", - reservation_sub_block: "reservationSubBlockValue", - }; - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.reservationSubBlockPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.reservationSubBlockPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('reservationSubBlockPath', () => { - const result = client.reservationSubBlockPath("projectValue", "zoneValue", "reservationValue", "reservationBlockValue", "reservationSubBlockValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.reservationSubBlockPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + describe('node', async () => { + const fakePath = '/rendered/path/node'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + cluster: 'clusterValue', + node: 'nodeValue', + }; + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.nodePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.nodePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('nodePath', () => { + const result = client.nodePath( + 'projectValue', + 'locationValue', + 'clusterValue', + 'nodeValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.nodePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromNodeName', () => { + const result = client.matchProjectFromNodeName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.nodePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromNodeName', () => { + const result = client.matchLocationFromNodeName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.nodePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchClusterFromNodeName', () => { + const result = client.matchClusterFromNodeName(fakePath); + assert.strictEqual(result, 'clusterValue'); + assert( + (client.pathTemplates.nodePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchNodeFromNodeName', () => { + const result = client.matchNodeFromNodeName(fakePath); + assert.strictEqual(result, 'nodeValue'); + assert( + (client.pathTemplates.nodePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchProjectFromReservationSubBlockName', () => { - const result = client.matchProjectFromReservationSubBlockName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.reservationSubBlockPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('pod', async () => { + const fakePath = '/rendered/path/pod'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + cluster: 'clusterValue', + namespace: 'namespaceValue', + pod: 'podValue', + }; + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.podPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.podPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('podPath', () => { + const result = client.podPath( + 'projectValue', + 'locationValue', + 'clusterValue', + 'namespaceValue', + 'podValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.podPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromPodName', () => { + const result = client.matchProjectFromPodName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.podPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromPodName', () => { + const result = client.matchLocationFromPodName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.podPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchClusterFromPodName', () => { + const result = client.matchClusterFromPodName(fakePath); + assert.strictEqual(result, 'clusterValue'); + assert( + (client.pathTemplates.podPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchNamespaceFromPodName', () => { + const result = client.matchNamespaceFromPodName(fakePath); + assert.strictEqual(result, 'namespaceValue'); + assert( + (client.pathTemplates.podPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchPodFromPodName', () => { + const result = client.matchPodFromPodName(fakePath); + assert.strictEqual(result, 'podValue'); + assert( + (client.pathTemplates.podPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchZoneFromReservationSubBlockName', () => { - const result = client.matchZoneFromReservationSubBlockName(fakePath); - assert.strictEqual(result, "zoneValue"); - assert((client.pathTemplates.reservationSubBlockPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('profileSession', async () => { + const fakePath = '/rendered/path/profileSession'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + machine_learning_run: 'machineLearningRunValue', + profile_session: 'profileSessionValue', + }; + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.profileSessionPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.profileSessionPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('profileSessionPath', () => { + const result = client.profileSessionPath( + 'projectValue', + 'locationValue', + 'machineLearningRunValue', + 'profileSessionValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.profileSessionPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProfileSessionName', () => { + const result = client.matchProjectFromProfileSessionName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.profileSessionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromProfileSessionName', () => { + const result = client.matchLocationFromProfileSessionName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.profileSessionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchMachineLearningRunFromProfileSessionName', () => { + const result = + client.matchMachineLearningRunFromProfileSessionName(fakePath); + assert.strictEqual(result, 'machineLearningRunValue'); + assert( + (client.pathTemplates.profileSessionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchProfileSessionFromProfileSessionName', () => { + const result = + client.matchProfileSessionFromProfileSessionName(fakePath); + assert.strictEqual(result, 'profileSessionValue'); + assert( + (client.pathTemplates.profileSessionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchReservationFromReservationSubBlockName', () => { - const result = client.matchReservationFromReservationSubBlockName(fakePath); - assert.strictEqual(result, "reservationValue"); - assert((client.pathTemplates.reservationSubBlockPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('profilerSession', async () => { + const fakePath = '/rendered/path/profilerSession'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + machine_learning_run: 'machineLearningRunValue', + profiler_session: 'profilerSessionValue', + }; + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.profilerSessionPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.profilerSessionPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('profilerSessionPath', () => { + const result = client.profilerSessionPath( + 'projectValue', + 'locationValue', + 'machineLearningRunValue', + 'profilerSessionValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.profilerSessionPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProfilerSessionName', () => { + const result = client.matchProjectFromProfilerSessionName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.profilerSessionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromProfilerSessionName', () => { + const result = client.matchLocationFromProfilerSessionName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.profilerSessionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchMachineLearningRunFromProfilerSessionName', () => { + const result = + client.matchMachineLearningRunFromProfilerSessionName(fakePath); + assert.strictEqual(result, 'machineLearningRunValue'); + assert( + (client.pathTemplates.profilerSessionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchProfilerSessionFromProfilerSessionName', () => { + const result = + client.matchProfilerSessionFromProfilerSessionName(fakePath); + assert.strictEqual(result, 'profilerSessionValue'); + assert( + (client.pathTemplates.profilerSessionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchReservationBlockFromReservationSubBlockName', () => { - const result = client.matchReservationBlockFromReservationSubBlockName(fakePath); - assert.strictEqual(result, "reservationBlockValue"); - assert((client.pathTemplates.reservationSubBlockPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('profilerTarget', async () => { + const fakePath = '/rendered/path/profilerTarget'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + machine_learning_run: 'machineLearningRunValue', + profiler_target: 'profilerTargetValue', + }; + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.profilerTargetPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.profilerTargetPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('profilerTargetPath', () => { + const result = client.profilerTargetPath( + 'projectValue', + 'locationValue', + 'machineLearningRunValue', + 'profilerTargetValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.profilerTargetPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProfilerTargetName', () => { + const result = client.matchProjectFromProfilerTargetName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.profilerTargetPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromProfilerTargetName', () => { + const result = client.matchLocationFromProfilerTargetName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.profilerTargetPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchMachineLearningRunFromProfilerTargetName', () => { + const result = + client.matchMachineLearningRunFromProfilerTargetName(fakePath); + assert.strictEqual(result, 'machineLearningRunValue'); + assert( + (client.pathTemplates.profilerTargetPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchProfilerTargetFromProfilerTargetName', () => { + const result = + client.matchProfilerTargetFromProfilerTargetName(fakePath); + assert.strictEqual(result, 'profilerTargetValue'); + assert( + (client.pathTemplates.profilerTargetPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchReservationSubBlockFromReservationSubBlockName', () => { - const result = client.matchReservationSubBlockFromReservationSubBlockName(fakePath); - assert.strictEqual(result, "reservationSubBlockValue"); - assert((client.pathTemplates.reservationSubBlockPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('project', async () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + 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('subnetwork', async () => { - const fakePath = "/rendered/path/subnetwork"; - const expectedParameters = { - project: "projectValue", - region: "regionValue", - subnetwork: "subnetworkValue", - }; - const client = new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.subnetworkPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.subnetworkPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('subnetworkPath', () => { - const result = client.subnetworkPath("projectValue", "regionValue", "subnetworkValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.subnetworkPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + describe('reservation', async () => { + const fakePath = '/rendered/path/reservation'; + const expectedParameters = { + project: 'projectValue', + zone: 'zoneValue', + reservation: 'reservationValue', + }; + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.reservationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.reservationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('reservationPath', () => { + const result = client.reservationPath( + 'projectValue', + 'zoneValue', + 'reservationValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.reservationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromReservationName', () => { + const result = client.matchProjectFromReservationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.reservationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchZoneFromReservationName', () => { + const result = client.matchZoneFromReservationName(fakePath); + assert.strictEqual(result, 'zoneValue'); + assert( + (client.pathTemplates.reservationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchReservationFromReservationName', () => { + const result = client.matchReservationFromReservationName(fakePath); + assert.strictEqual(result, 'reservationValue'); + assert( + (client.pathTemplates.reservationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchProjectFromSubnetworkName', () => { - const result = client.matchProjectFromSubnetworkName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.subnetworkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('reservationBlock', async () => { + const fakePath = '/rendered/path/reservationBlock'; + const expectedParameters = { + project: 'projectValue', + zone: 'zoneValue', + reservation: 'reservationValue', + reservation_block: 'reservationBlockValue', + }; + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.reservationBlockPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.reservationBlockPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('reservationBlockPath', () => { + const result = client.reservationBlockPath( + 'projectValue', + 'zoneValue', + 'reservationValue', + 'reservationBlockValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.reservationBlockPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromReservationBlockName', () => { + const result = client.matchProjectFromReservationBlockName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.reservationBlockPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchZoneFromReservationBlockName', () => { + const result = client.matchZoneFromReservationBlockName(fakePath); + assert.strictEqual(result, 'zoneValue'); + assert( + (client.pathTemplates.reservationBlockPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchReservationFromReservationBlockName', () => { + const result = + client.matchReservationFromReservationBlockName(fakePath); + assert.strictEqual(result, 'reservationValue'); + assert( + (client.pathTemplates.reservationBlockPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchReservationBlockFromReservationBlockName', () => { + const result = + client.matchReservationBlockFromReservationBlockName(fakePath); + assert.strictEqual(result, 'reservationBlockValue'); + assert( + (client.pathTemplates.reservationBlockPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchRegionFromSubnetworkName', () => { - const result = client.matchRegionFromSubnetworkName(fakePath); - assert.strictEqual(result, "regionValue"); - assert((client.pathTemplates.subnetworkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('reservationSubBlock', async () => { + const fakePath = '/rendered/path/reservationSubBlock'; + const expectedParameters = { + project: 'projectValue', + zone: 'zoneValue', + reservation: 'reservationValue', + reservation_block: 'reservationBlockValue', + reservation_sub_block: 'reservationSubBlockValue', + }; + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.reservationSubBlockPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.reservationSubBlockPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('reservationSubBlockPath', () => { + const result = client.reservationSubBlockPath( + 'projectValue', + 'zoneValue', + 'reservationValue', + 'reservationBlockValue', + 'reservationSubBlockValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.reservationSubBlockPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromReservationSubBlockName', () => { + const result = client.matchProjectFromReservationSubBlockName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.reservationSubBlockPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchZoneFromReservationSubBlockName', () => { + const result = client.matchZoneFromReservationSubBlockName(fakePath); + assert.strictEqual(result, 'zoneValue'); + assert( + ( + client.pathTemplates.reservationSubBlockPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchReservationFromReservationSubBlockName', () => { + const result = + client.matchReservationFromReservationSubBlockName(fakePath); + assert.strictEqual(result, 'reservationValue'); + assert( + ( + client.pathTemplates.reservationSubBlockPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchReservationBlockFromReservationSubBlockName', () => { + const result = + client.matchReservationBlockFromReservationSubBlockName(fakePath); + assert.strictEqual(result, 'reservationBlockValue'); + assert( + ( + client.pathTemplates.reservationSubBlockPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchReservationSubBlockFromReservationSubBlockName', () => { + const result = + client.matchReservationSubBlockFromReservationSubBlockName(fakePath); + assert.strictEqual(result, 'reservationSubBlockValue'); + assert( + ( + client.pathTemplates.reservationSubBlockPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchSubnetworkFromSubnetworkName', () => { - const result = client.matchSubnetworkFromSubnetworkName(fakePath); - assert.strictEqual(result, "subnetworkValue"); - assert((client.pathTemplates.subnetworkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('subnetwork', async () => { + const fakePath = '/rendered/path/subnetwork'; + const expectedParameters = { + project: 'projectValue', + region: 'regionValue', + subnetwork: 'subnetworkValue', + }; + const client = + new hypercomputeclusterModule.v1alpha.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.subnetworkPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.subnetworkPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('subnetworkPath', () => { + const result = client.subnetworkPath( + 'projectValue', + 'regionValue', + 'subnetworkValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.subnetworkPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromSubnetworkName', () => { + const result = client.matchProjectFromSubnetworkName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.subnetworkPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRegionFromSubnetworkName', () => { + const result = client.matchRegionFromSubnetworkName(fakePath); + assert.strictEqual(result, 'regionValue'); + assert( + (client.pathTemplates.subnetworkPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchSubnetworkFromSubnetworkName', () => { + const result = client.matchSubnetworkFromSubnetworkName(fakePath); + assert.strictEqual(result, 'subnetworkValue'); + assert( + (client.pathTemplates.subnetworkPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-hypercomputecluster/test/gapic_hypercompute_cluster_v1beta.ts b/packages/google-cloud-hypercomputecluster/test/gapic_hypercompute_cluster_v1beta.ts index 5bc4f60b7bc0..534850f85dd0 100644 --- a/packages/google-cloud-hypercomputecluster/test/gapic_hypercompute_cluster_v1beta.ts +++ b/packages/google-cloud-hypercomputecluster/test/gapic_hypercompute_cluster_v1beta.ts @@ -19,1922 +19,2551 @@ 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 hypercomputeclusterModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf, LROperation, operationsProtos, LocationProtos} from 'google-gax'; +import { + protobuf, + LROperation, + operationsProtos, + LocationProtos, +} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); +const root = protobuf.Root.fromJSON( + require('../protos/protos.json'), +).resolveAll(); // eslint-disable-next-line @typescript-eslint/no-unused-vars function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; } function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, { defaults: true }); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject, + ) as T; } function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); } -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error, +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); } -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +function stubLongRunningCall( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().rejects(callError) + : sinon.stub().resolves([mockOperation]); } -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +function stubLongRunningCallWithCallback( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().callsArgWith(2, callError) + : sinon.stub().callsArgWith(2, null, mockOperation); } -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error, +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); } - return sinon.stub().returns(mockStream); + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); } -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error, +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({ done: true, value: undefined }); + } + return Promise.resolve({ done: false, value: responses![counter++] }); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); } describe('v1beta.HypercomputeClusterClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new hypercomputeclusterModule.v1beta.HypercomputeClusterClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'hypercomputecluster.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new hypercomputeclusterModule.v1beta.HypercomputeClusterClient(); - 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 = hypercomputeclusterModule.v1beta.HypercomputeClusterClient.servicePath; - assert.strictEqual(servicePath, 'hypercomputecluster.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = hypercomputeclusterModule.v1beta.HypercomputeClusterClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'hypercomputecluster.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'hypercomputecluster.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'hypercomputecluster.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 hypercomputeclusterModule.v1beta.HypercomputeClusterClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'hypercomputecluster.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 hypercomputeclusterModule.v1beta.HypercomputeClusterClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'hypercomputecluster.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 hypercomputeclusterModule.v1beta.HypercomputeClusterClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = + new hypercomputeclusterModule.v1beta.HypercomputeClusterClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'hypercomputecluster.googleapis.com'); + }); - it('has port', () => { - const port = hypercomputeclusterModule.v1beta.HypercomputeClusterClient.port; - assert(port); - assert(typeof port === 'number'); - }); + it('has universeDomain', () => { + const client = + new hypercomputeclusterModule.v1beta.HypercomputeClusterClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('should create a client with no option', () => { - const client = new hypercomputeclusterModule.v1beta.HypercomputeClusterClient(); - assert(client); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + hypercomputeclusterModule.v1beta.HypercomputeClusterClient + .servicePath; + assert.strictEqual(servicePath, 'hypercomputecluster.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + hypercomputeclusterModule.v1beta.HypercomputeClusterClient + .apiEndpoint; + assert.strictEqual(apiEndpoint, 'hypercomputecluster.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = + new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + universeDomain: 'example.com', }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'hypercomputecluster.example.com'); + }); - it('should create a client with gRPC fallback', () => { - const client = new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - fallback: true, - }); - assert(client); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = + new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + universe_domain: 'example.com', }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'hypercomputecluster.example.com'); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.hypercomputeClusterStub, undefined); - await client.initialize(); - assert(client.hypercomputeClusterStub); + 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 hypercomputeclusterModule.v1beta.HypercomputeClusterClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'hypercomputecluster.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 hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual( + servicePath, + 'hypercomputecluster.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 hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('has close method for the initialized client', done => { - const client = new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.hypercomputeClusterStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has port', () => { + const port = + hypercomputeclusterModule.v1beta.HypercomputeClusterClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has close method for the non-initialized client', done => { - const client = new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.hypercomputeClusterStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('should create a client with no option', () => { + const client = + new hypercomputeclusterModule.v1beta.HypercomputeClusterClient(); + assert(client); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - 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 hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + fallback: true, }); + assert(client); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - 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 hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + assert.strictEqual(client.hypercomputeClusterStub, undefined); + await client.initialize(); + assert(client.hypercomputeClusterStub); }); - describe('getCluster', () => { - it('invokes getCluster without error', async () => { - const client = new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1beta.GetClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1beta.GetClusterRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1beta.Cluster() - ); - client.innerApiCalls.getCluster = stubSimpleCall(expectedResponse); - const [response] = await client.getCluster(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getCluster without error using callback', async () => { - const client = new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1beta.GetClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1beta.GetClusterRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1beta.Cluster() - ); - client.innerApiCalls.getCluster = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getCluster( - request, - (err?: Error|null, result?: protos.google.cloud.hypercomputecluster.v1beta.ICluster|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getCluster with error', async () => { - const client = new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1beta.GetClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1beta.GetClusterRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getCluster = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getCluster(request), expectedError); - const actualRequest = (client.innerApiCalls.getCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getCluster with closed client', async () => { - const client = new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1beta.GetClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1beta.GetClusterRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getCluster(request), expectedError); - }); - }); - - describe('createCluster', () => { - it('invokes createCluster without error', async () => { - const client = new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1beta.CreateClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1beta.CreateClusterRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createCluster = stubLongRunningCall(expectedResponse); - const [operation] = await client.createCluster(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createCluster without error using callback', async () => { - const client = new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1beta.CreateClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1beta.CreateClusterRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createCluster = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createCluster( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createCluster with call error', async () => { - const client = new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1beta.CreateClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1beta.CreateClusterRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createCluster = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createCluster(request), expectedError); - const actualRequest = (client.innerApiCalls.createCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createCluster with LRO error', async () => { - const client = new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1beta.CreateClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1beta.CreateClusterRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createCluster = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createCluster(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateClusterProgress without error', async () => { - const client = new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateClusterProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateClusterProgress with error', async () => { - const client = new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateClusterProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); + it('has close method for the initialized client', (done) => { + const client = + new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.hypercomputeClusterStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('updateCluster', () => { - it('invokes updateCluster without error', async () => { - const client = new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1beta.UpdateClusterRequest() - ); - request.cluster ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1beta.UpdateClusterRequest', ['cluster', 'name']); - request.cluster.name = defaultValue1; - const expectedHeaderRequestParams = `cluster.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateCluster = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateCluster(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateCluster without error using callback', async () => { - const client = new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1beta.UpdateClusterRequest() - ); - request.cluster ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1beta.UpdateClusterRequest', ['cluster', 'name']); - request.cluster.name = defaultValue1; - const expectedHeaderRequestParams = `cluster.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateCluster = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateCluster( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateCluster with call error', async () => { - const client = new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1beta.UpdateClusterRequest() - ); - request.cluster ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1beta.UpdateClusterRequest', ['cluster', 'name']); - request.cluster.name = defaultValue1; - const expectedHeaderRequestParams = `cluster.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateCluster = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateCluster(request), expectedError); - const actualRequest = (client.innerApiCalls.updateCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateCluster with LRO error', async () => { - const client = new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1beta.UpdateClusterRequest() - ); - request.cluster ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1beta.UpdateClusterRequest', ['cluster', 'name']); - request.cluster.name = defaultValue1; - const expectedHeaderRequestParams = `cluster.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateCluster = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateCluster(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpdateClusterProgress without error', async () => { - const client = new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateClusterProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateClusterProgress with error', async () => { - const client = new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateClusterProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); + it('has close method for the non-initialized client', (done) => { + const client = + new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.hypercomputeClusterStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('deleteCluster', () => { - it('invokes deleteCluster without error', async () => { - const client = new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1beta.DeleteClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1beta.DeleteClusterRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteCluster = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteCluster(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteCluster without error using callback', async () => { - const client = new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1beta.DeleteClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1beta.DeleteClusterRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteCluster = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteCluster( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteCluster with call error', async () => { - const client = new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1beta.DeleteClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1beta.DeleteClusterRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteCluster = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteCluster(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteCluster with LRO error', async () => { - const client = new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1beta.DeleteClusterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1beta.DeleteClusterRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteCluster = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteCluster(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteCluster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteCluster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteClusterProgress without error', async () => { - const client = new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteClusterProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteClusterProgress with error', async () => { - const client = new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - 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 hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + 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.checkDeleteClusterProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + 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('getCluster', () => { + it('invokes getCluster without error', async () => { + const client = + new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1beta.GetClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1beta.GetClusterRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1beta.Cluster(), + ); + client.innerApiCalls.getCluster = stubSimpleCall(expectedResponse); + const [response] = await client.getCluster(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listClusters', () => { - it('invokes listClusters without error', async () => { - const client = new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1beta.ListClustersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1beta.ListClustersRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1beta.Cluster()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1beta.Cluster()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1beta.Cluster()), - ]; - client.innerApiCalls.listClusters = stubSimpleCall(expectedResponse); - const [response] = await client.listClusters(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listClusters as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listClusters as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listClusters without error using callback', async () => { - const client = new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1beta.ListClustersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1beta.ListClustersRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1beta.Cluster()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1beta.Cluster()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1beta.Cluster()), - ]; - client.innerApiCalls.listClusters = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listClusters( - request, - (err?: Error|null, result?: protos.google.cloud.hypercomputecluster.v1beta.ICluster[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listClusters as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listClusters as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listClusters with error', async () => { - const client = new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1beta.ListClustersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1beta.ListClustersRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listClusters = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listClusters(request), expectedError); - const actualRequest = (client.innerApiCalls.listClusters as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listClusters as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listClustersStream without error', async () => { - const client = new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1beta.ListClustersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1beta.ListClustersRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1beta.Cluster()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1beta.Cluster()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1beta.Cluster()), - ]; - client.descriptors.page.listClusters.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listClustersStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.hypercomputecluster.v1beta.Cluster[] = []; - stream.on('data', (response: protos.google.cloud.hypercomputecluster.v1beta.Cluster) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listClusters.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listClusters, request)); - assert( - (client.descriptors.page.listClusters.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listClustersStream with error', async () => { - const client = new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1beta.ListClustersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1beta.ListClustersRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listClusters.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listClustersStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.hypercomputecluster.v1beta.Cluster[] = []; - stream.on('data', (response: protos.google.cloud.hypercomputecluster.v1beta.Cluster) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listClusters.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listClusters, request)); - assert( - (client.descriptors.page.listClusters.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listClusters without error', async () => { - const client = new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1beta.ListClustersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1beta.ListClustersRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1beta.Cluster()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1beta.Cluster()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1beta.Cluster()), - ]; - client.descriptors.page.listClusters.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.hypercomputecluster.v1beta.ICluster[] = []; - const iterable = client.listClustersAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listClusters.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listClusters.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listClusters with error', async () => { - const client = new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1beta.ListClustersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1beta.ListClustersRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listClusters.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listClustersAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.hypercomputecluster.v1beta.ICluster[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listClusters.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listClusters.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 hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - 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 hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - 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 hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - 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 hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - 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 getCluster without error using callback', async () => { + const client = + new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1beta.GetClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1beta.GetClusterRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1beta.Cluster(), + ); + client.innerApiCalls.getCluster = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getCluster( + request, + ( + err?: Error | null, + result?: protos.google.cloud.hypercomputecluster.v1beta.ICluster | 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 hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - 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 hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - 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 hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - 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 hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - 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 hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - 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 hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - 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 hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - 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 hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - 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 hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - 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 hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - 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 hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - 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 hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - 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.getCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('Path templates', () => { - - describe('bucket', async () => { - const fakePath = "/rendered/path/bucket"; - const expectedParameters = { - project: "projectValue", - bucket: "bucketValue", - }; - const client = new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.bucketPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.bucketPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('bucketPath', () => { - const result = client.bucketPath("projectValue", "bucketValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.bucketPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromBucketName', () => { - const result = client.matchProjectFromBucketName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.bucketPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBucketFromBucketName', () => { - const result = client.matchBucketFromBucketName(fakePath); - assert.strictEqual(result, "bucketValue"); - assert((client.pathTemplates.bucketPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('cluster', async () => { - const fakePath = "/rendered/path/cluster"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - cluster: "clusterValue", - }; - const client = new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.clusterPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.clusterPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('clusterPath', () => { - const result = client.clusterPath("projectValue", "locationValue", "clusterValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.clusterPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes getCluster with error', async () => { + const client = + new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1beta.GetClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1beta.GetClusterRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getCluster = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getCluster(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchProjectFromClusterName', () => { - const result = client.matchProjectFromClusterName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.clusterPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes getCluster with closed client', async () => { + const client = + new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1beta.GetClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1beta.GetClusterRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getCluster(request), expectedError); + }); + }); + + describe('createCluster', () => { + it('invokes createCluster without error', async () => { + const client = + new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1beta.CreateClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1beta.CreateClusterRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createCluster = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createCluster(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchLocationFromClusterName', () => { - const result = client.matchLocationFromClusterName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.clusterPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes createCluster without error using callback', async () => { + const client = + new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1beta.CreateClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1beta.CreateClusterRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createCluster = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createCluster( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.hypercomputecluster.v1beta.ICluster, + protos.google.cloud.hypercomputecluster.v1beta.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.hypercomputecluster.v1beta.ICluster, + protos.google.cloud.hypercomputecluster.v1beta.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchClusterFromClusterName', () => { - const result = client.matchClusterFromClusterName(fakePath); - assert.strictEqual(result, "clusterValue"); - assert((client.pathTemplates.clusterPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('invokes createCluster with call error', async () => { + const client = + new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1beta.CreateClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1beta.CreateClusterRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createCluster = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createCluster(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('computeInstance', async () => { - const fakePath = "/rendered/path/computeInstance"; - const expectedParameters = { - project: "projectValue", - zone: "zoneValue", - instance: "instanceValue", - }; - const client = new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.computeInstancePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.computeInstancePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('computeInstancePath', () => { - const result = client.computeInstancePath("projectValue", "zoneValue", "instanceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.computeInstancePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes createCluster with LRO error', async () => { + const client = + new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1beta.CreateClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1beta.CreateClusterRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createCluster = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createCluster(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchProjectFromComputeInstanceName', () => { - const result = client.matchProjectFromComputeInstanceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.computeInstancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes checkCreateClusterProgress without error', async () => { + const client = + new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateClusterProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('matchZoneFromComputeInstanceName', () => { - const result = client.matchZoneFromComputeInstanceName(fakePath); - assert.strictEqual(result, "zoneValue"); - assert((client.pathTemplates.computeInstancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes checkCreateClusterProgress with error', async () => { + const client = + new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateClusterProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateCluster', () => { + it('invokes updateCluster without error', async () => { + const client = + new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1beta.UpdateClusterRequest(), + ); + request.cluster ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1beta.UpdateClusterRequest', + ['cluster', 'name'], + ); + request.cluster.name = defaultValue1; + const expectedHeaderRequestParams = `cluster.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateCluster = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateCluster(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchInstanceFromComputeInstanceName', () => { - const result = client.matchInstanceFromComputeInstanceName(fakePath); - assert.strictEqual(result, "instanceValue"); - assert((client.pathTemplates.computeInstancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('invokes updateCluster without error using callback', async () => { + const client = + new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1beta.UpdateClusterRequest(), + ); + request.cluster ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1beta.UpdateClusterRequest', + ['cluster', 'name'], + ); + request.cluster.name = defaultValue1; + const expectedHeaderRequestParams = `cluster.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateCluster = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateCluster( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.hypercomputecluster.v1beta.ICluster, + protos.google.cloud.hypercomputecluster.v1beta.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.hypercomputecluster.v1beta.ICluster, + protos.google.cloud.hypercomputecluster.v1beta.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('diskType', async () => { - const fakePath = "/rendered/path/diskType"; - const expectedParameters = { - project: "projectValue", - zone: "zoneValue", - disk_type: "diskTypeValue", - }; - const client = new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.diskTypePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.diskTypePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('diskTypePath', () => { - const result = client.diskTypePath("projectValue", "zoneValue", "diskTypeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.diskTypePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes updateCluster with call error', async () => { + const client = + new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1beta.UpdateClusterRequest(), + ); + request.cluster ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1beta.UpdateClusterRequest', + ['cluster', 'name'], + ); + request.cluster.name = defaultValue1; + const expectedHeaderRequestParams = `cluster.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateCluster = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateCluster(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchProjectFromDiskTypeName', () => { - const result = client.matchProjectFromDiskTypeName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.diskTypePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes updateCluster with LRO error', async () => { + const client = + new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1beta.UpdateClusterRequest(), + ); + request.cluster ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1beta.UpdateClusterRequest', + ['cluster', 'name'], + ); + request.cluster.name = defaultValue1; + const expectedHeaderRequestParams = `cluster.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateCluster = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateCluster(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchZoneFromDiskTypeName', () => { - const result = client.matchZoneFromDiskTypeName(fakePath); - assert.strictEqual(result, "zoneValue"); - assert((client.pathTemplates.diskTypePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes checkUpdateClusterProgress without error', async () => { + const client = + new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdateClusterProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('matchDiskTypeFromDiskTypeName', () => { - const result = client.matchDiskTypeFromDiskTypeName(fakePath); - assert.strictEqual(result, "diskTypeValue"); - assert((client.pathTemplates.diskTypePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('invokes checkUpdateClusterProgress with error', async () => { + const client = + new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateClusterProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteCluster', () => { + it('invokes deleteCluster without error', async () => { + const client = + new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1beta.DeleteClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1beta.DeleteClusterRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteCluster = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteCluster(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCluster 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 hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - 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 deleteCluster without error using callback', async () => { + const client = + new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1beta.DeleteClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1beta.DeleteClusterRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteCluster = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteCluster( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.hypercomputecluster.v1beta.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.hypercomputecluster.v1beta.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCluster 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 deleteCluster with call error', async () => { + const client = + new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1beta.DeleteClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1beta.DeleteClusterRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteCluster = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteCluster(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCluster 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 deleteCluster with LRO error', async () => { + const client = + new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1beta.DeleteClusterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1beta.DeleteClusterRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteCluster = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteCluster(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteCluster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCluster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('lustreInstance', async () => { - const fakePath = "/rendered/path/lustreInstance"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - instance: "instanceValue", - }; - const client = new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.lustreInstancePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.lustreInstancePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('lustreInstancePath', () => { - const result = client.lustreInstancePath("projectValue", "locationValue", "instanceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.lustreInstancePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes checkDeleteClusterProgress without error', async () => { + const client = + new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteClusterProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('matchProjectFromLustreInstanceName', () => { - const result = client.matchProjectFromLustreInstanceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.lustreInstancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes checkDeleteClusterProgress with error', async () => { + const client = + new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteClusterProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listClusters', () => { + it('invokes listClusters without error', async () => { + const client = + new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1beta.ListClustersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1beta.ListClustersRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1beta.Cluster(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1beta.Cluster(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1beta.Cluster(), + ), + ]; + client.innerApiCalls.listClusters = stubSimpleCall(expectedResponse); + const [response] = await client.listClusters(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listClusters as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listClusters as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchLocationFromLustreInstanceName', () => { - const result = client.matchLocationFromLustreInstanceName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.lustreInstancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes listClusters without error using callback', async () => { + const client = + new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1beta.ListClustersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1beta.ListClustersRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1beta.Cluster(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1beta.Cluster(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1beta.Cluster(), + ), + ]; + client.innerApiCalls.listClusters = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listClusters( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.hypercomputecluster.v1beta.ICluster[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listClusters as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listClusters as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchInstanceFromLustreInstanceName', () => { - const result = client.matchInstanceFromLustreInstanceName(fakePath); - assert.strictEqual(result, "instanceValue"); - assert((client.pathTemplates.lustreInstancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('invokes listClusters with error', async () => { + const client = + new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1beta.ListClustersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1beta.ListClustersRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listClusters = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listClusters(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listClusters as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listClusters as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('network', async () => { - const fakePath = "/rendered/path/network"; - const expectedParameters = { - project: "projectValue", - network: "networkValue", - }; - const client = new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.networkPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.networkPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('networkPath', () => { - const result = client.networkPath("projectValue", "networkValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.networkPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes listClustersStream without error', async () => { + const client = + new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1beta.ListClustersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1beta.ListClustersRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1beta.Cluster(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1beta.Cluster(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1beta.Cluster(), + ), + ]; + client.descriptors.page.listClusters.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listClustersStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.hypercomputecluster.v1beta.Cluster[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.hypercomputecluster.v1beta.Cluster, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listClusters.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listClusters, request), + ); + assert( + (client.descriptors.page.listClusters.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('matchProjectFromNetworkName', () => { - const result = client.matchProjectFromNetworkName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.networkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes listClustersStream with error', async () => { + const client = + new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1beta.ListClustersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1beta.ListClustersRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listClusters.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listClustersStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.hypercomputecluster.v1beta.Cluster[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.hypercomputecluster.v1beta.Cluster, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listClusters.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listClusters, request), + ); + assert( + (client.descriptors.page.listClusters.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('matchNetworkFromNetworkName', () => { - const result = client.matchNetworkFromNetworkName(fakePath); - assert.strictEqual(result, "networkValue"); - assert((client.pathTemplates.networkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('uses async iteration with listClusters without error', async () => { + const client = + new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1beta.ListClustersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1beta.ListClustersRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1beta.Cluster(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1beta.Cluster(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1beta.Cluster(), + ), + ]; + client.descriptors.page.listClusters.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.hypercomputecluster.v1beta.ICluster[] = + []; + const iterable = client.listClustersAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listClusters.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listClusters.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - describe('project', async () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - 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('uses async iteration with listClusters with error', async () => { + const client = + new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1beta.ListClustersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1beta.ListClustersRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listClusters.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listClustersAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.hypercomputecluster.v1beta.ICluster[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listClusters.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listClusters.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 hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + 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 hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + 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 hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + 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 hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + 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 hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + 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 hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + 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 hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + 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 hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + 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 hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + 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 hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + 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 hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + 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 hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + 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 hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + 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 hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + 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 hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + 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 hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + 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('bucket', async () => { + const fakePath = '/rendered/path/bucket'; + const expectedParameters = { + project: 'projectValue', + bucket: 'bucketValue', + }; + const client = + new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.bucketPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.bucketPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('bucketPath', () => { + const result = client.bucketPath('projectValue', 'bucketValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.bucketPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromBucketName', () => { + const result = client.matchProjectFromBucketName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.bucketPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchBucketFromBucketName', () => { + const result = client.matchBucketFromBucketName(fakePath); + assert.strictEqual(result, 'bucketValue'); + assert( + (client.pathTemplates.bucketPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('cluster', async () => { + const fakePath = '/rendered/path/cluster'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + cluster: 'clusterValue', + }; + const client = + new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.clusterPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.clusterPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('clusterPath', () => { + const result = client.clusterPath( + 'projectValue', + 'locationValue', + 'clusterValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.clusterPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromClusterName', () => { + const result = client.matchProjectFromClusterName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.clusterPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromClusterName', () => { + const result = client.matchLocationFromClusterName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.clusterPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchClusterFromClusterName', () => { + const result = client.matchClusterFromClusterName(fakePath); + assert.strictEqual(result, 'clusterValue'); + assert( + (client.pathTemplates.clusterPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('reservation', async () => { - const fakePath = "/rendered/path/reservation"; - const expectedParameters = { - project: "projectValue", - zone: "zoneValue", - reservation: "reservationValue", - }; - const client = new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.reservationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.reservationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('reservationPath', () => { - const result = client.reservationPath("projectValue", "zoneValue", "reservationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.reservationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + describe('computeInstance', async () => { + const fakePath = '/rendered/path/computeInstance'; + const expectedParameters = { + project: 'projectValue', + zone: 'zoneValue', + instance: 'instanceValue', + }; + const client = + new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.computeInstancePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.computeInstancePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('computeInstancePath', () => { + const result = client.computeInstancePath( + 'projectValue', + 'zoneValue', + 'instanceValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.computeInstancePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromComputeInstanceName', () => { + const result = client.matchProjectFromComputeInstanceName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.computeInstancePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchZoneFromComputeInstanceName', () => { + const result = client.matchZoneFromComputeInstanceName(fakePath); + assert.strictEqual(result, 'zoneValue'); + assert( + (client.pathTemplates.computeInstancePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchInstanceFromComputeInstanceName', () => { + const result = client.matchInstanceFromComputeInstanceName(fakePath); + assert.strictEqual(result, 'instanceValue'); + assert( + (client.pathTemplates.computeInstancePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchProjectFromReservationName', () => { - const result = client.matchProjectFromReservationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.reservationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('diskType', async () => { + const fakePath = '/rendered/path/diskType'; + const expectedParameters = { + project: 'projectValue', + zone: 'zoneValue', + disk_type: 'diskTypeValue', + }; + const client = + new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.diskTypePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.diskTypePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('diskTypePath', () => { + const result = client.diskTypePath( + 'projectValue', + 'zoneValue', + 'diskTypeValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.diskTypePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromDiskTypeName', () => { + const result = client.matchProjectFromDiskTypeName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.diskTypePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchZoneFromDiskTypeName', () => { + const result = client.matchZoneFromDiskTypeName(fakePath); + assert.strictEqual(result, 'zoneValue'); + assert( + (client.pathTemplates.diskTypePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchDiskTypeFromDiskTypeName', () => { + const result = client.matchDiskTypeFromDiskTypeName(fakePath); + assert.strictEqual(result, 'diskTypeValue'); + assert( + (client.pathTemplates.diskTypePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchZoneFromReservationName', () => { - const result = client.matchZoneFromReservationName(fakePath); - assert.strictEqual(result, "zoneValue"); - assert((client.pathTemplates.reservationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('location', async () => { + const fakePath = '/rendered/path/location'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = + new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + 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('matchReservationFromReservationName', () => { - const result = client.matchReservationFromReservationName(fakePath); - assert.strictEqual(result, "reservationValue"); - assert((client.pathTemplates.reservationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('lustreInstance', async () => { + const fakePath = '/rendered/path/lustreInstance'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + instance: 'instanceValue', + }; + const client = + new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.lustreInstancePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.lustreInstancePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('lustreInstancePath', () => { + const result = client.lustreInstancePath( + 'projectValue', + 'locationValue', + 'instanceValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.lustreInstancePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromLustreInstanceName', () => { + const result = client.matchProjectFromLustreInstanceName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.lustreInstancePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromLustreInstanceName', () => { + const result = client.matchLocationFromLustreInstanceName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.lustreInstancePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchInstanceFromLustreInstanceName', () => { + const result = client.matchInstanceFromLustreInstanceName(fakePath); + assert.strictEqual(result, 'instanceValue'); + assert( + (client.pathTemplates.lustreInstancePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('subnetwork', async () => { - const fakePath = "/rendered/path/subnetwork"; - const expectedParameters = { - project: "projectValue", - region: "regionValue", - subnetwork: "subnetworkValue", - }; - const client = new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.subnetworkPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.subnetworkPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('subnetworkPath', () => { - const result = client.subnetworkPath("projectValue", "regionValue", "subnetworkValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.subnetworkPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + describe('network', async () => { + const fakePath = '/rendered/path/network'; + const expectedParameters = { + project: 'projectValue', + network: 'networkValue', + }; + const client = + new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.networkPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.networkPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('networkPath', () => { + const result = client.networkPath('projectValue', 'networkValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.networkPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromNetworkName', () => { + const result = client.matchProjectFromNetworkName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.networkPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchNetworkFromNetworkName', () => { + const result = client.matchNetworkFromNetworkName(fakePath); + assert.strictEqual(result, 'networkValue'); + assert( + (client.pathTemplates.networkPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchProjectFromSubnetworkName', () => { - const result = client.matchProjectFromSubnetworkName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.subnetworkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('project', async () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = + new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + 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('matchRegionFromSubnetworkName', () => { - const result = client.matchRegionFromSubnetworkName(fakePath); - assert.strictEqual(result, "regionValue"); - assert((client.pathTemplates.subnetworkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('reservation', async () => { + const fakePath = '/rendered/path/reservation'; + const expectedParameters = { + project: 'projectValue', + zone: 'zoneValue', + reservation: 'reservationValue', + }; + const client = + new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.reservationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.reservationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('reservationPath', () => { + const result = client.reservationPath( + 'projectValue', + 'zoneValue', + 'reservationValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.reservationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromReservationName', () => { + const result = client.matchProjectFromReservationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.reservationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchZoneFromReservationName', () => { + const result = client.matchZoneFromReservationName(fakePath); + assert.strictEqual(result, 'zoneValue'); + assert( + (client.pathTemplates.reservationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchReservationFromReservationName', () => { + const result = client.matchReservationFromReservationName(fakePath); + assert.strictEqual(result, 'reservationValue'); + assert( + (client.pathTemplates.reservationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchSubnetworkFromSubnetworkName', () => { - const result = client.matchSubnetworkFromSubnetworkName(fakePath); - assert.strictEqual(result, "subnetworkValue"); - assert((client.pathTemplates.subnetworkPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('subnetwork', async () => { + const fakePath = '/rendered/path/subnetwork'; + const expectedParameters = { + project: 'projectValue', + region: 'regionValue', + subnetwork: 'subnetworkValue', + }; + const client = + new hypercomputeclusterModule.v1beta.HypercomputeClusterClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.subnetworkPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.subnetworkPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('subnetworkPath', () => { + const result = client.subnetworkPath( + 'projectValue', + 'regionValue', + 'subnetworkValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.subnetworkPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromSubnetworkName', () => { + const result = client.matchProjectFromSubnetworkName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.subnetworkPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRegionFromSubnetworkName', () => { + const result = client.matchRegionFromSubnetworkName(fakePath); + assert.strictEqual(result, 'regionValue'); + assert( + (client.pathTemplates.subnetworkPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchSubnetworkFromSubnetworkName', () => { + const result = client.matchSubnetworkFromSubnetworkName(fakePath); + assert.strictEqual(result, 'subnetworkValue'); + assert( + (client.pathTemplates.subnetworkPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-hypercomputecluster/test/gapic_machine_learning_runs_v1alpha.ts b/packages/google-cloud-hypercomputecluster/test/gapic_machine_learning_runs_v1alpha.ts index de445943182e..d026b39cf724 100644 --- a/packages/google-cloud-hypercomputecluster/test/gapic_machine_learning_runs_v1alpha.ts +++ b/packages/google-cloud-hypercomputecluster/test/gapic_machine_learning_runs_v1alpha.ts @@ -19,4356 +19,5864 @@ 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 machinelearningrunsModule 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('v1alpha.MachineLearningRunsClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'hypercomputecluster.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient(); - 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 = machinelearningrunsModule.v1alpha.MachineLearningRunsClient.servicePath; - assert.strictEqual(servicePath, 'hypercomputecluster.googleapis.com'); - assert(stub.called); - stub.restore(); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'hypercomputecluster.googleapis.com'); + }); - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = machinelearningrunsModule.v1alpha.MachineLearningRunsClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'hypercomputecluster.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'hypercomputecluster.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'hypercomputecluster.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 machinelearningrunsModule.v1alpha.MachineLearningRunsClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'hypercomputecluster.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 machinelearningrunsModule.v1alpha.MachineLearningRunsClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'hypercomputecluster.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 machinelearningrunsModule.v1alpha.MachineLearningRunsClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); + it('has universeDomain', () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('has port', () => { - const port = machinelearningrunsModule.v1alpha.MachineLearningRunsClient.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 = + machinelearningrunsModule.v1alpha.MachineLearningRunsClient + .servicePath; + assert.strictEqual(servicePath, 'hypercomputecluster.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + machinelearningrunsModule.v1alpha.MachineLearningRunsClient + .apiEndpoint; + assert.strictEqual(apiEndpoint, 'hypercomputecluster.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + universeDomain: 'example.com', }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'hypercomputecluster.example.com'); + }); - it('should create a client with no option', () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient(); - assert(client); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + universe_domain: 'example.com', }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'hypercomputecluster.example.com'); + }); - it('should create a client with gRPC fallback', () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - 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 machinelearningrunsModule.v1alpha.MachineLearningRunsClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'hypercomputecluster.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 machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual( + servicePath, + 'hypercomputecluster.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 machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.machineLearningRunsStub, undefined); - await client.initialize(); - assert(client.machineLearningRunsStub); - }); + it('has port', () => { + const port = + machinelearningrunsModule.v1alpha.MachineLearningRunsClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has close method for the initialized client', done => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.machineLearningRunsStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('should create a client with no option', () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + fallback: true, }); + assert(client); + }); - it('has close method for the non-initialized client', done => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.machineLearningRunsStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('has initialize method and supports deferred initialization', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + assert.strictEqual(client.machineLearningRunsStub, undefined); + await client.initialize(); + assert(client.machineLearningRunsStub); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - 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 machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.machineLearningRunsStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - 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 machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.machineLearningRunsStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('getMachineLearningRun', () => { - it('invokes getMachineLearningRun without error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.GetMachineLearningRunRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.GetMachineLearningRunRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.MachineLearningRun() - ); - client.innerApiCalls.getMachineLearningRun = stubSimpleCall(expectedResponse); - const [response] = await client.getMachineLearningRun(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getMachineLearningRun as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getMachineLearningRun as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getMachineLearningRun without error using callback', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.GetMachineLearningRunRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.GetMachineLearningRunRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.MachineLearningRun() - ); - client.innerApiCalls.getMachineLearningRun = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getMachineLearningRun( - request, - (err?: Error|null, result?: protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getMachineLearningRun as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getMachineLearningRun as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getMachineLearningRun with error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.GetMachineLearningRunRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.GetMachineLearningRunRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getMachineLearningRun = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getMachineLearningRun(request), expectedError); - const actualRequest = (client.innerApiCalls.getMachineLearningRun as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getMachineLearningRun as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getMachineLearningRun with closed client', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.GetMachineLearningRunRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.GetMachineLearningRunRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getMachineLearningRun(request), expectedError); - }); - }); - - describe('getProfilerTarget', () => { - it('invokes getProfilerTarget without error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.GetProfilerTargetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.GetProfilerTargetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.ProfilerTarget() - ); - client.innerApiCalls.getProfilerTarget = stubSimpleCall(expectedResponse); - const [response] = await client.getProfilerTarget(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getProfilerTarget as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProfilerTarget as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProfilerTarget without error using callback', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.GetProfilerTargetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.GetProfilerTargetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.ProfilerTarget() - ); - client.innerApiCalls.getProfilerTarget = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getProfilerTarget( - request, - (err?: Error|null, result?: protos.google.cloud.hypercomputecluster.v1alpha.IProfilerTarget|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getProfilerTarget as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProfilerTarget as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProfilerTarget with error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.GetProfilerTargetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.GetProfilerTargetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getProfilerTarget = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getProfilerTarget(request), expectedError); - const actualRequest = (client.innerApiCalls.getProfilerTarget as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProfilerTarget as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProfilerTarget with closed client', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.GetProfilerTargetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.GetProfilerTargetRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getProfilerTarget(request), expectedError); - }); - }); - - describe('deleteProfilerTarget', () => { - it('invokes deleteProfilerTarget without error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.DeleteProfilerTargetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.DeleteProfilerTargetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteProfilerTarget = stubSimpleCall(expectedResponse); - const [response] = await client.deleteProfilerTarget(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteProfilerTarget as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProfilerTarget as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProfilerTarget without error using callback', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.DeleteProfilerTargetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.DeleteProfilerTargetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteProfilerTarget = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteProfilerTarget( - 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.deleteProfilerTarget as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProfilerTarget as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProfilerTarget with error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.DeleteProfilerTargetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.DeleteProfilerTargetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteProfilerTarget = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteProfilerTarget(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteProfilerTarget as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProfilerTarget as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProfilerTarget with closed client', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.DeleteProfilerTargetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.DeleteProfilerTargetRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.deleteProfilerTarget(request), expectedError); - }); - }); - - describe('getProfilerSession', () => { - it('invokes getProfilerSession without error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.GetProfilerSessionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.GetProfilerSessionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.ProfilerSession() - ); - client.innerApiCalls.getProfilerSession = stubSimpleCall(expectedResponse); - const [response] = await client.getProfilerSession(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getProfilerSession as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProfilerSession as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProfilerSession without error using callback', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.GetProfilerSessionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.GetProfilerSessionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.ProfilerSession() - ); - client.innerApiCalls.getProfilerSession = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getProfilerSession( - request, - (err?: Error|null, result?: protos.google.cloud.hypercomputecluster.v1alpha.IProfilerSession|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getProfilerSession as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProfilerSession as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProfilerSession with error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.GetProfilerSessionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.GetProfilerSessionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getProfilerSession = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getProfilerSession(request), expectedError); - const actualRequest = (client.innerApiCalls.getProfilerSession as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProfilerSession as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProfilerSession with closed client', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.GetProfilerSessionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.GetProfilerSessionRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getProfilerSession(request), expectedError); - }); - }); - - describe('deleteProfilerSession', () => { - it('invokes deleteProfilerSession without error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.DeleteProfilerSessionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.DeleteProfilerSessionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteProfilerSession = stubSimpleCall(expectedResponse); - const [response] = await client.deleteProfilerSession(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteProfilerSession as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProfilerSession as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProfilerSession without error using callback', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.DeleteProfilerSessionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.DeleteProfilerSessionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteProfilerSession = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteProfilerSession( - 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.deleteProfilerSession as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProfilerSession as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProfilerSession with error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.DeleteProfilerSessionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.DeleteProfilerSessionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteProfilerSession = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteProfilerSession(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteProfilerSession as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteProfilerSession as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteProfilerSession with closed client', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.DeleteProfilerSessionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.DeleteProfilerSessionRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.deleteProfilerSession(request), expectedError); - }); - }); - - describe('getProfileSession', () => { - it('invokes getProfileSession without error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const stub = sinon.stub(client, 'warn'); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.GetProfileSessionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.GetProfileSessionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.ProfileSession() - ); - client.innerApiCalls.getProfileSession = stubSimpleCall(expectedResponse); - const [response] = await client.getProfileSession(request); - assert(stub.calledOnce); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getProfileSession as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProfileSession as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProfileSession without error using callback', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const stub = sinon.stub(client, 'warn'); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.GetProfileSessionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.GetProfileSessionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.ProfileSession() - ); - client.innerApiCalls.getProfileSession = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getProfileSession( - request, - (err?: Error|null, result?: protos.google.cloud.hypercomputecluster.v1alpha.IProfileSession|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert(stub.calledOnce); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getProfileSession as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProfileSession as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProfileSession with error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const stub = sinon.stub(client, 'warn'); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.GetProfileSessionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.GetProfileSessionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getProfileSession = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getProfileSession(request), expectedError); - assert(stub.calledOnce); - const actualRequest = (client.innerApiCalls.getProfileSession as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProfileSession as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProfileSession with closed client', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const stub = sinon.stub(client, 'warn'); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.GetProfileSessionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.GetProfileSessionRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getProfileSession(request), expectedError); - assert(stub.calledOnce); - }); - }); - - describe('getMonitoredEvent', () => { - it('invokes getMonitoredEvent without error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.GetMonitoredEventRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.GetMonitoredEventRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.MonitoredEvent() - ); - client.innerApiCalls.getMonitoredEvent = stubSimpleCall(expectedResponse); - const [response] = await client.getMonitoredEvent(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getMonitoredEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getMonitoredEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getMonitoredEvent without error using callback', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.GetMonitoredEventRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.GetMonitoredEventRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.MonitoredEvent() - ); - client.innerApiCalls.getMonitoredEvent = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getMonitoredEvent( - request, - (err?: Error|null, result?: protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getMonitoredEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getMonitoredEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getMonitoredEvent with error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.GetMonitoredEventRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.GetMonitoredEventRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getMonitoredEvent = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getMonitoredEvent(request), expectedError); - const actualRequest = (client.innerApiCalls.getMonitoredEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getMonitoredEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getMonitoredEvent with closed client', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.GetMonitoredEventRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.GetMonitoredEventRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getMonitoredEvent(request), expectedError); - }); - }); - - describe('createMachineLearningRun', () => { - it('invokes createMachineLearningRun without error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.CreateMachineLearningRunRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.CreateMachineLearningRunRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createMachineLearningRun = stubLongRunningCall(expectedResponse); - const [operation] = await client.createMachineLearningRun(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createMachineLearningRun as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createMachineLearningRun as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createMachineLearningRun without error using callback', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.CreateMachineLearningRunRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.CreateMachineLearningRunRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createMachineLearningRun = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createMachineLearningRun( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createMachineLearningRun as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createMachineLearningRun as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createMachineLearningRun with call error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.CreateMachineLearningRunRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.CreateMachineLearningRunRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createMachineLearningRun = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createMachineLearningRun(request), expectedError); - const actualRequest = (client.innerApiCalls.createMachineLearningRun as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createMachineLearningRun as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createMachineLearningRun with LRO error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.CreateMachineLearningRunRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.CreateMachineLearningRunRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createMachineLearningRun = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createMachineLearningRun(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createMachineLearningRun as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createMachineLearningRun as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateMachineLearningRunProgress without error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateMachineLearningRunProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateMachineLearningRunProgress with error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - 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 machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + 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.checkCreateMachineLearningRunProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + 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('getMachineLearningRun', () => { + it('invokes getMachineLearningRun without error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.GetMachineLearningRunRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.GetMachineLearningRunRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.MachineLearningRun(), + ); + client.innerApiCalls.getMachineLearningRun = + stubSimpleCall(expectedResponse); + const [response] = await client.getMachineLearningRun(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getMachineLearningRun as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMachineLearningRun as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateMachineLearningRun', () => { - it('invokes updateMachineLearningRun without error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.UpdateMachineLearningRunRequest() - ); - request.machineLearningRun ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.UpdateMachineLearningRunRequest', ['machineLearningRun', 'name']); - request.machineLearningRun.name = defaultValue1; - const expectedHeaderRequestParams = `machine_learning_run.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateMachineLearningRun = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateMachineLearningRun(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateMachineLearningRun as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateMachineLearningRun as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateMachineLearningRun without error using callback', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.UpdateMachineLearningRunRequest() - ); - request.machineLearningRun ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.UpdateMachineLearningRunRequest', ['machineLearningRun', 'name']); - request.machineLearningRun.name = defaultValue1; - const expectedHeaderRequestParams = `machine_learning_run.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateMachineLearningRun = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateMachineLearningRun( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateMachineLearningRun as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateMachineLearningRun as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateMachineLearningRun with call error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.UpdateMachineLearningRunRequest() - ); - request.machineLearningRun ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.UpdateMachineLearningRunRequest', ['machineLearningRun', 'name']); - request.machineLearningRun.name = defaultValue1; - const expectedHeaderRequestParams = `machine_learning_run.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateMachineLearningRun = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateMachineLearningRun(request), expectedError); - const actualRequest = (client.innerApiCalls.updateMachineLearningRun as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateMachineLearningRun as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateMachineLearningRun with LRO error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.UpdateMachineLearningRunRequest() - ); - request.machineLearningRun ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.UpdateMachineLearningRunRequest', ['machineLearningRun', 'name']); - request.machineLearningRun.name = defaultValue1; - const expectedHeaderRequestParams = `machine_learning_run.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateMachineLearningRun = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateMachineLearningRun(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateMachineLearningRun as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateMachineLearningRun as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpdateMachineLearningRunProgress without error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateMachineLearningRunProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateMachineLearningRunProgress with error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes getMachineLearningRun without error using callback', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.GetMachineLearningRunRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.GetMachineLearningRunRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.MachineLearningRun(), + ); + client.innerApiCalls.getMachineLearningRun = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getMachineLearningRun( + request, + ( + err?: Error | null, + result?: protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getMachineLearningRun as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMachineLearningRun as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateMachineLearningRunProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes getMachineLearningRun with error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.GetMachineLearningRunRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.GetMachineLearningRunRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getMachineLearningRun = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getMachineLearningRun(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.getMachineLearningRun as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMachineLearningRun as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteMachineLearningRun', () => { - it('invokes deleteMachineLearningRun without error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.DeleteMachineLearningRunRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.DeleteMachineLearningRunRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteMachineLearningRun = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteMachineLearningRun(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteMachineLearningRun as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteMachineLearningRun as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteMachineLearningRun without error using callback', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.DeleteMachineLearningRunRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.DeleteMachineLearningRunRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteMachineLearningRun = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteMachineLearningRun( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteMachineLearningRun as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteMachineLearningRun as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteMachineLearningRun with call error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.DeleteMachineLearningRunRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.DeleteMachineLearningRunRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteMachineLearningRun = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteMachineLearningRun(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteMachineLearningRun as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteMachineLearningRun as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteMachineLearningRun with LRO error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.DeleteMachineLearningRunRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.DeleteMachineLearningRunRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteMachineLearningRun = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteMachineLearningRun(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteMachineLearningRun as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteMachineLearningRun as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteMachineLearningRunProgress without error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteMachineLearningRunProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteMachineLearningRunProgress with error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes getMachineLearningRun with closed client', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.GetMachineLearningRunRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.GetMachineLearningRunRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.getMachineLearningRun(request), + expectedError, + ); + }); + }); + + describe('getProfilerTarget', () => { + it('invokes getProfilerTarget without error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.GetProfilerTargetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.GetProfilerTargetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ProfilerTarget(), + ); + client.innerApiCalls.getProfilerTarget = stubSimpleCall(expectedResponse); + const [response] = await client.getProfilerTarget(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getProfilerTarget as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProfilerTarget as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteMachineLearningRunProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes getProfilerTarget without error using callback', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.GetProfilerTargetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.GetProfilerTargetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ProfilerTarget(), + ); + client.innerApiCalls.getProfilerTarget = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getProfilerTarget( + request, + ( + err?: Error | null, + result?: protos.google.cloud.hypercomputecluster.v1alpha.IProfilerTarget | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getProfilerTarget as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProfilerTarget as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createProfilerTarget', () => { - it('invokes createProfilerTarget without error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.CreateProfilerTargetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.CreateProfilerTargetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createProfilerTarget = stubLongRunningCall(expectedResponse); - const [operation] = await client.createProfilerTarget(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createProfilerTarget as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProfilerTarget as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createProfilerTarget without error using callback', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.CreateProfilerTargetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.CreateProfilerTargetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createProfilerTarget = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createProfilerTarget( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createProfilerTarget as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProfilerTarget as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createProfilerTarget with call error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.CreateProfilerTargetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.CreateProfilerTargetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createProfilerTarget = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createProfilerTarget(request), expectedError); - const actualRequest = (client.innerApiCalls.createProfilerTarget as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProfilerTarget as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createProfilerTarget with LRO error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.CreateProfilerTargetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.CreateProfilerTargetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createProfilerTarget = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createProfilerTarget(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createProfilerTarget as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProfilerTarget as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateProfilerTargetProgress without error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateProfilerTargetProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateProfilerTargetProgress with error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes getProfilerTarget with error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.GetProfilerTargetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.GetProfilerTargetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getProfilerTarget = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getProfilerTarget(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getProfilerTarget as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProfilerTarget as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateProfilerTargetProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes getProfilerTarget with closed client', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.GetProfilerTargetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.GetProfilerTargetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getProfilerTarget(request), expectedError); + }); + }); + + describe('deleteProfilerTarget', () => { + it('invokes deleteProfilerTarget without error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.DeleteProfilerTargetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.DeleteProfilerTargetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteProfilerTarget = + stubSimpleCall(expectedResponse); + const [response] = await client.deleteProfilerTarget(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteProfilerTarget as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteProfilerTarget as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createProfilerSession', () => { - it('invokes createProfilerSession without error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.CreateProfilerSessionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.CreateProfilerSessionRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createProfilerSession = stubLongRunningCall(expectedResponse); - const [operation] = await client.createProfilerSession(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createProfilerSession as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProfilerSession as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createProfilerSession without error using callback', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.CreateProfilerSessionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.CreateProfilerSessionRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createProfilerSession = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createProfilerSession( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createProfilerSession as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProfilerSession as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createProfilerSession with call error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.CreateProfilerSessionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.CreateProfilerSessionRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createProfilerSession = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createProfilerSession(request), expectedError); - const actualRequest = (client.innerApiCalls.createProfilerSession as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProfilerSession as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createProfilerSession with LRO error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.CreateProfilerSessionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.CreateProfilerSessionRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createProfilerSession = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createProfilerSession(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createProfilerSession as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createProfilerSession as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateProfilerSessionProgress without error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateProfilerSessionProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateProfilerSessionProgress with error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes deleteProfilerTarget without error using callback', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.DeleteProfilerTargetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.DeleteProfilerTargetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteProfilerTarget = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteProfilerTarget( + 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.deleteProfilerTarget as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteProfilerTarget as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateProfilerSessionProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes deleteProfilerTarget with error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.DeleteProfilerTargetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.DeleteProfilerTargetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteProfilerTarget = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteProfilerTarget(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteProfilerTarget as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteProfilerTarget as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createMonitoredEvent', () => { - it('invokes createMonitoredEvent without error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.CreateMonitoredEventRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.CreateMonitoredEventRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createMonitoredEvent = stubLongRunningCall(expectedResponse); - const [operation] = await client.createMonitoredEvent(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createMonitoredEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createMonitoredEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createMonitoredEvent without error using callback', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.CreateMonitoredEventRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.CreateMonitoredEventRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createMonitoredEvent = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createMonitoredEvent( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createMonitoredEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createMonitoredEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createMonitoredEvent with call error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.CreateMonitoredEventRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.CreateMonitoredEventRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createMonitoredEvent = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createMonitoredEvent(request), expectedError); - const actualRequest = (client.innerApiCalls.createMonitoredEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createMonitoredEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createMonitoredEvent with LRO error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.CreateMonitoredEventRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.CreateMonitoredEventRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createMonitoredEvent = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createMonitoredEvent(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createMonitoredEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createMonitoredEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateMonitoredEventProgress without error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateMonitoredEventProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateMonitoredEventProgress with error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes deleteProfilerTarget with closed client', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.DeleteProfilerTargetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.DeleteProfilerTargetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.deleteProfilerTarget(request), expectedError); + }); + }); + + describe('getProfilerSession', () => { + it('invokes getProfilerSession without error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.GetProfilerSessionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.GetProfilerSessionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ProfilerSession(), + ); + client.innerApiCalls.getProfilerSession = + stubSimpleCall(expectedResponse); + const [response] = await client.getProfilerSession(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getProfilerSession as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProfilerSession as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateMonitoredEventProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes getProfilerSession without error using callback', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.GetProfilerSessionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.GetProfilerSessionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ProfilerSession(), + ); + client.innerApiCalls.getProfilerSession = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getProfilerSession( + request, + ( + err?: Error | null, + result?: protos.google.cloud.hypercomputecluster.v1alpha.IProfilerSession | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getProfilerSession as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProfilerSession as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateMonitoredEvent', () => { - it('invokes updateMonitoredEvent without error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.UpdateMonitoredEventRequest() - ); - request.monitoredEvent ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.UpdateMonitoredEventRequest', ['monitoredEvent', 'name']); - request.monitoredEvent.name = defaultValue1; - const expectedHeaderRequestParams = `monitored_event.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateMonitoredEvent = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateMonitoredEvent(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateMonitoredEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateMonitoredEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateMonitoredEvent without error using callback', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.UpdateMonitoredEventRequest() - ); - request.monitoredEvent ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.UpdateMonitoredEventRequest', ['monitoredEvent', 'name']); - request.monitoredEvent.name = defaultValue1; - const expectedHeaderRequestParams = `monitored_event.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateMonitoredEvent = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateMonitoredEvent( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateMonitoredEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateMonitoredEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateMonitoredEvent with call error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.UpdateMonitoredEventRequest() - ); - request.monitoredEvent ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.UpdateMonitoredEventRequest', ['monitoredEvent', 'name']); - request.monitoredEvent.name = defaultValue1; - const expectedHeaderRequestParams = `monitored_event.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateMonitoredEvent = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateMonitoredEvent(request), expectedError); - const actualRequest = (client.innerApiCalls.updateMonitoredEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateMonitoredEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateMonitoredEvent with LRO error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.UpdateMonitoredEventRequest() - ); - request.monitoredEvent ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.UpdateMonitoredEventRequest', ['monitoredEvent', 'name']); - request.monitoredEvent.name = defaultValue1; - const expectedHeaderRequestParams = `monitored_event.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateMonitoredEvent = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateMonitoredEvent(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateMonitoredEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateMonitoredEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkUpdateMonitoredEventProgress without error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateMonitoredEventProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateMonitoredEventProgress with error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes getProfilerSession with error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.GetProfilerSessionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.GetProfilerSessionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getProfilerSession = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getProfilerSession(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getProfilerSession as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProfilerSession as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateMonitoredEventProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes getProfilerSession with closed client', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.GetProfilerSessionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.GetProfilerSessionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getProfilerSession(request), expectedError); + }); + }); + + describe('deleteProfilerSession', () => { + it('invokes deleteProfilerSession without error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.DeleteProfilerSessionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.DeleteProfilerSessionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteProfilerSession = + stubSimpleCall(expectedResponse); + const [response] = await client.deleteProfilerSession(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteProfilerSession as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteProfilerSession as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteMonitoredEvent', () => { - it('invokes deleteMonitoredEvent without error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.DeleteMonitoredEventRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.DeleteMonitoredEventRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteMonitoredEvent = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteMonitoredEvent(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteMonitoredEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteMonitoredEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteMonitoredEvent without error using callback', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.DeleteMonitoredEventRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.DeleteMonitoredEventRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteMonitoredEvent = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteMonitoredEvent( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteMonitoredEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteMonitoredEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteMonitoredEvent with call error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.DeleteMonitoredEventRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.DeleteMonitoredEventRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteMonitoredEvent = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteMonitoredEvent(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteMonitoredEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteMonitoredEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteMonitoredEvent with LRO error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.DeleteMonitoredEventRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.DeleteMonitoredEventRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteMonitoredEvent = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteMonitoredEvent(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteMonitoredEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteMonitoredEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteMonitoredEventProgress without error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteMonitoredEventProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteMonitoredEventProgress with error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes deleteProfilerSession without error using callback', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.DeleteProfilerSessionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.DeleteProfilerSessionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteProfilerSession = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteProfilerSession( + 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.deleteProfilerSession as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteProfilerSession as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteMonitoredEventProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes deleteProfilerSession with error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.DeleteProfilerSessionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.DeleteProfilerSessionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteProfilerSession = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.deleteProfilerSession(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.deleteProfilerSession as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteProfilerSession as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listMachineLearningRuns', () => { - it('invokes listMachineLearningRuns without error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.ListMachineLearningRunsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.ListMachineLearningRunsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.MachineLearningRun()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.MachineLearningRun()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.MachineLearningRun()), - ]; - client.innerApiCalls.listMachineLearningRuns = stubSimpleCall(expectedResponse); - const [response] = await client.listMachineLearningRuns(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listMachineLearningRuns as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listMachineLearningRuns as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listMachineLearningRuns without error using callback', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.ListMachineLearningRunsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.ListMachineLearningRunsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.MachineLearningRun()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.MachineLearningRun()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.MachineLearningRun()), - ]; - client.innerApiCalls.listMachineLearningRuns = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listMachineLearningRuns( - request, - (err?: Error|null, result?: protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listMachineLearningRuns as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listMachineLearningRuns as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listMachineLearningRuns with error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.ListMachineLearningRunsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.ListMachineLearningRunsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listMachineLearningRuns = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listMachineLearningRuns(request), expectedError); - const actualRequest = (client.innerApiCalls.listMachineLearningRuns as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listMachineLearningRuns as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listMachineLearningRunsStream without error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.ListMachineLearningRunsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.ListMachineLearningRunsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.MachineLearningRun()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.MachineLearningRun()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.MachineLearningRun()), - ]; - client.descriptors.page.listMachineLearningRuns.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listMachineLearningRunsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.hypercomputecluster.v1alpha.MachineLearningRun[] = []; - stream.on('data', (response: protos.google.cloud.hypercomputecluster.v1alpha.MachineLearningRun) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listMachineLearningRuns.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listMachineLearningRuns, request)); - assert( - (client.descriptors.page.listMachineLearningRuns.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listMachineLearningRunsStream with error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.ListMachineLearningRunsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.ListMachineLearningRunsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listMachineLearningRuns.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listMachineLearningRunsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.hypercomputecluster.v1alpha.MachineLearningRun[] = []; - stream.on('data', (response: protos.google.cloud.hypercomputecluster.v1alpha.MachineLearningRun) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listMachineLearningRuns.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listMachineLearningRuns, request)); - assert( - (client.descriptors.page.listMachineLearningRuns.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listMachineLearningRuns without error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.ListMachineLearningRunsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.ListMachineLearningRunsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.MachineLearningRun()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.MachineLearningRun()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.MachineLearningRun()), - ]; - client.descriptors.page.listMachineLearningRuns.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun[] = []; - const iterable = client.listMachineLearningRunsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes deleteProfilerSession with closed client', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.DeleteProfilerSessionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.DeleteProfilerSessionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.deleteProfilerSession(request), + expectedError, + ); + }); + }); + + describe('getProfileSession', () => { + it('invokes getProfileSession without error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const stub = sinon.stub(client, 'warn'); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.GetProfileSessionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.GetProfileSessionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ProfileSession(), + ); + client.innerApiCalls.getProfileSession = stubSimpleCall(expectedResponse); + const [response] = await client.getProfileSession(request); + assert(stub.calledOnce); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getProfileSession as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProfileSession as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProfileSession without error using callback', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const stub = sinon.stub(client, 'warn'); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.GetProfileSessionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.GetProfileSessionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ProfileSession(), + ); + client.innerApiCalls.getProfileSession = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getProfileSession( + request, + ( + err?: Error | null, + result?: protos.google.cloud.hypercomputecluster.v1alpha.IProfileSession | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listMachineLearningRuns.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listMachineLearningRuns.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listMachineLearningRuns with error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.ListMachineLearningRunsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.ListMachineLearningRunsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listMachineLearningRuns.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listMachineLearningRunsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listMachineLearningRuns.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listMachineLearningRuns.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listProfilerTargets', () => { - it('invokes listProfilerTargets without error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.ListProfilerTargetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.ListProfilerTargetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.ProfilerTarget()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.ProfilerTarget()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.ProfilerTarget()), - ]; - client.innerApiCalls.listProfilerTargets = stubSimpleCall(expectedResponse); - const [response] = await client.listProfilerTargets(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProfilerTargets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProfilerTargets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProfilerTargets without error using callback', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.ListProfilerTargetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.ListProfilerTargetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.ProfilerTarget()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.ProfilerTarget()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.ProfilerTarget()), - ]; - client.innerApiCalls.listProfilerTargets = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listProfilerTargets( - request, - (err?: Error|null, result?: protos.google.cloud.hypercomputecluster.v1alpha.IProfilerTarget[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProfilerTargets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProfilerTargets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProfilerTargets with error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.ListProfilerTargetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.ListProfilerTargetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listProfilerTargets = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listProfilerTargets(request), expectedError); - const actualRequest = (client.innerApiCalls.listProfilerTargets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProfilerTargets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProfilerTargetsStream without error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.ListProfilerTargetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.ListProfilerTargetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.ProfilerTarget()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.ProfilerTarget()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.ProfilerTarget()), - ]; - client.descriptors.page.listProfilerTargets.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listProfilerTargetsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.hypercomputecluster.v1alpha.ProfilerTarget[] = []; - stream.on('data', (response: protos.google.cloud.hypercomputecluster.v1alpha.ProfilerTarget) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listProfilerTargets.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProfilerTargets, request)); - assert( - (client.descriptors.page.listProfilerTargets.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listProfilerTargetsStream with error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.ListProfilerTargetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.ListProfilerTargetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listProfilerTargets.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listProfilerTargetsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.hypercomputecluster.v1alpha.ProfilerTarget[] = []; - stream.on('data', (response: protos.google.cloud.hypercomputecluster.v1alpha.ProfilerTarget) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listProfilerTargets.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProfilerTargets, request)); - assert( - (client.descriptors.page.listProfilerTargets.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProfilerTargets without error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.ListProfilerTargetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.ListProfilerTargetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.ProfilerTarget()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.ProfilerTarget()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.ProfilerTarget()), - ]; - client.descriptors.page.listProfilerTargets.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.hypercomputecluster.v1alpha.IProfilerTarget[] = []; - const iterable = client.listProfilerTargetsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + }, + ); + }); + const response = await promise; + assert(stub.calledOnce); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getProfileSession as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProfileSession as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProfileSession with error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const stub = sinon.stub(client, 'warn'); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.GetProfileSessionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.GetProfileSessionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getProfileSession = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getProfileSession(request), expectedError); + assert(stub.calledOnce); + const actualRequest = ( + client.innerApiCalls.getProfileSession as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProfileSession as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getProfileSession with closed client', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const stub = sinon.stub(client, 'warn'); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.GetProfileSessionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.GetProfileSessionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getProfileSession(request), expectedError); + assert(stub.calledOnce); + }); + }); + + describe('getMonitoredEvent', () => { + it('invokes getMonitoredEvent without error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.GetMonitoredEventRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.GetMonitoredEventRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.MonitoredEvent(), + ); + client.innerApiCalls.getMonitoredEvent = stubSimpleCall(expectedResponse); + const [response] = await client.getMonitoredEvent(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getMonitoredEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMonitoredEvent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getMonitoredEvent without error using callback', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.GetMonitoredEventRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.GetMonitoredEventRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.MonitoredEvent(), + ); + client.innerApiCalls.getMonitoredEvent = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getMonitoredEvent( + request, + ( + err?: Error | null, + result?: protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listProfilerTargets.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listProfilerTargets.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProfilerTargets with error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.ListProfilerTargetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.ListProfilerTargetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listProfilerTargets.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listProfilerTargetsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.hypercomputecluster.v1alpha.IProfilerTarget[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listProfilerTargets.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listProfilerTargets.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listProfilerSessions', () => { - it('invokes listProfilerSessions without error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.ListProfilerSessionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.ListProfilerSessionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.ProfilerSession()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.ProfilerSession()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.ProfilerSession()), - ]; - client.innerApiCalls.listProfilerSessions = stubSimpleCall(expectedResponse); - const [response] = await client.listProfilerSessions(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProfilerSessions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProfilerSessions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProfilerSessions without error using callback', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.ListProfilerSessionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.ListProfilerSessionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.ProfilerSession()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.ProfilerSession()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.ProfilerSession()), - ]; - client.innerApiCalls.listProfilerSessions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listProfilerSessions( - request, - (err?: Error|null, result?: protos.google.cloud.hypercomputecluster.v1alpha.IProfilerSession[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProfilerSessions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProfilerSessions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProfilerSessions with error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.ListProfilerSessionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.ListProfilerSessionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listProfilerSessions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listProfilerSessions(request), expectedError); - const actualRequest = (client.innerApiCalls.listProfilerSessions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProfilerSessions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProfilerSessionsStream without error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.ListProfilerSessionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.ListProfilerSessionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.ProfilerSession()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.ProfilerSession()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.ProfilerSession()), - ]; - client.descriptors.page.listProfilerSessions.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listProfilerSessionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.hypercomputecluster.v1alpha.ProfilerSession[] = []; - stream.on('data', (response: protos.google.cloud.hypercomputecluster.v1alpha.ProfilerSession) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listProfilerSessions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProfilerSessions, request)); - assert( - (client.descriptors.page.listProfilerSessions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listProfilerSessionsStream with error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.ListProfilerSessionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.ListProfilerSessionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listProfilerSessions.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listProfilerSessionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.hypercomputecluster.v1alpha.ProfilerSession[] = []; - stream.on('data', (response: protos.google.cloud.hypercomputecluster.v1alpha.ProfilerSession) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listProfilerSessions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProfilerSessions, request)); - assert( - (client.descriptors.page.listProfilerSessions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProfilerSessions without error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.ListProfilerSessionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.ListProfilerSessionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.ProfilerSession()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.ProfilerSession()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.ProfilerSession()), - ]; - client.descriptors.page.listProfilerSessions.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.hypercomputecluster.v1alpha.IProfilerSession[] = []; - const iterable = client.listProfilerSessionsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getMonitoredEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMonitoredEvent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getMonitoredEvent with error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.GetMonitoredEventRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.GetMonitoredEventRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getMonitoredEvent = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getMonitoredEvent(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getMonitoredEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getMonitoredEvent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getMonitoredEvent with closed client', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.GetMonitoredEventRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.GetMonitoredEventRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getMonitoredEvent(request), expectedError); + }); + }); + + describe('createMachineLearningRun', () => { + it('invokes createMachineLearningRun without error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.CreateMachineLearningRunRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.CreateMachineLearningRunRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createMachineLearningRun = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createMachineLearningRun(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createMachineLearningRun as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMachineLearningRun as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createMachineLearningRun without error using callback', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.CreateMachineLearningRunRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.CreateMachineLearningRunRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createMachineLearningRun = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createMachineLearningRun( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listProfilerSessions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listProfilerSessions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProfilerSessions with error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.ListProfilerSessionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.ListProfilerSessionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listProfilerSessions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listProfilerSessionsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.hypercomputecluster.v1alpha.IProfilerSession[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listProfilerSessions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listProfilerSessions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listProfileSessions', () => { - it('invokes listProfileSessions without error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const stub = sinon.stub(client, 'warn'); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.ListProfileSessionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.ListProfileSessionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.ProfileSession()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.ProfileSession()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.ProfileSession()), - ]; - client.innerApiCalls.listProfileSessions = stubSimpleCall(expectedResponse); - const [response] = await client.listProfileSessions(request); - assert(stub.calledOnce); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProfileSessions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProfileSessions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProfileSessions without error using callback', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const stub = sinon.stub(client, 'warn'); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.ListProfileSessionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.ListProfileSessionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.ProfileSession()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.ProfileSession()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.ProfileSession()), - ]; - client.innerApiCalls.listProfileSessions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listProfileSessions( - request, - (err?: Error|null, result?: protos.google.cloud.hypercomputecluster.v1alpha.IProfileSession[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert(stub.calledOnce); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProfileSessions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProfileSessions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProfileSessions with error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const stub = sinon.stub(client, 'warn'); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.ListProfileSessionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.ListProfileSessionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listProfileSessions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listProfileSessions(request), expectedError); - assert(stub.calledOnce); - const actualRequest = (client.innerApiCalls.listProfileSessions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProfileSessions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProfileSessionsStream without error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const stub = sinon.stub(client, 'warn'); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.ListProfileSessionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.ListProfileSessionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.ProfileSession()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.ProfileSession()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.ProfileSession()), - ]; - client.descriptors.page.listProfileSessions.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listProfileSessionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.hypercomputecluster.v1alpha.ProfileSession[] = []; - stream.on('data', (response: protos.google.cloud.hypercomputecluster.v1alpha.ProfileSession) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert(stub.calledOnce); - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listProfileSessions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProfileSessions, request)); - assert( - (client.descriptors.page.listProfileSessions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listProfileSessionsStream with error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const stub = sinon.stub(client, 'warn'); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.ListProfileSessionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.ListProfileSessionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listProfileSessions.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listProfileSessionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.hypercomputecluster.v1alpha.ProfileSession[] = []; - stream.on('data', (response: protos.google.cloud.hypercomputecluster.v1alpha.ProfileSession) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert(stub.calledOnce); - assert((client.descriptors.page.listProfileSessions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProfileSessions, request)); - assert( - (client.descriptors.page.listProfileSessions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProfileSessions without error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const stub = sinon.stub(client, 'warn'); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.ListProfileSessionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.ListProfileSessionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.ProfileSession()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.ProfileSession()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.ProfileSession()), - ]; - client.descriptors.page.listProfileSessions.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.hypercomputecluster.v1alpha.IProfileSession[] = []; - const iterable = client.listProfileSessionsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createMachineLearningRun as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMachineLearningRun as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createMachineLearningRun with call error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.CreateMachineLearningRunRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.CreateMachineLearningRunRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createMachineLearningRun = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.createMachineLearningRun(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.createMachineLearningRun as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMachineLearningRun as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createMachineLearningRun with LRO error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.CreateMachineLearningRunRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.CreateMachineLearningRunRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createMachineLearningRun = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createMachineLearningRun(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createMachineLearningRun as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMachineLearningRun as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkCreateMachineLearningRunProgress without error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = + await client.checkCreateMachineLearningRunProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateMachineLearningRunProgress with error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateMachineLearningRunProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateMachineLearningRun', () => { + it('invokes updateMachineLearningRun without error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.UpdateMachineLearningRunRequest(), + ); + request.machineLearningRun ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.UpdateMachineLearningRunRequest', + ['machineLearningRun', 'name'], + ); + request.machineLearningRun.name = defaultValue1; + const expectedHeaderRequestParams = `machine_learning_run.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateMachineLearningRun = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateMachineLearningRun(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateMachineLearningRun as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateMachineLearningRun as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateMachineLearningRun without error using callback', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.UpdateMachineLearningRunRequest(), + ); + request.machineLearningRun ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.UpdateMachineLearningRunRequest', + ['machineLearningRun', 'name'], + ); + request.machineLearningRun.name = defaultValue1; + const expectedHeaderRequestParams = `machine_learning_run.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateMachineLearningRun = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateMachineLearningRun( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert(stub.calledOnce); - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listProfileSessions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listProfileSessions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listProfileSessions with error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const stub = sinon.stub(client, 'warn'); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.ListProfileSessionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.ListProfileSessionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listProfileSessions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listProfileSessionsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.hypercomputecluster.v1alpha.IProfileSession[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert(stub.calledOnce); - assert.deepStrictEqual( - (client.descriptors.page.listProfileSessions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listProfileSessions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listMonitoredEvents', () => { - it('invokes listMonitoredEvents without error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.ListMonitoredEventsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.ListMonitoredEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.MonitoredEvent()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.MonitoredEvent()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.MonitoredEvent()), - ]; - client.innerApiCalls.listMonitoredEvents = stubSimpleCall(expectedResponse); - const [response] = await client.listMonitoredEvents(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listMonitoredEvents as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listMonitoredEvents as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listMonitoredEvents without error using callback', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.ListMonitoredEventsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.ListMonitoredEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.MonitoredEvent()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.MonitoredEvent()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.MonitoredEvent()), - ]; - client.innerApiCalls.listMonitoredEvents = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listMonitoredEvents( - request, - (err?: Error|null, result?: protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listMonitoredEvents as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listMonitoredEvents as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listMonitoredEvents with error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.ListMonitoredEventsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.ListMonitoredEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listMonitoredEvents = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listMonitoredEvents(request), expectedError); - const actualRequest = (client.innerApiCalls.listMonitoredEvents as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listMonitoredEvents as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listMonitoredEventsStream without error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.ListMonitoredEventsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.ListMonitoredEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.MonitoredEvent()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.MonitoredEvent()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.MonitoredEvent()), - ]; - client.descriptors.page.listMonitoredEvents.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listMonitoredEventsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.hypercomputecluster.v1alpha.MonitoredEvent[] = []; - stream.on('data', (response: protos.google.cloud.hypercomputecluster.v1alpha.MonitoredEvent) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listMonitoredEvents.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listMonitoredEvents, request)); - assert( - (client.descriptors.page.listMonitoredEvents.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listMonitoredEventsStream with error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.ListMonitoredEventsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.ListMonitoredEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listMonitoredEvents.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listMonitoredEventsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.hypercomputecluster.v1alpha.MonitoredEvent[] = []; - stream.on('data', (response: protos.google.cloud.hypercomputecluster.v1alpha.MonitoredEvent) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listMonitoredEvents.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listMonitoredEvents, request)); - assert( - (client.descriptors.page.listMonitoredEvents.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listMonitoredEvents without error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.ListMonitoredEventsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.ListMonitoredEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.MonitoredEvent()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.MonitoredEvent()), - generateSampleMessage(new protos.google.cloud.hypercomputecluster.v1alpha.MonitoredEvent()), - ]; - client.descriptors.page.listMonitoredEvents.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent[] = []; - const iterable = client.listMonitoredEventsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateMachineLearningRun as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateMachineLearningRun as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateMachineLearningRun with call error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.UpdateMachineLearningRunRequest(), + ); + request.machineLearningRun ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.UpdateMachineLearningRunRequest', + ['machineLearningRun', 'name'], + ); + request.machineLearningRun.name = defaultValue1; + const expectedHeaderRequestParams = `machine_learning_run.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateMachineLearningRun = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.updateMachineLearningRun(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.updateMachineLearningRun as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateMachineLearningRun as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateMachineLearningRun with LRO error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.UpdateMachineLearningRunRequest(), + ); + request.machineLearningRun ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.UpdateMachineLearningRunRequest', + ['machineLearningRun', 'name'], + ); + request.machineLearningRun.name = defaultValue1; + const expectedHeaderRequestParams = `machine_learning_run.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateMachineLearningRun = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateMachineLearningRun(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateMachineLearningRun as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateMachineLearningRun as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkUpdateMachineLearningRunProgress without error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = + await client.checkUpdateMachineLearningRunProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpdateMachineLearningRunProgress with error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateMachineLearningRunProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteMachineLearningRun', () => { + it('invokes deleteMachineLearningRun without error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.DeleteMachineLearningRunRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.DeleteMachineLearningRunRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteMachineLearningRun = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteMachineLearningRun(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteMachineLearningRun as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteMachineLearningRun as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteMachineLearningRun without error using callback', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.DeleteMachineLearningRunRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.DeleteMachineLearningRunRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteMachineLearningRun = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteMachineLearningRun( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listMonitoredEvents.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listMonitoredEvents.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listMonitoredEvents with error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.hypercomputecluster.v1alpha.ListMonitoredEventsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.hypercomputecluster.v1alpha.ListMonitoredEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listMonitoredEvents.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listMonitoredEventsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listMonitoredEvents.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listMonitoredEvents.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 machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - 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 machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - 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 machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - 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 machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteMachineLearningRun as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteMachineLearningRun as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteMachineLearningRun with call error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.DeleteMachineLearningRunRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.DeleteMachineLearningRunRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteMachineLearningRun = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.deleteMachineLearningRun(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.deleteMachineLearningRun as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteMachineLearningRun as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteMachineLearningRun with LRO error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.DeleteMachineLearningRunRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.DeleteMachineLearningRunRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteMachineLearningRun = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteMachineLearningRun(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteMachineLearningRun as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteMachineLearningRun as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkDeleteMachineLearningRunProgress without error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = + await client.checkDeleteMachineLearningRunProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteMachineLearningRunProgress with error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteMachineLearningRunProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createProfilerTarget', () => { + it('invokes createProfilerTarget without error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.CreateProfilerTargetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.CreateProfilerTargetRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createProfilerTarget = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createProfilerTarget(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createProfilerTarget as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createProfilerTarget as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProfilerTarget without error using callback', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.CreateProfilerTargetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.CreateProfilerTargetRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createProfilerTarget = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createProfilerTarget( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IProfilerTarget, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - 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 machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - 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 machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - 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 machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - 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 machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - 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 machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - 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 machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - 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 machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - 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 machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - 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 machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - 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 machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.IOperation[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IProfilerTarget, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createProfilerTarget as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createProfilerTarget as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProfilerTarget with call error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.CreateProfilerTargetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.CreateProfilerTargetRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createProfilerTarget = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createProfilerTarget(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createProfilerTarget as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createProfilerTarget as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProfilerTarget with LRO error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.CreateProfilerTargetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.CreateProfilerTargetRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createProfilerTarget = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createProfilerTarget(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createProfilerTarget as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createProfilerTarget as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkCreateProfilerTargetProgress without error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateProfilerTargetProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateProfilerTargetProgress with error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateProfilerTargetProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createProfilerSession', () => { + it('invokes createProfilerSession without error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.CreateProfilerSessionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.CreateProfilerSessionRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createProfilerSession = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createProfilerSession(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createProfilerSession as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createProfilerSession as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createProfilerSession without error using callback', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.CreateProfilerSessionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.CreateProfilerSessionRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createProfilerSession = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createProfilerSession( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IProfilerSession, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.IOperation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IProfilerSession, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createProfilerSession as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createProfilerSession as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('Path templates', () => { + it('invokes createProfilerSession with call error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.CreateProfilerSessionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.CreateProfilerSessionRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createProfilerSession = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.createProfilerSession(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.createProfilerSession as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createProfilerSession as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('cluster', async () => { - const fakePath = "/rendered/path/cluster"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - cluster: "clusterValue", - }; - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.clusterPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.clusterPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('clusterPath', () => { - const result = client.clusterPath("projectValue", "locationValue", "clusterValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.clusterPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes createProfilerSession with LRO error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.CreateProfilerSessionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.CreateProfilerSessionRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createProfilerSession = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createProfilerSession(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createProfilerSession as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createProfilerSession as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchProjectFromClusterName', () => { - const result = client.matchProjectFromClusterName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.clusterPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes checkCreateProfilerSessionProgress without error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateProfilerSessionProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('matchLocationFromClusterName', () => { - const result = client.matchLocationFromClusterName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.clusterPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes checkCreateProfilerSessionProgress with error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateProfilerSessionProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createMonitoredEvent', () => { + it('invokes createMonitoredEvent without error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.CreateMonitoredEventRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.CreateMonitoredEventRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createMonitoredEvent = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createMonitoredEvent(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createMonitoredEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMonitoredEvent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchClusterFromClusterName', () => { - const result = client.matchClusterFromClusterName(fakePath); - assert.strictEqual(result, "clusterValue"); - assert((client.pathTemplates.clusterPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('invokes createMonitoredEvent without error using callback', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.CreateMonitoredEventRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.CreateMonitoredEventRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createMonitoredEvent = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createMonitoredEvent( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createMonitoredEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMonitoredEvent 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 machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - 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 createMonitoredEvent with call error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.CreateMonitoredEventRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.CreateMonitoredEventRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createMonitoredEvent = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createMonitoredEvent(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createMonitoredEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMonitoredEvent 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 createMonitoredEvent with LRO error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.CreateMonitoredEventRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.CreateMonitoredEventRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createMonitoredEvent = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createMonitoredEvent(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createMonitoredEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createMonitoredEvent 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 checkCreateMonitoredEventProgress without error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateMonitoredEventProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - describe('machineLearningRun', async () => { - const fakePath = "/rendered/path/machineLearningRun"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - machine_learning_run: "machineLearningRunValue", - }; - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.machineLearningRunPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.machineLearningRunPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('machineLearningRunPath', () => { - const result = client.machineLearningRunPath("projectValue", "locationValue", "machineLearningRunValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.machineLearningRunPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes checkCreateMonitoredEventProgress with error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateMonitoredEventProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateMonitoredEvent', () => { + it('invokes updateMonitoredEvent without error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.UpdateMonitoredEventRequest(), + ); + request.monitoredEvent ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.UpdateMonitoredEventRequest', + ['monitoredEvent', 'name'], + ); + request.monitoredEvent.name = defaultValue1; + const expectedHeaderRequestParams = `monitored_event.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateMonitoredEvent = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateMonitoredEvent(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateMonitoredEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateMonitoredEvent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchProjectFromMachineLearningRunName', () => { - const result = client.matchProjectFromMachineLearningRunName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.machineLearningRunPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes updateMonitoredEvent without error using callback', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.UpdateMonitoredEventRequest(), + ); + request.monitoredEvent ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.UpdateMonitoredEventRequest', + ['monitoredEvent', 'name'], + ); + request.monitoredEvent.name = defaultValue1; + const expectedHeaderRequestParams = `monitored_event.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateMonitoredEvent = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateMonitoredEvent( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateMonitoredEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateMonitoredEvent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchLocationFromMachineLearningRunName', () => { - const result = client.matchLocationFromMachineLearningRunName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.machineLearningRunPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes updateMonitoredEvent with call error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.UpdateMonitoredEventRequest(), + ); + request.monitoredEvent ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.UpdateMonitoredEventRequest', + ['monitoredEvent', 'name'], + ); + request.monitoredEvent.name = defaultValue1; + const expectedHeaderRequestParams = `monitored_event.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateMonitoredEvent = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateMonitoredEvent(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateMonitoredEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateMonitoredEvent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchMachineLearningRunFromMachineLearningRunName', () => { - const result = client.matchMachineLearningRunFromMachineLearningRunName(fakePath); - assert.strictEqual(result, "machineLearningRunValue"); - assert((client.pathTemplates.machineLearningRunPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('invokes updateMonitoredEvent with LRO error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.UpdateMonitoredEventRequest(), + ); + request.monitoredEvent ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.UpdateMonitoredEventRequest', + ['monitoredEvent', 'name'], + ); + request.monitoredEvent.name = defaultValue1; + const expectedHeaderRequestParams = `monitored_event.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateMonitoredEvent = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateMonitoredEvent(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateMonitoredEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateMonitoredEvent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('monitoredEvent', async () => { - const fakePath = "/rendered/path/monitoredEvent"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - machine_learning_run: "machineLearningRunValue", - monitored_event: "monitoredEventValue", - }; - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.monitoredEventPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.monitoredEventPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('monitoredEventPath', () => { - const result = client.monitoredEventPath("projectValue", "locationValue", "machineLearningRunValue", "monitoredEventValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.monitoredEventPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes checkUpdateMonitoredEventProgress without error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdateMonitoredEventProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('matchProjectFromMonitoredEventName', () => { - const result = client.matchProjectFromMonitoredEventName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.monitoredEventPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes checkUpdateMonitoredEventProgress with error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateMonitoredEventProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteMonitoredEvent', () => { + it('invokes deleteMonitoredEvent without error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.DeleteMonitoredEventRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.DeleteMonitoredEventRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteMonitoredEvent = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteMonitoredEvent(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteMonitoredEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteMonitoredEvent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchLocationFromMonitoredEventName', () => { - const result = client.matchLocationFromMonitoredEventName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.monitoredEventPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes deleteMonitoredEvent without error using callback', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.DeleteMonitoredEventRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.DeleteMonitoredEventRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteMonitoredEvent = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteMonitoredEvent( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.hypercomputecluster.v1alpha.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteMonitoredEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteMonitoredEvent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchMachineLearningRunFromMonitoredEventName', () => { - const result = client.matchMachineLearningRunFromMonitoredEventName(fakePath); - assert.strictEqual(result, "machineLearningRunValue"); - assert((client.pathTemplates.monitoredEventPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes deleteMonitoredEvent with call error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.DeleteMonitoredEventRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.DeleteMonitoredEventRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteMonitoredEvent = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteMonitoredEvent(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteMonitoredEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteMonitoredEvent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchMonitoredEventFromMonitoredEventName', () => { - const result = client.matchMonitoredEventFromMonitoredEventName(fakePath); - assert.strictEqual(result, "monitoredEventValue"); - assert((client.pathTemplates.monitoredEventPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('invokes deleteMonitoredEvent with LRO error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.DeleteMonitoredEventRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.DeleteMonitoredEventRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteMonitoredEvent = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteMonitoredEvent(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteMonitoredEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteMonitoredEvent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('node', async () => { - const fakePath = "/rendered/path/node"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - cluster: "clusterValue", - node: "nodeValue", - }; - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.nodePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.nodePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('nodePath', () => { - const result = client.nodePath("projectValue", "locationValue", "clusterValue", "nodeValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.nodePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes checkDeleteMonitoredEventProgress without error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteMonitoredEventProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('matchProjectFromNodeName', () => { - const result = client.matchProjectFromNodeName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.nodePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes checkDeleteMonitoredEventProgress with error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteMonitoredEventProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listMachineLearningRuns', () => { + it('invokes listMachineLearningRuns without error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ListMachineLearningRunsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.ListMachineLearningRunsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.MachineLearningRun(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.MachineLearningRun(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.MachineLearningRun(), + ), + ]; + client.innerApiCalls.listMachineLearningRuns = + stubSimpleCall(expectedResponse); + const [response] = await client.listMachineLearningRuns(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listMachineLearningRuns as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMachineLearningRuns as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchLocationFromNodeName', () => { - const result = client.matchLocationFromNodeName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.nodePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes listMachineLearningRuns without error using callback', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ListMachineLearningRunsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.ListMachineLearningRunsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.MachineLearningRun(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.MachineLearningRun(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.MachineLearningRun(), + ), + ]; + client.innerApiCalls.listMachineLearningRuns = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listMachineLearningRuns( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listMachineLearningRuns as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMachineLearningRuns as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchClusterFromNodeName', () => { - const result = client.matchClusterFromNodeName(fakePath); - assert.strictEqual(result, "clusterValue"); - assert((client.pathTemplates.nodePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes listMachineLearningRuns with error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ListMachineLearningRunsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.ListMachineLearningRunsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listMachineLearningRuns = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.listMachineLearningRuns(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.listMachineLearningRuns as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMachineLearningRuns as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchNodeFromNodeName', () => { - const result = client.matchNodeFromNodeName(fakePath); - assert.strictEqual(result, "nodeValue"); - assert((client.pathTemplates.nodePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('invokes listMachineLearningRunsStream without error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ListMachineLearningRunsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.ListMachineLearningRunsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.MachineLearningRun(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.MachineLearningRun(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.MachineLearningRun(), + ), + ]; + client.descriptors.page.listMachineLearningRuns.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listMachineLearningRunsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.hypercomputecluster.v1alpha.MachineLearningRun[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.hypercomputecluster.v1alpha.MachineLearningRun, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + ( + client.descriptors.page.listMachineLearningRuns + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.listMachineLearningRuns, request), + ); + assert( + ( + client.descriptors.page.listMachineLearningRuns + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - describe('profileSession', async () => { - const fakePath = "/rendered/path/profileSession"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - machine_learning_run: "machineLearningRunValue", - profile_session: "profileSessionValue", - }; - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.profileSessionPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.profileSessionPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('profileSessionPath', () => { - const result = client.profileSessionPath("projectValue", "locationValue", "machineLearningRunValue", "profileSessionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.profileSessionPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes listMachineLearningRunsStream with error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ListMachineLearningRunsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.ListMachineLearningRunsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listMachineLearningRuns.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listMachineLearningRunsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.hypercomputecluster.v1alpha.MachineLearningRun[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.hypercomputecluster.v1alpha.MachineLearningRun, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + ( + client.descriptors.page.listMachineLearningRuns + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.listMachineLearningRuns, request), + ); + assert( + ( + client.descriptors.page.listMachineLearningRuns + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('matchProjectFromProfileSessionName', () => { - const result = client.matchProjectFromProfileSessionName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.profileSessionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('uses async iteration with listMachineLearningRuns without error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ListMachineLearningRunsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.ListMachineLearningRunsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.MachineLearningRun(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.MachineLearningRun(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.MachineLearningRun(), + ), + ]; + client.descriptors.page.listMachineLearningRuns.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun[] = + []; + const iterable = client.listMachineLearningRunsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listMachineLearningRuns + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listMachineLearningRuns + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('matchLocationFromProfileSessionName', () => { - const result = client.matchLocationFromProfileSessionName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.profileSessionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('uses async iteration with listMachineLearningRuns with error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ListMachineLearningRunsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.ListMachineLearningRunsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listMachineLearningRuns.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listMachineLearningRunsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.hypercomputecluster.v1alpha.IMachineLearningRun[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listMachineLearningRuns + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listMachineLearningRuns + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + + describe('listProfilerTargets', () => { + it('invokes listProfilerTargets without error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ListProfilerTargetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.ListProfilerTargetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ProfilerTarget(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ProfilerTarget(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ProfilerTarget(), + ), + ]; + client.innerApiCalls.listProfilerTargets = + stubSimpleCall(expectedResponse); + const [response] = await client.listProfilerTargets(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listProfilerTargets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProfilerTargets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchMachineLearningRunFromProfileSessionName', () => { - const result = client.matchMachineLearningRunFromProfileSessionName(fakePath); - assert.strictEqual(result, "machineLearningRunValue"); - assert((client.pathTemplates.profileSessionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes listProfilerTargets without error using callback', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ListProfilerTargetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.ListProfilerTargetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ProfilerTarget(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ProfilerTarget(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ProfilerTarget(), + ), + ]; + client.innerApiCalls.listProfilerTargets = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProfilerTargets( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.hypercomputecluster.v1alpha.IProfilerTarget[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listProfilerTargets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProfilerTargets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchProfileSessionFromProfileSessionName', () => { - const result = client.matchProfileSessionFromProfileSessionName(fakePath); - assert.strictEqual(result, "profileSessionValue"); - assert((client.pathTemplates.profileSessionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('invokes listProfilerTargets with error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ListProfilerTargetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.ListProfilerTargetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listProfilerTargets = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listProfilerTargets(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listProfilerTargets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProfilerTargets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('profilerSession', async () => { - const fakePath = "/rendered/path/profilerSession"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - machine_learning_run: "machineLearningRunValue", - profiler_session: "profilerSessionValue", - }; - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.profilerSessionPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.profilerSessionPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('profilerSessionPath', () => { - const result = client.profilerSessionPath("projectValue", "locationValue", "machineLearningRunValue", "profilerSessionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.profilerSessionPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes listProfilerTargetsStream without error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ListProfilerTargetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.ListProfilerTargetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ProfilerTarget(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ProfilerTarget(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ProfilerTarget(), + ), + ]; + client.descriptors.page.listProfilerTargets.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listProfilerTargetsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.hypercomputecluster.v1alpha.ProfilerTarget[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.hypercomputecluster.v1alpha.ProfilerTarget, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listProfilerTargets.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listProfilerTargets, request), + ); + assert( + (client.descriptors.page.listProfilerTargets.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('matchProjectFromProfilerSessionName', () => { - const result = client.matchProjectFromProfilerSessionName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.profilerSessionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes listProfilerTargetsStream with error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ListProfilerTargetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.ListProfilerTargetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProfilerTargets.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listProfilerTargetsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.hypercomputecluster.v1alpha.ProfilerTarget[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.hypercomputecluster.v1alpha.ProfilerTarget, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listProfilerTargets.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listProfilerTargets, request), + ); + assert( + (client.descriptors.page.listProfilerTargets.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('matchLocationFromProfilerSessionName', () => { - const result = client.matchLocationFromProfilerSessionName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.profilerSessionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('uses async iteration with listProfilerTargets without error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ListProfilerTargetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.ListProfilerTargetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ProfilerTarget(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ProfilerTarget(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ProfilerTarget(), + ), + ]; + client.descriptors.page.listProfilerTargets.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.hypercomputecluster.v1alpha.IProfilerTarget[] = + []; + const iterable = client.listProfilerTargetsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listProfilerTargets.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listProfilerTargets.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('matchMachineLearningRunFromProfilerSessionName', () => { - const result = client.matchMachineLearningRunFromProfilerSessionName(fakePath); - assert.strictEqual(result, "machineLearningRunValue"); - assert((client.pathTemplates.profilerSessionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('uses async iteration with listProfilerTargets with error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ListProfilerTargetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.ListProfilerTargetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProfilerTargets.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listProfilerTargetsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.hypercomputecluster.v1alpha.IProfilerTarget[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listProfilerTargets.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listProfilerTargets.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listProfilerSessions', () => { + it('invokes listProfilerSessions without error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ListProfilerSessionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.ListProfilerSessionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ProfilerSession(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ProfilerSession(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ProfilerSession(), + ), + ]; + client.innerApiCalls.listProfilerSessions = + stubSimpleCall(expectedResponse); + const [response] = await client.listProfilerSessions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listProfilerSessions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProfilerSessions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchProfilerSessionFromProfilerSessionName', () => { - const result = client.matchProfilerSessionFromProfilerSessionName(fakePath); - assert.strictEqual(result, "profilerSessionValue"); - assert((client.pathTemplates.profilerSessionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('invokes listProfilerSessions without error using callback', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ListProfilerSessionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.ListProfilerSessionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ProfilerSession(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ProfilerSession(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ProfilerSession(), + ), + ]; + client.innerApiCalls.listProfilerSessions = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProfilerSessions( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.hypercomputecluster.v1alpha.IProfilerSession[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listProfilerSessions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProfilerSessions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('profilerTarget', async () => { - const fakePath = "/rendered/path/profilerTarget"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - machine_learning_run: "machineLearningRunValue", - profiler_target: "profilerTargetValue", - }; - const client = new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.profilerTargetPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.profilerTargetPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('profilerTargetPath', () => { - const result = client.profilerTargetPath("projectValue", "locationValue", "machineLearningRunValue", "profilerTargetValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.profilerTargetPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes listProfilerSessions with error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ListProfilerSessionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.ListProfilerSessionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listProfilerSessions = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listProfilerSessions(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listProfilerSessions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProfilerSessions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchProjectFromProfilerTargetName', () => { - const result = client.matchProjectFromProfilerTargetName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.profilerTargetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes listProfilerSessionsStream without error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ListProfilerSessionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.ListProfilerSessionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ProfilerSession(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ProfilerSession(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ProfilerSession(), + ), + ]; + client.descriptors.page.listProfilerSessions.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listProfilerSessionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.hypercomputecluster.v1alpha.ProfilerSession[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.hypercomputecluster.v1alpha.ProfilerSession, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listProfilerSessions.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listProfilerSessions, request), + ); + assert( + (client.descriptors.page.listProfilerSessions.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('matchLocationFromProfilerTargetName', () => { - const result = client.matchLocationFromProfilerTargetName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.profilerTargetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes listProfilerSessionsStream with error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ListProfilerSessionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.ListProfilerSessionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProfilerSessions.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listProfilerSessionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.hypercomputecluster.v1alpha.ProfilerSession[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.hypercomputecluster.v1alpha.ProfilerSession, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listProfilerSessions.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listProfilerSessions, request), + ); + assert( + (client.descriptors.page.listProfilerSessions.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('matchMachineLearningRunFromProfilerTargetName', () => { - const result = client.matchMachineLearningRunFromProfilerTargetName(fakePath); - assert.strictEqual(result, "machineLearningRunValue"); - assert((client.pathTemplates.profilerTargetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('uses async iteration with listProfilerSessions without error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ListProfilerSessionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.ListProfilerSessionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ProfilerSession(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ProfilerSession(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ProfilerSession(), + ), + ]; + client.descriptors.page.listProfilerSessions.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.hypercomputecluster.v1alpha.IProfilerSession[] = + []; + const iterable = client.listProfilerSessionsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listProfilerSessions.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listProfilerSessions.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('matchProfilerTargetFromProfilerTargetName', () => { - const result = client.matchProfilerTargetFromProfilerTargetName(fakePath); - assert.strictEqual(result, "profilerTargetValue"); - assert((client.pathTemplates.profilerTargetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('uses async iteration with listProfilerSessions with error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ListProfilerSessionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.ListProfilerSessionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProfilerSessions.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listProfilerSessionsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.hypercomputecluster.v1alpha.IProfilerSession[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listProfilerSessions.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listProfilerSessions.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listProfileSessions', () => { + it('invokes listProfileSessions without error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const stub = sinon.stub(client, 'warn'); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ListProfileSessionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.ListProfileSessionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ProfileSession(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ProfileSession(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ProfileSession(), + ), + ]; + client.innerApiCalls.listProfileSessions = + stubSimpleCall(expectedResponse); + const [response] = await client.listProfileSessions(request); + assert(stub.calledOnce); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listProfileSessions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProfileSessions 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 machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ - 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 listProfileSessions without error using callback', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const stub = sinon.stub(client, 'warn'); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ListProfileSessionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.ListProfileSessionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ProfileSession(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ProfileSession(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ProfileSession(), + ), + ]; + client.innerApiCalls.listProfileSessions = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProfileSessions( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.hypercomputecluster.v1alpha.IProfileSession[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert(stub.calledOnce); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listProfileSessions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProfileSessions 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 listProfileSessions with error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const stub = sinon.stub(client, 'warn'); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ListProfileSessionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.ListProfileSessionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listProfileSessions = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listProfileSessions(request), expectedError); + assert(stub.calledOnce); + const actualRequest = ( + client.innerApiCalls.listProfileSessions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProfileSessions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listProfileSessionsStream without error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const stub = sinon.stub(client, 'warn'); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ListProfileSessionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.ListProfileSessionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ProfileSession(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ProfileSession(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ProfileSession(), + ), + ]; + client.descriptors.page.listProfileSessions.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listProfileSessionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.hypercomputecluster.v1alpha.ProfileSession[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.hypercomputecluster.v1alpha.ProfileSession, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert(stub.calledOnce); + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listProfileSessions.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listProfileSessions, request), + ); + assert( + (client.descriptors.page.listProfileSessions.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + + it('invokes listProfileSessionsStream with error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const stub = sinon.stub(client, 'warn'); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ListProfileSessionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.ListProfileSessionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProfileSessions.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listProfileSessionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.hypercomputecluster.v1alpha.ProfileSession[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.hypercomputecluster.v1alpha.ProfileSession, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert(stub.calledOnce); + assert( + (client.descriptors.page.listProfileSessions.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listProfileSessions, request), + ); + assert( + (client.descriptors.page.listProfileSessions.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + + it('uses async iteration with listProfileSessions without error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const stub = sinon.stub(client, 'warn'); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ListProfileSessionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.ListProfileSessionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ProfileSession(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ProfileSession(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ProfileSession(), + ), + ]; + client.descriptors.page.listProfileSessions.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.hypercomputecluster.v1alpha.IProfileSession[] = + []; + const iterable = client.listProfileSessionsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert(stub.calledOnce); + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listProfileSessions.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listProfileSessions.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + + it('uses async iteration with listProfileSessions with error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + const stub = sinon.stub(client, 'warn'); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ListProfileSessionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.ListProfileSessionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProfileSessions.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listProfileSessionsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.hypercomputecluster.v1alpha.IProfileSession[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert(stub.calledOnce); + assert.deepStrictEqual( + ( + client.descriptors.page.listProfileSessions.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listProfileSessions.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listMonitoredEvents', () => { + it('invokes listMonitoredEvents without error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ListMonitoredEventsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.ListMonitoredEventsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.MonitoredEvent(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.MonitoredEvent(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.MonitoredEvent(), + ), + ]; + client.innerApiCalls.listMonitoredEvents = + stubSimpleCall(expectedResponse); + const [response] = await client.listMonitoredEvents(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listMonitoredEvents as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMonitoredEvents as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listMonitoredEvents without error using callback', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ListMonitoredEventsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.ListMonitoredEventsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.MonitoredEvent(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.MonitoredEvent(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.MonitoredEvent(), + ), + ]; + client.innerApiCalls.listMonitoredEvents = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listMonitoredEvents( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listMonitoredEvents as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMonitoredEvents as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listMonitoredEvents with error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ListMonitoredEventsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.ListMonitoredEventsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listMonitoredEvents = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listMonitoredEvents(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listMonitoredEvents as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listMonitoredEvents as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listMonitoredEventsStream without error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ListMonitoredEventsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.ListMonitoredEventsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.MonitoredEvent(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.MonitoredEvent(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.MonitoredEvent(), + ), + ]; + client.descriptors.page.listMonitoredEvents.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listMonitoredEventsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.hypercomputecluster.v1alpha.MonitoredEvent[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.hypercomputecluster.v1alpha.MonitoredEvent, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listMonitoredEvents.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listMonitoredEvents, request), + ); + assert( + (client.descriptors.page.listMonitoredEvents.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + + it('invokes listMonitoredEventsStream with error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ListMonitoredEventsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.ListMonitoredEventsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listMonitoredEvents.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listMonitoredEventsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.hypercomputecluster.v1alpha.MonitoredEvent[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.hypercomputecluster.v1alpha.MonitoredEvent, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listMonitoredEvents.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listMonitoredEvents, request), + ); + assert( + (client.descriptors.page.listMonitoredEvents.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + + it('uses async iteration with listMonitoredEvents without error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ListMonitoredEventsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.ListMonitoredEventsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.MonitoredEvent(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.MonitoredEvent(), + ), + generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.MonitoredEvent(), + ), + ]; + client.descriptors.page.listMonitoredEvents.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent[] = + []; + const iterable = client.listMonitoredEventsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listMonitoredEvents.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listMonitoredEvents.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + + it('uses async iteration with listMonitoredEvents with error', async () => { + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.hypercomputecluster.v1alpha.ListMonitoredEventsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.hypercomputecluster.v1alpha.ListMonitoredEventsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listMonitoredEvents.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listMonitoredEventsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.hypercomputecluster.v1alpha.IMonitoredEvent[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listMonitoredEvents.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listMonitoredEvents.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 machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + 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 machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + 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 machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + 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 machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + 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 machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + 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 machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + 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 machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + 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 machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + 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 machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + 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 machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + 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 machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + 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 machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + 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 machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + 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 machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + 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 machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + 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 machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + 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('cluster', async () => { + const fakePath = '/rendered/path/cluster'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + cluster: 'clusterValue', + }; + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.clusterPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.clusterPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('clusterPath', () => { + const result = client.clusterPath( + 'projectValue', + 'locationValue', + 'clusterValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.clusterPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromClusterName', () => { + const result = client.matchProjectFromClusterName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.clusterPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromClusterName', () => { + const result = client.matchLocationFromClusterName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.clusterPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchClusterFromClusterName', () => { + const result = client.matchClusterFromClusterName(fakePath); + assert.strictEqual(result, 'clusterValue'); + assert( + (client.pathTemplates.clusterPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('location', async () => { + const fakePath = '/rendered/path/location'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + 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('machineLearningRun', async () => { + const fakePath = '/rendered/path/machineLearningRun'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + machine_learning_run: 'machineLearningRunValue', + }; + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.machineLearningRunPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.machineLearningRunPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('machineLearningRunPath', () => { + const result = client.machineLearningRunPath( + 'projectValue', + 'locationValue', + 'machineLearningRunValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.machineLearningRunPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromMachineLearningRunName', () => { + const result = client.matchProjectFromMachineLearningRunName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.machineLearningRunPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromMachineLearningRunName', () => { + const result = client.matchLocationFromMachineLearningRunName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.machineLearningRunPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchMachineLearningRunFromMachineLearningRunName', () => { + const result = + client.matchMachineLearningRunFromMachineLearningRunName(fakePath); + assert.strictEqual(result, 'machineLearningRunValue'); + assert( + ( + client.pathTemplates.machineLearningRunPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('monitoredEvent', async () => { + const fakePath = '/rendered/path/monitoredEvent'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + machine_learning_run: 'machineLearningRunValue', + monitored_event: 'monitoredEventValue', + }; + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.monitoredEventPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.monitoredEventPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('monitoredEventPath', () => { + const result = client.monitoredEventPath( + 'projectValue', + 'locationValue', + 'machineLearningRunValue', + 'monitoredEventValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.monitoredEventPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromMonitoredEventName', () => { + const result = client.matchProjectFromMonitoredEventName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.monitoredEventPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromMonitoredEventName', () => { + const result = client.matchLocationFromMonitoredEventName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.monitoredEventPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchMachineLearningRunFromMonitoredEventName', () => { + const result = + client.matchMachineLearningRunFromMonitoredEventName(fakePath); + assert.strictEqual(result, 'machineLearningRunValue'); + assert( + (client.pathTemplates.monitoredEventPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchMonitoredEventFromMonitoredEventName', () => { + const result = + client.matchMonitoredEventFromMonitoredEventName(fakePath); + assert.strictEqual(result, 'monitoredEventValue'); + assert( + (client.pathTemplates.monitoredEventPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('node', async () => { + const fakePath = '/rendered/path/node'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + cluster: 'clusterValue', + node: 'nodeValue', + }; + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.nodePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.nodePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('nodePath', () => { + const result = client.nodePath( + 'projectValue', + 'locationValue', + 'clusterValue', + 'nodeValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.nodePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromNodeName', () => { + const result = client.matchProjectFromNodeName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.nodePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromNodeName', () => { + const result = client.matchLocationFromNodeName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.nodePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchClusterFromNodeName', () => { + const result = client.matchClusterFromNodeName(fakePath); + assert.strictEqual(result, 'clusterValue'); + assert( + (client.pathTemplates.nodePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchNodeFromNodeName', () => { + const result = client.matchNodeFromNodeName(fakePath); + assert.strictEqual(result, 'nodeValue'); + assert( + (client.pathTemplates.nodePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('profileSession', async () => { + const fakePath = '/rendered/path/profileSession'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + machine_learning_run: 'machineLearningRunValue', + profile_session: 'profileSessionValue', + }; + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.profileSessionPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.profileSessionPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('profileSessionPath', () => { + const result = client.profileSessionPath( + 'projectValue', + 'locationValue', + 'machineLearningRunValue', + 'profileSessionValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.profileSessionPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProfileSessionName', () => { + const result = client.matchProjectFromProfileSessionName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.profileSessionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromProfileSessionName', () => { + const result = client.matchLocationFromProfileSessionName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.profileSessionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchMachineLearningRunFromProfileSessionName', () => { + const result = + client.matchMachineLearningRunFromProfileSessionName(fakePath); + assert.strictEqual(result, 'machineLearningRunValue'); + assert( + (client.pathTemplates.profileSessionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchProfileSessionFromProfileSessionName', () => { + const result = + client.matchProfileSessionFromProfileSessionName(fakePath); + assert.strictEqual(result, 'profileSessionValue'); + assert( + (client.pathTemplates.profileSessionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('profilerSession', async () => { + const fakePath = '/rendered/path/profilerSession'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + machine_learning_run: 'machineLearningRunValue', + profiler_session: 'profilerSessionValue', + }; + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.profilerSessionPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.profilerSessionPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('profilerSessionPath', () => { + const result = client.profilerSessionPath( + 'projectValue', + 'locationValue', + 'machineLearningRunValue', + 'profilerSessionValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.profilerSessionPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProfilerSessionName', () => { + const result = client.matchProjectFromProfilerSessionName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.profilerSessionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromProfilerSessionName', () => { + const result = client.matchLocationFromProfilerSessionName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.profilerSessionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchMachineLearningRunFromProfilerSessionName', () => { + const result = + client.matchMachineLearningRunFromProfilerSessionName(fakePath); + assert.strictEqual(result, 'machineLearningRunValue'); + assert( + (client.pathTemplates.profilerSessionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchProfilerSessionFromProfilerSessionName', () => { + const result = + client.matchProfilerSessionFromProfilerSessionName(fakePath); + assert.strictEqual(result, 'profilerSessionValue'); + assert( + (client.pathTemplates.profilerSessionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('profilerTarget', async () => { + const fakePath = '/rendered/path/profilerTarget'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + machine_learning_run: 'machineLearningRunValue', + profiler_target: 'profilerTargetValue', + }; + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.profilerTargetPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.profilerTargetPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('profilerTargetPath', () => { + const result = client.profilerTargetPath( + 'projectValue', + 'locationValue', + 'machineLearningRunValue', + 'profilerTargetValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.profilerTargetPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProfilerTargetName', () => { + const result = client.matchProjectFromProfilerTargetName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.profilerTargetPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromProfilerTargetName', () => { + const result = client.matchLocationFromProfilerTargetName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.profilerTargetPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchMachineLearningRunFromProfilerTargetName', () => { + const result = + client.matchMachineLearningRunFromProfilerTargetName(fakePath); + assert.strictEqual(result, 'machineLearningRunValue'); + assert( + (client.pathTemplates.profilerTargetPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchProfilerTargetFromProfilerTargetName', () => { + const result = + client.matchProfilerTargetFromProfilerTargetName(fakePath); + assert.strictEqual(result, 'profilerTargetValue'); + assert( + (client.pathTemplates.profilerTargetPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('project', async () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = + new machinelearningrunsModule.v1alpha.MachineLearningRunsClient({ + 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-hypercomputecluster/webpack.config.js b/packages/google-cloud-hypercomputecluster/webpack.config.js index cb75b8519f72..0ad64201ae58 100644 --- a/packages/google-cloud-hypercomputecluster/webpack.config.js +++ b/packages/google-cloud-hypercomputecluster/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-iap/.eslintignore b/packages/google-cloud-iap/.eslintignore new file mode 100644 index 000000000000..cfc348ec4d11 --- /dev/null +++ b/packages/google-cloud-iap/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/packages/google-cloud-iap/.eslintrc.json b/packages/google-cloud-iap/.eslintrc.json new file mode 100644 index 000000000000..3e8d97ccb390 --- /dev/null +++ b/packages/google-cloud-iap/.eslintrc.json @@ -0,0 +1,4 @@ +{ + "extends": "./node_modules/gts", + "root": true +} diff --git a/packages/google-cloud-iap/README.md b/packages/google-cloud-iap/README.md index c4a785288f91..c5cfd5674cf3 100644 --- a/packages/google-cloud-iap/README.md +++ b/packages/google-cloud-iap/README.md @@ -115,7 +115,7 @@ More Information: [Google Cloud Platform Launch Stages][launch_stages] ## Contributing -Contributions welcome! See the [Contributing Guide](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-iap/CONTRIBUTING.md). +Contributions welcome! See the [Contributing Guide](https://github.com/googleapis/google-cloud-node/blob/main/CONTRIBUTING.md). Please note that this `README.md` and a variety of configuration files in this repository (including `.nycrc` and `tsconfig.json`) @@ -125,7 +125,7 @@ are generated from a central template. Apache Version 2.0 -See [LICENSE](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-iap/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-iap/protos/protos.d.ts b/packages/google-cloud-iap/protos/protos.d.ts index a85e587a6bd5..abda27de97d0 100644 --- a/packages/google-cloud-iap/protos/protos.d.ts +++ b/packages/google-cloud-iap/protos/protos.d.ts @@ -4739,6 +4739,9 @@ export namespace google { /** CommonLanguageSettings destinations */ destinations?: (google.api.ClientLibraryDestination[]|null); + + /** CommonLanguageSettings selectiveGapicGeneration */ + selectiveGapicGeneration?: (google.api.ISelectiveGapicGeneration|null); } /** Represents a CommonLanguageSettings. */ @@ -4756,6 +4759,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 @@ -5456,6 +5462,9 @@ export namespace google { /** PythonSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** PythonSettings experimentalFeatures */ + experimentalFeatures?: (google.api.PythonSettings.IExperimentalFeatures|null); } /** Represents a PythonSettings. */ @@ -5470,6 +5479,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 @@ -5548,6 +5560,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 { @@ -5874,6 +5998,9 @@ export namespace google { /** GoSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** GoSettings renamedServices */ + renamedServices?: ({ [k: string]: string }|null); } /** Represents a GoSettings. */ @@ -5888,6 +6015,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 @@ -6212,6 +6342,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, @@ -6593,6 +6826,7 @@ export namespace google { /** Edition enum. */ enum Edition { EDITION_UNKNOWN = 0, + EDITION_LEGACY = 900, EDITION_PROTO2 = 998, EDITION_PROTO3 = 999, EDITION_2023 = 1000, @@ -6623,6 +6857,9 @@ export namespace google { /** FileDescriptorProto weakDependency */ weakDependency?: (number[]|null); + /** FileDescriptorProto optionDependency */ + optionDependency?: (string[]|null); + /** FileDescriptorProto messageType */ messageType?: (google.protobuf.IDescriptorProto[]|null); @@ -6672,6 +6909,9 @@ export namespace google { /** FileDescriptorProto weakDependency. */ public weakDependency: number[]; + /** FileDescriptorProto optionDependency. */ + public optionDependency: string[]; + /** FileDescriptorProto messageType. */ public messageType: google.protobuf.IDescriptorProto[]; @@ -6806,6 +7046,9 @@ export namespace google { /** DescriptorProto reservedName */ reservedName?: (string[]|null); + + /** DescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents a DescriptorProto. */ @@ -6847,6 +7090,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 @@ -7694,6 +7940,9 @@ export namespace google { /** EnumDescriptorProto reservedName */ reservedName?: (string[]|null); + + /** EnumDescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents an EnumDescriptorProto. */ @@ -7720,6 +7969,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 @@ -8654,6 +8906,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); @@ -8709,6 +8964,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[]; @@ -8929,6 +9187,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. */ @@ -9167,6 +9540,9 @@ export namespace google { /** EnumValueOptions debugRedact */ debugRedact?: (boolean|null); + /** EnumValueOptions featureSupport */ + featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** EnumValueOptions uninterpretedOption */ uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); } @@ -9189,6 +9565,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[]; @@ -9778,6 +10157,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. */ @@ -9807,6 +10192,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 @@ -9929,6 +10320,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. */ @@ -10048,8 +10549,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. */ @@ -10064,8 +10568,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. @@ -10598,6 +11105,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-iap/protos/protos.js b/packages/google-cloud-iap/protos/protos.js index ac8c34babb4b..ad7e0192141c 100644 --- a/packages/google-cloud-iap/protos/protos.js +++ b/packages/google-cloud-iap/protos/protos.js @@ -10928,6 +10928,7 @@ * @interface ICommonLanguageSettings * @property {string|null} [referenceDocsUri] CommonLanguageSettings referenceDocsUri * @property {Array.|null} [destinations] CommonLanguageSettings destinations + * @property {google.api.ISelectiveGapicGeneration|null} [selectiveGapicGeneration] CommonLanguageSettings selectiveGapicGeneration */ /** @@ -10962,6 +10963,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 @@ -10994,6 +11003,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; }; @@ -11045,6 +11056,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; @@ -11096,6 +11111,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; }; @@ -11138,6 +11158,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; }; @@ -11156,8 +11181,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) { @@ -11165,6 +11192,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; }; @@ -12987,6 +13016,7 @@ * @memberof google.api * @interface IPythonSettings * @property {google.api.ICommonLanguageSettings|null} [common] PythonSettings common + * @property {google.api.PythonSettings.IExperimentalFeatures|null} [experimentalFeatures] PythonSettings experimentalFeatures */ /** @@ -13012,6 +13042,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 @@ -13038,6 +13076,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; }; @@ -13078,6 +13118,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; @@ -13118,6 +13162,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; }; @@ -13138,6 +13187,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; }; @@ -13154,10 +13208,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; }; @@ -13187,6 +13245,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; })(); @@ -14063,6 +14373,7 @@ * @memberof google.api * @interface IGoSettings * @property {google.api.ICommonLanguageSettings|null} [common] GoSettings common + * @property {Object.|null} [renamedServices] GoSettings renamedServices */ /** @@ -14074,6 +14385,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) @@ -14088,6 +14400,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 @@ -14114,6 +14434,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; }; @@ -14144,7 +14467,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) @@ -14154,6 +14477,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; @@ -14194,6 +14540,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; }; @@ -14214,6 +14568,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; }; @@ -14230,10 +14591,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; }; @@ -14872,30 +15241,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; })(); /** @@ -15857,6 +16471,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 @@ -15871,6 +16486,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; @@ -15895,6 +16511,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 @@ -15917,6 +16534,7 @@ this.dependency = []; this.publicDependency = []; this.weakDependency = []; + this.optionDependency = []; this.messageType = []; this.enumType = []; this.service = []; @@ -15967,6 +16585,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 @@ -16088,6 +16714,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; }; @@ -16160,6 +16789,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 = []; @@ -16262,6 +16897,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"; @@ -16316,6 +16958,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -16368,6 +17011,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"); @@ -16431,6 +17081,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -16496,6 +17150,7 @@ object.extension = []; object.publicDependency = []; object.weakDependency = []; + object.optionDependency = []; } if (options.defaults) { object.name = ""; @@ -16552,6 +17207,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; }; @@ -16600,6 +17260,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 */ /** @@ -16705,6 +17366,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 @@ -16757,6 +17426,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; }; @@ -16849,6 +17520,10 @@ message.reservedName.push(reader.string()); break; } + case 11: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -16962,6 +17637,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; }; @@ -17061,6 +17745,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; }; @@ -17090,6 +17794,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; @@ -17135,6 +17840,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; }; @@ -19179,6 +19886,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 */ /** @@ -19239,6 +19947,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 @@ -19276,6 +19992,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; }; @@ -19338,6 +20056,10 @@ message.reservedName.push(reader.string()); break; } + case 6: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -19406,6 +20128,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; }; @@ -19455,6 +20186,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; }; @@ -19479,6 +20230,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; @@ -19499,6 +20251,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; }; @@ -21817,6 +22571,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 @@ -21937,6 +22692,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 @@ -22011,6 +22774,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(); @@ -22112,6 +22877,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 = []; @@ -22247,6 +23016,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"; @@ -22435,6 +23209,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"); @@ -22532,6 +23311,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")) @@ -22564,6 +23344,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) @@ -22836,6 +23618,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -22877,103 +23660,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; @@ -23568,6 +24837,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 */ @@ -23611,6 +24881,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 @@ -23649,6 +24927,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(); @@ -23700,6 +24980,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 = []; @@ -23752,6 +25036,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"; @@ -23785,6 +25074,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"); @@ -23817,6 +25111,7 @@ object.deprecated = false; object.features = null; object.debugRedact = false; + object.featureSupport = null; } if (message.deprecated != null && message.hasOwnProperty("deprecated")) object.deprecated = message.deprecated; @@ -23824,6 +25119,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) @@ -25263,6 +26560,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 */ /** @@ -25328,6 +26627,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 @@ -25364,6 +26679,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; }; @@ -25424,6 +26743,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; @@ -25514,6 +26841,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; }; @@ -25653,6 +27000,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; }; @@ -25676,6 +27071,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; @@ -25689,6 +27086,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; }; @@ -25816,6 +27217,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; })(); @@ -26000,6 +27614,7 @@ default: return "minimumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -26017,6 +27632,7 @@ default: return "maximumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -26065,6 +27681,10 @@ case 0: message.minimumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.minimumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.minimumEdition = 998; @@ -26117,6 +27737,10 @@ case 0: message.maximumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.maximumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.maximumEdition = 998; @@ -26225,7 +27849,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 */ /** @@ -26252,12 +27877,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. @@ -26283,10 +27916,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; }; @@ -26327,8 +27962,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: @@ -26371,6 +28010,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -26383,10 +28023,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; }; @@ -26414,6 +28059,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -26455,10 +28104,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; }; @@ -26477,13 +28131,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; }; @@ -27698,6 +29355,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-iap/protos/protos.json b/packages/google-cloud-iap/protos/protos.json index aa37e98d6a1f..73a2e0a149ea 100644 --- a/packages/google-cloud-iap/protos/protos.json +++ b/packages/google-cloud-iap/protos/protos.json @@ -1142,8 +1142,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": { @@ -1267,6 +1266,10 @@ "rule": "repeated", "type": "ClientLibraryDestination", "id": 2 + }, + "selectiveGapicGeneration": { + "type": "SelectiveGapicGeneration", + "id": 3 } } }, @@ -1407,6 +1410,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 + } + } } } }, @@ -1464,6 +1489,11 @@ "common": { "type": "CommonLanguageSettings", "id": 1 + }, + "renamedServices": { + "keyType": "string", + "type": "string", + "id": 2 } } }, @@ -1525,6 +1555,19 @@ "PACKAGE_MANAGER": 20 } }, + "SelectiveGapicGeneration": { + "fields": { + "methods": { + "rule": "repeated", + "type": "string", + "id": 1 + }, + "generateOmittedAsInternal": { + "type": "bool", + "id": 2 + } + } + }, "LaunchStage": { "values": { "LAUNCH_STAGE_UNSPECIFIED": 0, @@ -1657,12 +1700,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, @@ -1701,6 +1751,11 @@ "type": "int32", "id": 11 }, + "optionDependency": { + "rule": "repeated", + "type": "string", + "id": 15 + }, "messageType": { "rule": "repeated", "type": "DescriptorProto", @@ -1789,6 +1844,10 @@ "rule": "repeated", "type": "string", "id": 10 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 11 } }, "nested": { @@ -2014,6 +2073,10 @@ "rule": "repeated", "type": "string", "id": 5 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 6 } }, "nested": { @@ -2064,7 +2127,14 @@ "type": "ServiceOptions", "id": 3 } - } + }, + "reserved": [ + [ + 4, + 4 + ], + "stream" + ] }, "MethodDescriptorProto": { "edition": "proto2", @@ -2228,6 +2298,7 @@ 42, 42 ], + "php_generic_services", [ 38, 38 @@ -2363,7 +2434,8 @@ "type": "bool", "id": 10, "options": { - "default": false + "default": false, + "deprecated": true } }, "debugRedact": { @@ -2391,6 +2463,10 @@ "type": "FeatureSet", "id": 21 }, + "featureSupport": { + "type": "FeatureSupport", + "id": 22 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -2460,6 +2536,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 + } + } } } }, @@ -2548,6 +2644,10 @@ "default": false } }, + "featureSupport": { + "type": "FieldOptions.FeatureSupport", + "id": 4 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -2690,6 +2790,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_2023", "edition_defaults.value": "EXPLICIT" } @@ -2700,6 +2801,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "OPEN" } @@ -2710,6 +2812,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "PACKED" } @@ -2720,6 +2823,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "VERIFY" } @@ -2730,7 +2834,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" } }, @@ -2740,27 +2845,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, @@ -2805,7 +2921,13 @@ "UTF8_VALIDATION_UNKNOWN": 0, "VERIFY": 2, "NONE": 3 - } + }, + "reserved": [ + [ + 1, + 1 + ] + ] }, "MessageEncoding": { "values": { @@ -2820,6 +2942,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 + } + } + } } } }, @@ -2847,11 +2996,26 @@ "type": "Edition", "id": 3 }, - "features": { + "overridableFeatures": { "type": "FeatureSet", - "id": 2 + "id": 4 + }, + "fixedFeatures": { + "type": "FeatureSet", + "id": 5 } - } + }, + "reserved": [ + [ + 1, + 1 + ], + [ + 2, + 2 + ], + "features" + ] } } }, @@ -2864,6 +3028,12 @@ "id": 1 } }, + "extensions": [ + [ + 536000000, + 536000000 + ] + ], "nested": { "Location": { "fields": { @@ -2949,6 +3119,14 @@ } } }, + "SymbolVisibility": { + "edition": "proto2", + "values": { + "VISIBILITY_UNSET": 0, + "VISIBILITY_LOCAL": 1, + "VISIBILITY_EXPORT": 2 + } + }, "Duration": { "fields": { "seconds": { @@ -3051,13 +3229,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-iap/samples/generated/v1/snippet_metadata_google.cloud.iap.v1.json b/packages/google-cloud-iap/samples/generated/v1/snippet_metadata_google.cloud.iap.v1.json index 76d40c8e7b28..3e66b88348b4 100644 --- a/packages/google-cloud-iap/samples/generated/v1/snippet_metadata_google.cloud.iap.v1.json +++ b/packages/google-cloud-iap/samples/generated/v1/snippet_metadata_google.cloud.iap.v1.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-iap", - "version": "4.4.0", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-iap/samples/generated/v1beta1/snippet_metadata_google.cloud.iap.v1beta1.json b/packages/google-cloud-iap/samples/generated/v1beta1/snippet_metadata_google.cloud.iap.v1beta1.json index 58baeb8c3081..a3dad3196325 100644 --- a/packages/google-cloud-iap/samples/generated/v1beta1/snippet_metadata_google.cloud.iap.v1beta1.json +++ b/packages/google-cloud-iap/samples/generated/v1beta1/snippet_metadata_google.cloud.iap.v1beta1.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-iap", - "version": "4.4.0", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-iap/src/v1/identity_aware_proxy_admin_service_client.ts b/packages/google-cloud-iap/src/v1/identity_aware_proxy_admin_service_client.ts index ad56d82eb19b..c5e748cb9001 100644 --- a/packages/google-cloud-iap/src/v1/identity_aware_proxy_admin_service_client.ts +++ b/packages/google-cloud-iap/src/v1/identity_aware_proxy_admin_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 IdentityAwareProxyAdminServiceClient { 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('iap'); @@ -57,9 +64,9 @@ export class IdentityAwareProxyAdminServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - identityAwareProxyAdminServiceStub?: Promise<{[name: string]: Function}>; + innerApiCalls: { [name: string]: Function }; + pathTemplates: { [name: string]: gax.PathTemplate }; + identityAwareProxyAdminServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of IdentityAwareProxyAdminServiceClient. @@ -100,21 +107,43 @@ export class IdentityAwareProxyAdminServiceClient { * const client = new IdentityAwareProxyAdminServiceClient({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 IdentityAwareProxyAdminServiceClient; - 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 IdentityAwareProxyAdminServiceClient; + 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 = 'iap.' + 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 IdentityAwareProxyAdminServiceClient { 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 IdentityAwareProxyAdminServiceClient { } // 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 +204,13 @@ export class IdentityAwareProxyAdminServiceClient { // Create useful helper objects for these. this.pathTemplates = { projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' + 'projects/{project}', ), tunnelDestGroupPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/iap_tunnel/locations/{location}/destGroups/{dest_group}' + 'projects/{project}/iap_tunnel/locations/{location}/destGroups/{dest_group}', ), tunnelLocationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/iap_tunnel/locations/{location}' + 'projects/{project}/iap_tunnel/locations/{location}', ), }; @@ -192,14 +218,20 @@ export class IdentityAwareProxyAdminServiceClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listTunnelDestGroups: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'tunnelDestGroups') + listTunnelDestGroups: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'tunnelDestGroups', + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.iap.v1.IdentityAwareProxyAdminService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.iap.v1.IdentityAwareProxyAdminService', + 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 +262,53 @@ export class IdentityAwareProxyAdminServiceClient { // Put together the "service stub" for // google.cloud.iap.v1.IdentityAwareProxyAdminService. this.identityAwareProxyAdminServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.iap.v1.IdentityAwareProxyAdminService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.iap.v1.IdentityAwareProxyAdminService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.iap.v1.IdentityAwareProxyAdminService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.iap.v1 + .IdentityAwareProxyAdminService, + 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 identityAwareProxyAdminServiceStubMethods = - ['setIamPolicy', 'getIamPolicy', 'testIamPermissions', 'getIapSettings', 'updateIapSettings', 'validateIapAttributeExpression', 'listTunnelDestGroups', 'createTunnelDestGroup', 'getTunnelDestGroup', 'deleteTunnelDestGroup', 'updateTunnelDestGroup']; + const identityAwareProxyAdminServiceStubMethods = [ + 'setIamPolicy', + 'getIamPolicy', + 'testIamPermissions', + 'getIapSettings', + 'updateIapSettings', + 'validateIapAttributeExpression', + 'listTunnelDestGroups', + 'createTunnelDestGroup', + 'getTunnelDestGroup', + 'deleteTunnelDestGroup', + 'updateTunnelDestGroup', + ]; for (const methodName of identityAwareProxyAdminServiceStubMethods) { const callPromise = this.identityAwareProxyAdminServiceStub.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 +323,14 @@ export class IdentityAwareProxyAdminServiceClient { * @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 'iap.googleapis.com'; } @@ -287,8 +341,14 @@ export class IdentityAwareProxyAdminServiceClient { * @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 'iap.googleapis.com'; } @@ -319,9 +379,7 @@ export class IdentityAwareProxyAdminServiceClient { * @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; @@ -330,8 +388,9 @@ export class IdentityAwareProxyAdminServiceClient { * 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; @@ -342,1106 +401,1494 @@ export class IdentityAwareProxyAdminServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Sets the access control policy for an Identity-Aware Proxy protected - * resource. Replaces any existing policy. - * More information about managing access via IAP can be found at: - * https://cloud.google.com/iap/docs/managing-access#managing_access_via_the_api - * - * @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/identity_aware_proxy_admin_service.set_iam_policy.js - * region_tag:iap_v1_generated_IdentityAwareProxyAdminService_SetIamPolicy_async - */ + /** + * Sets the access control policy for an Identity-Aware Proxy protected + * resource. Replaces any existing policy. + * More information about managing access via IAP can be found at: + * https://cloud.google.com/iap/docs/managing-access#managing_access_via_the_api + * + * @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/identity_aware_proxy_admin_service.set_iam_policy.js + * region_tag:iap_v1_generated_IdentityAwareProxyAdminService_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; }); } -/** - * Gets the access control policy for an Identity-Aware Proxy protected - * resource. - * More information about managing access via IAP can be found at: - * https://cloud.google.com/iap/docs/managing-access#managing_access_via_the_api - * - * @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/identity_aware_proxy_admin_service.get_iam_policy.js - * region_tag:iap_v1_generated_IdentityAwareProxyAdminService_GetIamPolicy_async - */ + /** + * Gets the access control policy for an Identity-Aware Proxy protected + * resource. + * More information about managing access via IAP can be found at: + * https://cloud.google.com/iap/docs/managing-access#managing_access_via_the_api + * + * @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/identity_aware_proxy_admin_service.get_iam_policy.js + * region_tag:iap_v1_generated_IdentityAwareProxyAdminService_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; }); } -/** - * Returns permissions that a caller has on the Identity-Aware Proxy protected - * resource. - * More information about managing access via IAP can be found at: - * https://cloud.google.com/iap/docs/managing-access#managing_access_via_the_api - * - * @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/identity_aware_proxy_admin_service.test_iam_permissions.js - * region_tag:iap_v1_generated_IdentityAwareProxyAdminService_TestIamPermissions_async - */ + /** + * Returns permissions that a caller has on the Identity-Aware Proxy protected + * resource. + * More information about managing access via IAP can be found at: + * https://cloud.google.com/iap/docs/managing-access#managing_access_via_the_api + * + * @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/identity_aware_proxy_admin_service.test_iam_permissions.js + * region_tag:iap_v1_generated_IdentityAwareProxyAdminService_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; }); } -/** - * Gets the IAP settings on a particular IAP protected resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name for which to retrieve the settings. - * Authorization: Requires the `getSettings` permission for the associated - * 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.iap.v1.IapSettings|IapSettings}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/identity_aware_proxy_admin_service.get_iap_settings.js - * region_tag:iap_v1_generated_IdentityAwareProxyAdminService_GetIapSettings_async - */ + /** + * Gets the IAP settings on a particular IAP protected resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name for which to retrieve the settings. + * Authorization: Requires the `getSettings` permission for the associated + * 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.iap.v1.IapSettings|IapSettings}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/identity_aware_proxy_admin_service.get_iap_settings.js + * region_tag:iap_v1_generated_IdentityAwareProxyAdminService_GetIapSettings_async + */ getIapSettings( - request?: protos.google.cloud.iap.v1.IGetIapSettingsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.iap.v1.IIapSettings, - protos.google.cloud.iap.v1.IGetIapSettingsRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.iap.v1.IGetIapSettingsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.iap.v1.IIapSettings, + protos.google.cloud.iap.v1.IGetIapSettingsRequest | undefined, + {} | undefined, + ] + >; getIapSettings( - request: protos.google.cloud.iap.v1.IGetIapSettingsRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.iap.v1.IIapSettings, - protos.google.cloud.iap.v1.IGetIapSettingsRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.iap.v1.IGetIapSettingsRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.iap.v1.IIapSettings, + protos.google.cloud.iap.v1.IGetIapSettingsRequest | null | undefined, + {} | null | undefined + >, + ): void; getIapSettings( - request: protos.google.cloud.iap.v1.IGetIapSettingsRequest, - callback: Callback< - protos.google.cloud.iap.v1.IIapSettings, - protos.google.cloud.iap.v1.IGetIapSettingsRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.iap.v1.IGetIapSettingsRequest, + callback: Callback< + protos.google.cloud.iap.v1.IIapSettings, + protos.google.cloud.iap.v1.IGetIapSettingsRequest | null | undefined, + {} | null | undefined + >, + ): void; getIapSettings( - request?: protos.google.cloud.iap.v1.IGetIapSettingsRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.iap.v1.IIapSettings, - protos.google.cloud.iap.v1.IGetIapSettingsRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.iap.v1.IGetIapSettingsRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.iap.v1.IIapSettings, - protos.google.cloud.iap.v1.IGetIapSettingsRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.iap.v1.IIapSettings, - protos.google.cloud.iap.v1.IGetIapSettingsRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.iap.v1.IGetIapSettingsRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.iap.v1.IIapSettings, + protos.google.cloud.iap.v1.IGetIapSettingsRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.iap.v1.IIapSettings, + protos.google.cloud.iap.v1.IGetIapSettingsRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getIapSettings request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.iap.v1.IIapSettings, - protos.google.cloud.iap.v1.IGetIapSettingsRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.iap.v1.IIapSettings, + protos.google.cloud.iap.v1.IGetIapSettingsRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getIapSettings response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getIapSettings(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.iap.v1.IIapSettings, - protos.google.cloud.iap.v1.IGetIapSettingsRequest|undefined, - {}|undefined - ]) => { - this._log.info('getIapSettings response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getIapSettings(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.iap.v1.IIapSettings, + protos.google.cloud.iap.v1.IGetIapSettingsRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getIapSettings response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 IAP settings on a particular IAP protected resource. It - * replaces all fields unless the `update_mask` is set. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.iap.v1.IapSettings} request.iapSettings - * Required. The new values for the IAP settings to be updated. - * Authorization: Requires the `updateSettings` permission for the associated - * resource. - * @param {google.protobuf.FieldMask} request.updateMask - * The field mask specifying which IAP settings should be updated. - * If omitted, then all of the settings are updated. See - * https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask. - * - * Note: All IAP reauth settings must always be set together, using the - * field mask: `iapSettings.accessSettings.reauthSettings`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.iap.v1.IapSettings|IapSettings}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/identity_aware_proxy_admin_service.update_iap_settings.js - * region_tag:iap_v1_generated_IdentityAwareProxyAdminService_UpdateIapSettings_async - */ + /** + * Updates the IAP settings on a particular IAP protected resource. It + * replaces all fields unless the `update_mask` is set. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.iap.v1.IapSettings} request.iapSettings + * Required. The new values for the IAP settings to be updated. + * Authorization: Requires the `updateSettings` permission for the associated + * resource. + * @param {google.protobuf.FieldMask} request.updateMask + * The field mask specifying which IAP settings should be updated. + * If omitted, then all of the settings are updated. See + * https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask. + * + * Note: All IAP reauth settings must always be set together, using the + * field mask: `iapSettings.accessSettings.reauthSettings`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.iap.v1.IapSettings|IapSettings}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/identity_aware_proxy_admin_service.update_iap_settings.js + * region_tag:iap_v1_generated_IdentityAwareProxyAdminService_UpdateIapSettings_async + */ updateIapSettings( - request?: protos.google.cloud.iap.v1.IUpdateIapSettingsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.iap.v1.IIapSettings, - protos.google.cloud.iap.v1.IUpdateIapSettingsRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.iap.v1.IUpdateIapSettingsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.iap.v1.IIapSettings, + protos.google.cloud.iap.v1.IUpdateIapSettingsRequest | undefined, + {} | undefined, + ] + >; updateIapSettings( - request: protos.google.cloud.iap.v1.IUpdateIapSettingsRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.iap.v1.IIapSettings, - protos.google.cloud.iap.v1.IUpdateIapSettingsRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.iap.v1.IUpdateIapSettingsRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.iap.v1.IIapSettings, + protos.google.cloud.iap.v1.IUpdateIapSettingsRequest | null | undefined, + {} | null | undefined + >, + ): void; updateIapSettings( - request: protos.google.cloud.iap.v1.IUpdateIapSettingsRequest, - callback: Callback< - protos.google.cloud.iap.v1.IIapSettings, - protos.google.cloud.iap.v1.IUpdateIapSettingsRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.iap.v1.IUpdateIapSettingsRequest, + callback: Callback< + protos.google.cloud.iap.v1.IIapSettings, + protos.google.cloud.iap.v1.IUpdateIapSettingsRequest | null | undefined, + {} | null | undefined + >, + ): void; updateIapSettings( - request?: protos.google.cloud.iap.v1.IUpdateIapSettingsRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.iap.v1.IIapSettings, - protos.google.cloud.iap.v1.IUpdateIapSettingsRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.iap.v1.IUpdateIapSettingsRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.iap.v1.IIapSettings, - protos.google.cloud.iap.v1.IUpdateIapSettingsRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.iap.v1.IIapSettings, - protos.google.cloud.iap.v1.IUpdateIapSettingsRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.iap.v1.IUpdateIapSettingsRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.iap.v1.IIapSettings, + protos.google.cloud.iap.v1.IUpdateIapSettingsRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.iap.v1.IIapSettings, + protos.google.cloud.iap.v1.IUpdateIapSettingsRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'iap_settings.name': request.iapSettings!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'iap_settings.name': request.iapSettings!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('updateIapSettings request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.iap.v1.IIapSettings, - protos.google.cloud.iap.v1.IUpdateIapSettingsRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.iap.v1.IIapSettings, + | protos.google.cloud.iap.v1.IUpdateIapSettingsRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('updateIapSettings response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.updateIapSettings(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.iap.v1.IIapSettings, - protos.google.cloud.iap.v1.IUpdateIapSettingsRequest|undefined, - {}|undefined - ]) => { - this._log.info('updateIapSettings response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .updateIapSettings(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.iap.v1.IIapSettings, + protos.google.cloud.iap.v1.IUpdateIapSettingsRequest | undefined, + {} | undefined, + ]) => { + this._log.info('updateIapSettings response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Validates that a given CEL expression conforms to IAP restrictions. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the IAP protected resource. - * @param {string} request.expression - * Required. User input string expression. Should be of the form - * `attributes.saml_attributes.filter(attribute, attribute.name in - * ['{attribute_name}', '{attribute_name}'])` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.iap.v1.ValidateIapAttributeExpressionResponse|ValidateIapAttributeExpressionResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/identity_aware_proxy_admin_service.validate_iap_attribute_expression.js - * region_tag:iap_v1_generated_IdentityAwareProxyAdminService_ValidateIapAttributeExpression_async - */ + /** + * Validates that a given CEL expression conforms to IAP restrictions. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the IAP protected resource. + * @param {string} request.expression + * Required. User input string expression. Should be of the form + * `attributes.saml_attributes.filter(attribute, attribute.name in + * ['{attribute_name}', '{attribute_name}'])` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.iap.v1.ValidateIapAttributeExpressionResponse|ValidateIapAttributeExpressionResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/identity_aware_proxy_admin_service.validate_iap_attribute_expression.js + * region_tag:iap_v1_generated_IdentityAwareProxyAdminService_ValidateIapAttributeExpression_async + */ validateIapAttributeExpression( - request?: protos.google.cloud.iap.v1.IValidateIapAttributeExpressionRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.iap.v1.IValidateIapAttributeExpressionResponse, - protos.google.cloud.iap.v1.IValidateIapAttributeExpressionRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.iap.v1.IValidateIapAttributeExpressionRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.iap.v1.IValidateIapAttributeExpressionResponse, + ( + | protos.google.cloud.iap.v1.IValidateIapAttributeExpressionRequest + | undefined + ), + {} | undefined, + ] + >; validateIapAttributeExpression( - request: protos.google.cloud.iap.v1.IValidateIapAttributeExpressionRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.iap.v1.IValidateIapAttributeExpressionResponse, - protos.google.cloud.iap.v1.IValidateIapAttributeExpressionRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.iap.v1.IValidateIapAttributeExpressionRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.iap.v1.IValidateIapAttributeExpressionResponse, + | protos.google.cloud.iap.v1.IValidateIapAttributeExpressionRequest + | null + | undefined, + {} | null | undefined + >, + ): void; validateIapAttributeExpression( - request: protos.google.cloud.iap.v1.IValidateIapAttributeExpressionRequest, - callback: Callback< - protos.google.cloud.iap.v1.IValidateIapAttributeExpressionResponse, - protos.google.cloud.iap.v1.IValidateIapAttributeExpressionRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.iap.v1.IValidateIapAttributeExpressionRequest, + callback: Callback< + protos.google.cloud.iap.v1.IValidateIapAttributeExpressionResponse, + | protos.google.cloud.iap.v1.IValidateIapAttributeExpressionRequest + | null + | undefined, + {} | null | undefined + >, + ): void; validateIapAttributeExpression( - request?: protos.google.cloud.iap.v1.IValidateIapAttributeExpressionRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.iap.v1.IValidateIapAttributeExpressionResponse, - protos.google.cloud.iap.v1.IValidateIapAttributeExpressionRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.iap.v1.IValidateIapAttributeExpressionRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.iap.v1.IValidateIapAttributeExpressionResponse, - protos.google.cloud.iap.v1.IValidateIapAttributeExpressionRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.iap.v1.IValidateIapAttributeExpressionResponse, - protos.google.cloud.iap.v1.IValidateIapAttributeExpressionRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.iap.v1.IValidateIapAttributeExpressionRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.iap.v1.IValidateIapAttributeExpressionResponse, + | protos.google.cloud.iap.v1.IValidateIapAttributeExpressionRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.iap.v1.IValidateIapAttributeExpressionResponse, + ( + | protos.google.cloud.iap.v1.IValidateIapAttributeExpressionRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('validateIapAttributeExpression request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.iap.v1.IValidateIapAttributeExpressionResponse, - protos.google.cloud.iap.v1.IValidateIapAttributeExpressionRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.iap.v1.IValidateIapAttributeExpressionResponse, + | protos.google.cloud.iap.v1.IValidateIapAttributeExpressionRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { - this._log.info('validateIapAttributeExpression response %j', response); + this._log.info( + 'validateIapAttributeExpression response %j', + response, + ); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.validateIapAttributeExpression(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.iap.v1.IValidateIapAttributeExpressionResponse, - protos.google.cloud.iap.v1.IValidateIapAttributeExpressionRequest|undefined, - {}|undefined - ]) => { - this._log.info('validateIapAttributeExpression response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .validateIapAttributeExpression(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.iap.v1.IValidateIapAttributeExpressionResponse, + ( + | protos.google.cloud.iap.v1.IValidateIapAttributeExpressionRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info( + 'validateIapAttributeExpression response %j', + response, + ); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 TunnelDestGroup. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Google Cloud Project ID and location. - * In the following format: - * `projects/{project_number/id}/iap_tunnel/locations/{location}`. - * @param {google.cloud.iap.v1.TunnelDestGroup} request.tunnelDestGroup - * Required. The TunnelDestGroup to create. - * @param {string} request.tunnelDestGroupId - * Required. The ID to use for the TunnelDestGroup, which becomes the final - * component of the resource name. - * - * This value must be 4-63 characters, and valid characters - * are `[a-z]-`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.iap.v1.TunnelDestGroup|TunnelDestGroup}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/identity_aware_proxy_admin_service.create_tunnel_dest_group.js - * region_tag:iap_v1_generated_IdentityAwareProxyAdminService_CreateTunnelDestGroup_async - */ + /** + * Creates a new TunnelDestGroup. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Google Cloud Project ID and location. + * In the following format: + * `projects/{project_number/id}/iap_tunnel/locations/{location}`. + * @param {google.cloud.iap.v1.TunnelDestGroup} request.tunnelDestGroup + * Required. The TunnelDestGroup to create. + * @param {string} request.tunnelDestGroupId + * Required. The ID to use for the TunnelDestGroup, which becomes the final + * component of the resource name. + * + * This value must be 4-63 characters, and valid characters + * are `[a-z]-`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.iap.v1.TunnelDestGroup|TunnelDestGroup}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/identity_aware_proxy_admin_service.create_tunnel_dest_group.js + * region_tag:iap_v1_generated_IdentityAwareProxyAdminService_CreateTunnelDestGroup_async + */ createTunnelDestGroup( - request?: protos.google.cloud.iap.v1.ICreateTunnelDestGroupRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.iap.v1.ITunnelDestGroup, - protos.google.cloud.iap.v1.ICreateTunnelDestGroupRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.iap.v1.ICreateTunnelDestGroupRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.iap.v1.ITunnelDestGroup, + protos.google.cloud.iap.v1.ICreateTunnelDestGroupRequest | undefined, + {} | undefined, + ] + >; createTunnelDestGroup( - request: protos.google.cloud.iap.v1.ICreateTunnelDestGroupRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.iap.v1.ITunnelDestGroup, - protos.google.cloud.iap.v1.ICreateTunnelDestGroupRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.iap.v1.ICreateTunnelDestGroupRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.iap.v1.ITunnelDestGroup, + | protos.google.cloud.iap.v1.ICreateTunnelDestGroupRequest + | null + | undefined, + {} | null | undefined + >, + ): void; createTunnelDestGroup( - request: protos.google.cloud.iap.v1.ICreateTunnelDestGroupRequest, - callback: Callback< - protos.google.cloud.iap.v1.ITunnelDestGroup, - protos.google.cloud.iap.v1.ICreateTunnelDestGroupRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.iap.v1.ICreateTunnelDestGroupRequest, + callback: Callback< + protos.google.cloud.iap.v1.ITunnelDestGroup, + | protos.google.cloud.iap.v1.ICreateTunnelDestGroupRequest + | null + | undefined, + {} | null | undefined + >, + ): void; createTunnelDestGroup( - request?: protos.google.cloud.iap.v1.ICreateTunnelDestGroupRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.iap.v1.ITunnelDestGroup, - protos.google.cloud.iap.v1.ICreateTunnelDestGroupRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.iap.v1.ICreateTunnelDestGroupRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.iap.v1.ITunnelDestGroup, - protos.google.cloud.iap.v1.ICreateTunnelDestGroupRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.iap.v1.ITunnelDestGroup, - protos.google.cloud.iap.v1.ICreateTunnelDestGroupRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.iap.v1.ICreateTunnelDestGroupRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.iap.v1.ITunnelDestGroup, + | protos.google.cloud.iap.v1.ICreateTunnelDestGroupRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.iap.v1.ITunnelDestGroup, + protos.google.cloud.iap.v1.ICreateTunnelDestGroupRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.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('createTunnelDestGroup request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.iap.v1.ITunnelDestGroup, - protos.google.cloud.iap.v1.ICreateTunnelDestGroupRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.iap.v1.ITunnelDestGroup, + | protos.google.cloud.iap.v1.ICreateTunnelDestGroupRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('createTunnelDestGroup response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.createTunnelDestGroup(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.iap.v1.ITunnelDestGroup, - protos.google.cloud.iap.v1.ICreateTunnelDestGroupRequest|undefined, - {}|undefined - ]) => { - this._log.info('createTunnelDestGroup response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .createTunnelDestGroup(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.iap.v1.ITunnelDestGroup, + protos.google.cloud.iap.v1.ICreateTunnelDestGroupRequest | undefined, + {} | undefined, + ]) => { + this._log.info('createTunnelDestGroup response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 an existing TunnelDestGroup. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the TunnelDestGroup to be fetched. - * In the following format: - * `projects/{project_number/id}/iap_tunnel/locations/{location}/destGroups/{dest_group}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.iap.v1.TunnelDestGroup|TunnelDestGroup}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/identity_aware_proxy_admin_service.get_tunnel_dest_group.js - * region_tag:iap_v1_generated_IdentityAwareProxyAdminService_GetTunnelDestGroup_async - */ + /** + * Retrieves an existing TunnelDestGroup. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the TunnelDestGroup to be fetched. + * In the following format: + * `projects/{project_number/id}/iap_tunnel/locations/{location}/destGroups/{dest_group}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.iap.v1.TunnelDestGroup|TunnelDestGroup}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/identity_aware_proxy_admin_service.get_tunnel_dest_group.js + * region_tag:iap_v1_generated_IdentityAwareProxyAdminService_GetTunnelDestGroup_async + */ getTunnelDestGroup( - request?: protos.google.cloud.iap.v1.IGetTunnelDestGroupRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.iap.v1.ITunnelDestGroup, - protos.google.cloud.iap.v1.IGetTunnelDestGroupRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.iap.v1.IGetTunnelDestGroupRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.iap.v1.ITunnelDestGroup, + protos.google.cloud.iap.v1.IGetTunnelDestGroupRequest | undefined, + {} | undefined, + ] + >; getTunnelDestGroup( - request: protos.google.cloud.iap.v1.IGetTunnelDestGroupRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.iap.v1.ITunnelDestGroup, - protos.google.cloud.iap.v1.IGetTunnelDestGroupRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.iap.v1.IGetTunnelDestGroupRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.iap.v1.ITunnelDestGroup, + protos.google.cloud.iap.v1.IGetTunnelDestGroupRequest | null | undefined, + {} | null | undefined + >, + ): void; getTunnelDestGroup( - request: protos.google.cloud.iap.v1.IGetTunnelDestGroupRequest, - callback: Callback< - protos.google.cloud.iap.v1.ITunnelDestGroup, - protos.google.cloud.iap.v1.IGetTunnelDestGroupRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.iap.v1.IGetTunnelDestGroupRequest, + callback: Callback< + protos.google.cloud.iap.v1.ITunnelDestGroup, + protos.google.cloud.iap.v1.IGetTunnelDestGroupRequest | null | undefined, + {} | null | undefined + >, + ): void; getTunnelDestGroup( - request?: protos.google.cloud.iap.v1.IGetTunnelDestGroupRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.iap.v1.IGetTunnelDestGroupRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.iap.v1.ITunnelDestGroup, - protos.google.cloud.iap.v1.IGetTunnelDestGroupRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.iap.v1.ITunnelDestGroup, - protos.google.cloud.iap.v1.IGetTunnelDestGroupRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.iap.v1.ITunnelDestGroup, - protos.google.cloud.iap.v1.IGetTunnelDestGroupRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.iap.v1.IGetTunnelDestGroupRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.iap.v1.ITunnelDestGroup, + protos.google.cloud.iap.v1.IGetTunnelDestGroupRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.iap.v1.ITunnelDestGroup, + protos.google.cloud.iap.v1.IGetTunnelDestGroupRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getTunnelDestGroup request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.iap.v1.ITunnelDestGroup, - protos.google.cloud.iap.v1.IGetTunnelDestGroupRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.iap.v1.ITunnelDestGroup, + | protos.google.cloud.iap.v1.IGetTunnelDestGroupRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getTunnelDestGroup response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getTunnelDestGroup(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.iap.v1.ITunnelDestGroup, - protos.google.cloud.iap.v1.IGetTunnelDestGroupRequest|undefined, - {}|undefined - ]) => { - this._log.info('getTunnelDestGroup response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getTunnelDestGroup(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.iap.v1.ITunnelDestGroup, + protos.google.cloud.iap.v1.IGetTunnelDestGroupRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getTunnelDestGroup response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 TunnelDestGroup. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the TunnelDestGroup to delete. - * In the following format: - * `projects/{project_number/id}/iap_tunnel/locations/{location}/destGroups/{dest_group}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for 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/identity_aware_proxy_admin_service.delete_tunnel_dest_group.js - * region_tag:iap_v1_generated_IdentityAwareProxyAdminService_DeleteTunnelDestGroup_async - */ + /** + * Deletes a TunnelDestGroup. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the TunnelDestGroup to delete. + * In the following format: + * `projects/{project_number/id}/iap_tunnel/locations/{location}/destGroups/{dest_group}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for 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/identity_aware_proxy_admin_service.delete_tunnel_dest_group.js + * region_tag:iap_v1_generated_IdentityAwareProxyAdminService_DeleteTunnelDestGroup_async + */ deleteTunnelDestGroup( - request?: protos.google.cloud.iap.v1.IDeleteTunnelDestGroupRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.iap.v1.IDeleteTunnelDestGroupRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.iap.v1.IDeleteTunnelDestGroupRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.iap.v1.IDeleteTunnelDestGroupRequest | undefined, + {} | undefined, + ] + >; deleteTunnelDestGroup( - request: protos.google.cloud.iap.v1.IDeleteTunnelDestGroupRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.iap.v1.IDeleteTunnelDestGroupRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.iap.v1.IDeleteTunnelDestGroupRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.iap.v1.IDeleteTunnelDestGroupRequest + | null + | undefined, + {} | null | undefined + >, + ): void; deleteTunnelDestGroup( - request: protos.google.cloud.iap.v1.IDeleteTunnelDestGroupRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.iap.v1.IDeleteTunnelDestGroupRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.iap.v1.IDeleteTunnelDestGroupRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.iap.v1.IDeleteTunnelDestGroupRequest + | null + | undefined, + {} | null | undefined + >, + ): void; deleteTunnelDestGroup( - request?: protos.google.cloud.iap.v1.IDeleteTunnelDestGroupRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.iap.v1.IDeleteTunnelDestGroupRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.iap.v1.IDeleteTunnelDestGroupRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.protobuf.IEmpty, - protos.google.cloud.iap.v1.IDeleteTunnelDestGroupRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.iap.v1.IDeleteTunnelDestGroupRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.iap.v1.IDeleteTunnelDestGroupRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.iap.v1.IDeleteTunnelDestGroupRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.iap.v1.IDeleteTunnelDestGroupRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('deleteTunnelDestGroup request %j', request); - const wrappedCallback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.iap.v1.IDeleteTunnelDestGroupRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.iap.v1.IDeleteTunnelDestGroupRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('deleteTunnelDestGroup response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.deleteTunnelDestGroup(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.protobuf.IEmpty, - protos.google.cloud.iap.v1.IDeleteTunnelDestGroupRequest|undefined, - {}|undefined - ]) => { - this._log.info('deleteTunnelDestGroup response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .deleteTunnelDestGroup(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + protos.google.cloud.iap.v1.IDeleteTunnelDestGroupRequest | undefined, + {} | undefined, + ]) => { + this._log.info('deleteTunnelDestGroup response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 TunnelDestGroup. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.iap.v1.TunnelDestGroup} request.tunnelDestGroup - * Required. The new values for the TunnelDestGroup. - * @param {google.protobuf.FieldMask} request.updateMask - * A field mask that specifies which IAP settings to update. - * If omitted, then all of the settings are updated. See - * https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.iap.v1.TunnelDestGroup|TunnelDestGroup}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/identity_aware_proxy_admin_service.update_tunnel_dest_group.js - * region_tag:iap_v1_generated_IdentityAwareProxyAdminService_UpdateTunnelDestGroup_async - */ + /** + * Updates a TunnelDestGroup. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.iap.v1.TunnelDestGroup} request.tunnelDestGroup + * Required. The new values for the TunnelDestGroup. + * @param {google.protobuf.FieldMask} request.updateMask + * A field mask that specifies which IAP settings to update. + * If omitted, then all of the settings are updated. See + * https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.iap.v1.TunnelDestGroup|TunnelDestGroup}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/identity_aware_proxy_admin_service.update_tunnel_dest_group.js + * region_tag:iap_v1_generated_IdentityAwareProxyAdminService_UpdateTunnelDestGroup_async + */ updateTunnelDestGroup( - request?: protos.google.cloud.iap.v1.IUpdateTunnelDestGroupRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.iap.v1.ITunnelDestGroup, - protos.google.cloud.iap.v1.IUpdateTunnelDestGroupRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.iap.v1.IUpdateTunnelDestGroupRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.iap.v1.ITunnelDestGroup, + protos.google.cloud.iap.v1.IUpdateTunnelDestGroupRequest | undefined, + {} | undefined, + ] + >; updateTunnelDestGroup( - request: protos.google.cloud.iap.v1.IUpdateTunnelDestGroupRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.iap.v1.ITunnelDestGroup, - protos.google.cloud.iap.v1.IUpdateTunnelDestGroupRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.iap.v1.IUpdateTunnelDestGroupRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.iap.v1.ITunnelDestGroup, + | protos.google.cloud.iap.v1.IUpdateTunnelDestGroupRequest + | null + | undefined, + {} | null | undefined + >, + ): void; updateTunnelDestGroup( - request: protos.google.cloud.iap.v1.IUpdateTunnelDestGroupRequest, - callback: Callback< - protos.google.cloud.iap.v1.ITunnelDestGroup, - protos.google.cloud.iap.v1.IUpdateTunnelDestGroupRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.iap.v1.IUpdateTunnelDestGroupRequest, + callback: Callback< + protos.google.cloud.iap.v1.ITunnelDestGroup, + | protos.google.cloud.iap.v1.IUpdateTunnelDestGroupRequest + | null + | undefined, + {} | null | undefined + >, + ): void; updateTunnelDestGroup( - request?: protos.google.cloud.iap.v1.IUpdateTunnelDestGroupRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.iap.v1.ITunnelDestGroup, - protos.google.cloud.iap.v1.IUpdateTunnelDestGroupRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.iap.v1.IUpdateTunnelDestGroupRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.iap.v1.ITunnelDestGroup, - protos.google.cloud.iap.v1.IUpdateTunnelDestGroupRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.iap.v1.ITunnelDestGroup, - protos.google.cloud.iap.v1.IUpdateTunnelDestGroupRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.iap.v1.IUpdateTunnelDestGroupRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.iap.v1.ITunnelDestGroup, + | protos.google.cloud.iap.v1.IUpdateTunnelDestGroupRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.iap.v1.ITunnelDestGroup, + protos.google.cloud.iap.v1.IUpdateTunnelDestGroupRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'tunnel_dest_group.name': request.tunnelDestGroup!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'tunnel_dest_group.name': request.tunnelDestGroup!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('updateTunnelDestGroup request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.iap.v1.ITunnelDestGroup, - protos.google.cloud.iap.v1.IUpdateTunnelDestGroupRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.iap.v1.ITunnelDestGroup, + | protos.google.cloud.iap.v1.IUpdateTunnelDestGroupRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('updateTunnelDestGroup response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.updateTunnelDestGroup(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.iap.v1.ITunnelDestGroup, - protos.google.cloud.iap.v1.IUpdateTunnelDestGroupRequest|undefined, - {}|undefined - ]) => { - this._log.info('updateTunnelDestGroup response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .updateTunnelDestGroup(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.iap.v1.ITunnelDestGroup, + protos.google.cloud.iap.v1.IUpdateTunnelDestGroupRequest | undefined, + {} | undefined, + ]) => { + this._log.info('updateTunnelDestGroup response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 the existing TunnelDestGroups. To group across all locations, use a - * `-` as the location ID. For example: - * `/v1/projects/123/iap_tunnel/locations/-/destGroups` - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Google Cloud Project ID and location. - * In the following format: - * `projects/{project_number/id}/iap_tunnel/locations/{location}`. - * A `-` can be used for the location to group across all locations. - * @param {number} request.pageSize - * The maximum number of groups to return. The service might return fewer than - * this value. - * If unspecified, at most 100 groups are returned. - * The maximum value is 1000; values above 1000 are coerced to 1000. - * @param {string} request.pageToken - * A page token, received from a previous `ListTunnelDestGroups` - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * `ListTunnelDestGroups` 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.iap.v1.TunnelDestGroup|TunnelDestGroup}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listTunnelDestGroupsAsync()` - * method described below for async iteration which you can stop as 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 existing TunnelDestGroups. To group across all locations, use a + * `-` as the location ID. For example: + * `/v1/projects/123/iap_tunnel/locations/-/destGroups` + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Google Cloud Project ID and location. + * In the following format: + * `projects/{project_number/id}/iap_tunnel/locations/{location}`. + * A `-` can be used for the location to group across all locations. + * @param {number} request.pageSize + * The maximum number of groups to return. The service might return fewer than + * this value. + * If unspecified, at most 100 groups are returned. + * The maximum value is 1000; values above 1000 are coerced to 1000. + * @param {string} request.pageToken + * A page token, received from a previous `ListTunnelDestGroups` + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * `ListTunnelDestGroups` 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.iap.v1.TunnelDestGroup|TunnelDestGroup}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listTunnelDestGroupsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listTunnelDestGroups( - request?: protos.google.cloud.iap.v1.IListTunnelDestGroupsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.iap.v1.ITunnelDestGroup[], - protos.google.cloud.iap.v1.IListTunnelDestGroupsRequest|null, - protos.google.cloud.iap.v1.IListTunnelDestGroupsResponse - ]>; + request?: protos.google.cloud.iap.v1.IListTunnelDestGroupsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.iap.v1.ITunnelDestGroup[], + protos.google.cloud.iap.v1.IListTunnelDestGroupsRequest | null, + protos.google.cloud.iap.v1.IListTunnelDestGroupsResponse, + ] + >; listTunnelDestGroups( - request: protos.google.cloud.iap.v1.IListTunnelDestGroupsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.iap.v1.IListTunnelDestGroupsRequest, - protos.google.cloud.iap.v1.IListTunnelDestGroupsResponse|null|undefined, - protos.google.cloud.iap.v1.ITunnelDestGroup>): void; + request: protos.google.cloud.iap.v1.IListTunnelDestGroupsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.iap.v1.IListTunnelDestGroupsRequest, + | protos.google.cloud.iap.v1.IListTunnelDestGroupsResponse + | null + | undefined, + protos.google.cloud.iap.v1.ITunnelDestGroup + >, + ): void; listTunnelDestGroups( - request: protos.google.cloud.iap.v1.IListTunnelDestGroupsRequest, - callback: PaginationCallback< - protos.google.cloud.iap.v1.IListTunnelDestGroupsRequest, - protos.google.cloud.iap.v1.IListTunnelDestGroupsResponse|null|undefined, - protos.google.cloud.iap.v1.ITunnelDestGroup>): void; + request: protos.google.cloud.iap.v1.IListTunnelDestGroupsRequest, + callback: PaginationCallback< + protos.google.cloud.iap.v1.IListTunnelDestGroupsRequest, + | protos.google.cloud.iap.v1.IListTunnelDestGroupsResponse + | null + | undefined, + protos.google.cloud.iap.v1.ITunnelDestGroup + >, + ): void; listTunnelDestGroups( - request?: protos.google.cloud.iap.v1.IListTunnelDestGroupsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.iap.v1.IListTunnelDestGroupsRequest, - protos.google.cloud.iap.v1.IListTunnelDestGroupsResponse|null|undefined, - protos.google.cloud.iap.v1.ITunnelDestGroup>, - callback?: PaginationCallback< + request?: protos.google.cloud.iap.v1.IListTunnelDestGroupsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.iap.v1.IListTunnelDestGroupsRequest, - protos.google.cloud.iap.v1.IListTunnelDestGroupsResponse|null|undefined, - protos.google.cloud.iap.v1.ITunnelDestGroup>): - Promise<[ - protos.google.cloud.iap.v1.ITunnelDestGroup[], - protos.google.cloud.iap.v1.IListTunnelDestGroupsRequest|null, - protos.google.cloud.iap.v1.IListTunnelDestGroupsResponse - ]>|void { + | protos.google.cloud.iap.v1.IListTunnelDestGroupsResponse + | null + | undefined, + protos.google.cloud.iap.v1.ITunnelDestGroup + >, + callback?: PaginationCallback< + protos.google.cloud.iap.v1.IListTunnelDestGroupsRequest, + | protos.google.cloud.iap.v1.IListTunnelDestGroupsResponse + | null + | undefined, + protos.google.cloud.iap.v1.ITunnelDestGroup + >, + ): Promise< + [ + protos.google.cloud.iap.v1.ITunnelDestGroup[], + protos.google.cloud.iap.v1.IListTunnelDestGroupsRequest | null, + protos.google.cloud.iap.v1.IListTunnelDestGroupsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-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.iap.v1.IListTunnelDestGroupsRequest, - protos.google.cloud.iap.v1.IListTunnelDestGroupsResponse|null|undefined, - protos.google.cloud.iap.v1.ITunnelDestGroup>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.iap.v1.IListTunnelDestGroupsRequest, + | protos.google.cloud.iap.v1.IListTunnelDestGroupsResponse + | null + | undefined, + protos.google.cloud.iap.v1.ITunnelDestGroup + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listTunnelDestGroups values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1450,128 +1897,132 @@ export class IdentityAwareProxyAdminServiceClient { this._log.info('listTunnelDestGroups request %j', request); return this.innerApiCalls .listTunnelDestGroups(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.iap.v1.ITunnelDestGroup[], - protos.google.cloud.iap.v1.IListTunnelDestGroupsRequest|null, - protos.google.cloud.iap.v1.IListTunnelDestGroupsResponse - ]) => { - this._log.info('listTunnelDestGroups values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.iap.v1.ITunnelDestGroup[], + protos.google.cloud.iap.v1.IListTunnelDestGroupsRequest | null, + protos.google.cloud.iap.v1.IListTunnelDestGroupsResponse, + ]) => { + this._log.info('listTunnelDestGroups values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listTunnelDestGroups`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Google Cloud Project ID and location. - * In the following format: - * `projects/{project_number/id}/iap_tunnel/locations/{location}`. - * A `-` can be used for the location to group across all locations. - * @param {number} request.pageSize - * The maximum number of groups to return. The service might return fewer than - * this value. - * If unspecified, at most 100 groups are returned. - * The maximum value is 1000; values above 1000 are coerced to 1000. - * @param {string} request.pageToken - * A page token, received from a previous `ListTunnelDestGroups` - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * `ListTunnelDestGroups` 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.iap.v1.TunnelDestGroup|TunnelDestGroup} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listTunnelDestGroupsAsync()` - * method described below for async iteration which you can stop as 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 `listTunnelDestGroups`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Google Cloud Project ID and location. + * In the following format: + * `projects/{project_number/id}/iap_tunnel/locations/{location}`. + * A `-` can be used for the location to group across all locations. + * @param {number} request.pageSize + * The maximum number of groups to return. The service might return fewer than + * this value. + * If unspecified, at most 100 groups are returned. + * The maximum value is 1000; values above 1000 are coerced to 1000. + * @param {string} request.pageToken + * A page token, received from a previous `ListTunnelDestGroups` + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * `ListTunnelDestGroups` 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.iap.v1.TunnelDestGroup|TunnelDestGroup} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listTunnelDestGroupsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listTunnelDestGroupsStream( - request?: protos.google.cloud.iap.v1.IListTunnelDestGroupsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.iap.v1.IListTunnelDestGroupsRequest, + 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['listTunnelDestGroups']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listTunnelDestGroups stream %j', request); return this.descriptors.page.listTunnelDestGroups.createStream( this.innerApiCalls.listTunnelDestGroups as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listTunnelDestGroups`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Google Cloud Project ID and location. - * In the following format: - * `projects/{project_number/id}/iap_tunnel/locations/{location}`. - * A `-` can be used for the location to group across all locations. - * @param {number} request.pageSize - * The maximum number of groups to return. The service might return fewer than - * this value. - * If unspecified, at most 100 groups are returned. - * The maximum value is 1000; values above 1000 are coerced to 1000. - * @param {string} request.pageToken - * A page token, received from a previous `ListTunnelDestGroups` - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * `ListTunnelDestGroups` 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.iap.v1.TunnelDestGroup|TunnelDestGroup}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@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/identity_aware_proxy_admin_service.list_tunnel_dest_groups.js - * region_tag:iap_v1_generated_IdentityAwareProxyAdminService_ListTunnelDestGroups_async - */ + /** + * Equivalent to `listTunnelDestGroups`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Google Cloud Project ID and location. + * In the following format: + * `projects/{project_number/id}/iap_tunnel/locations/{location}`. + * A `-` can be used for the location to group across all locations. + * @param {number} request.pageSize + * The maximum number of groups to return. The service might return fewer than + * this value. + * If unspecified, at most 100 groups are returned. + * The maximum value is 1000; values above 1000 are coerced to 1000. + * @param {string} request.pageToken + * A page token, received from a previous `ListTunnelDestGroups` + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * `ListTunnelDestGroups` 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.iap.v1.TunnelDestGroup|TunnelDestGroup}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@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/identity_aware_proxy_admin_service.list_tunnel_dest_groups.js + * region_tag:iap_v1_generated_IdentityAwareProxyAdminService_ListTunnelDestGroups_async + */ listTunnelDestGroupsAsync( - request?: protos.google.cloud.iap.v1.IListTunnelDestGroupsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.iap.v1.IListTunnelDestGroupsRequest, + 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['listTunnelDestGroups']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listTunnelDestGroups iterate %j', request); return this.descriptors.page.listTunnelDestGroups.asyncIterate( this.innerApiCalls['listTunnelDestGroups'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } // -------------------- @@ -1584,7 +2035,7 @@ export class IdentityAwareProxyAdminServiceClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -1609,7 +2060,7 @@ export class IdentityAwareProxyAdminServiceClient { * @param {string} dest_group * @returns {string} Resource name string. */ - tunnelDestGroupPath(project:string,location:string,destGroup:string) { + tunnelDestGroupPath(project: string, location: string, destGroup: string) { return this.pathTemplates.tunnelDestGroupPathTemplate.render({ project: project, location: location, @@ -1625,7 +2076,9 @@ export class IdentityAwareProxyAdminServiceClient { * @returns {string} A string representing the project. */ matchProjectFromTunnelDestGroupName(tunnelDestGroupName: string) { - return this.pathTemplates.tunnelDestGroupPathTemplate.match(tunnelDestGroupName).project; + return this.pathTemplates.tunnelDestGroupPathTemplate.match( + tunnelDestGroupName, + ).project; } /** @@ -1636,7 +2089,9 @@ export class IdentityAwareProxyAdminServiceClient { * @returns {string} A string representing the location. */ matchLocationFromTunnelDestGroupName(tunnelDestGroupName: string) { - return this.pathTemplates.tunnelDestGroupPathTemplate.match(tunnelDestGroupName).location; + return this.pathTemplates.tunnelDestGroupPathTemplate.match( + tunnelDestGroupName, + ).location; } /** @@ -1647,7 +2102,9 @@ export class IdentityAwareProxyAdminServiceClient { * @returns {string} A string representing the dest_group. */ matchDestGroupFromTunnelDestGroupName(tunnelDestGroupName: string) { - return this.pathTemplates.tunnelDestGroupPathTemplate.match(tunnelDestGroupName).dest_group; + return this.pathTemplates.tunnelDestGroupPathTemplate.match( + tunnelDestGroupName, + ).dest_group; } /** @@ -1657,7 +2114,7 @@ export class IdentityAwareProxyAdminServiceClient { * @param {string} location * @returns {string} Resource name string. */ - tunnelLocationPath(project:string,location:string) { + tunnelLocationPath(project: string, location: string) { return this.pathTemplates.tunnelLocationPathTemplate.render({ project: project, location: location, @@ -1672,7 +2129,9 @@ export class IdentityAwareProxyAdminServiceClient { * @returns {string} A string representing the project. */ matchProjectFromTunnelLocationName(tunnelLocationName: string) { - return this.pathTemplates.tunnelLocationPathTemplate.match(tunnelLocationName).project; + return this.pathTemplates.tunnelLocationPathTemplate.match( + tunnelLocationName, + ).project; } /** @@ -1683,7 +2142,9 @@ export class IdentityAwareProxyAdminServiceClient { * @returns {string} A string representing the location. */ matchLocationFromTunnelLocationName(tunnelLocationName: string) { - return this.pathTemplates.tunnelLocationPathTemplate.match(tunnelLocationName).location; + return this.pathTemplates.tunnelLocationPathTemplate.match( + tunnelLocationName, + ).location; } /** @@ -1694,7 +2155,7 @@ export class IdentityAwareProxyAdminServiceClient { */ close(): Promise { if (this.identityAwareProxyAdminServiceStub && !this._terminated) { - return this.identityAwareProxyAdminServiceStub.then(stub => { + return this.identityAwareProxyAdminServiceStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); @@ -1702,4 +2163,4 @@ export class IdentityAwareProxyAdminServiceClient { } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-iap/src/v1/identity_aware_proxy_o_auth_service_client.ts b/packages/google-cloud-iap/src/v1/identity_aware_proxy_o_auth_service_client.ts index cc1bbff91e6e..fcf63b5dfd9c 100644 --- a/packages/google-cloud-iap/src/v1/identity_aware_proxy_o_auth_service_client.ts +++ b/packages/google-cloud-iap/src/v1/identity_aware_proxy_o_auth_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 @@ -46,7 +53,7 @@ export class IdentityAwareProxyOAuthServiceClient { 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('iap'); @@ -59,9 +66,9 @@ export class IdentityAwareProxyOAuthServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - identityAwareProxyOAuthServiceStub?: Promise<{[name: string]: Function}>; + innerApiCalls: { [name: string]: Function }; + pathTemplates: { [name: string]: gax.PathTemplate }; + identityAwareProxyOAuthServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of IdentityAwareProxyOAuthServiceClient. @@ -102,21 +109,43 @@ export class IdentityAwareProxyOAuthServiceClient { * const client = new IdentityAwareProxyOAuthServiceClient({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 IdentityAwareProxyOAuthServiceClient; - 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 IdentityAwareProxyOAuthServiceClient; + 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 = 'iap.' + 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 +170,7 @@ export class IdentityAwareProxyOAuthServiceClient { 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,10 +184,7 @@ export class IdentityAwareProxyOAuthServiceClient { } // 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 { @@ -180,13 +206,13 @@ export class IdentityAwareProxyOAuthServiceClient { // Create useful helper objects for these. this.pathTemplates = { projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' + 'projects/{project}', ), tunnelDestGroupPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/iap_tunnel/locations/{location}/destGroups/{dest_group}' + 'projects/{project}/iap_tunnel/locations/{location}/destGroups/{dest_group}', ), tunnelLocationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/iap_tunnel/locations/{location}' + 'projects/{project}/iap_tunnel/locations/{location}', ), }; @@ -194,14 +220,20 @@ export class IdentityAwareProxyOAuthServiceClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listIdentityAwareProxyClients: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'identityAwareProxyClients') + listIdentityAwareProxyClients: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'identityAwareProxyClients', + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.iap.v1.IdentityAwareProxyOAuthService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.iap.v1.IdentityAwareProxyOAuthService', + 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,50 @@ export class IdentityAwareProxyOAuthServiceClient { // Put together the "service stub" for // google.cloud.iap.v1.IdentityAwareProxyOAuthService. this.identityAwareProxyOAuthServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.iap.v1.IdentityAwareProxyOAuthService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.iap.v1.IdentityAwareProxyOAuthService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.iap.v1.IdentityAwareProxyOAuthService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.iap.v1 + .IdentityAwareProxyOAuthService, + 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 identityAwareProxyOAuthServiceStubMethods = - ['listBrands', 'createBrand', 'getBrand', 'createIdentityAwareProxyClient', 'listIdentityAwareProxyClients', 'getIdentityAwareProxyClient', 'resetIdentityAwareProxyClientSecret', 'deleteIdentityAwareProxyClient']; + const identityAwareProxyOAuthServiceStubMethods = [ + 'listBrands', + 'createBrand', + 'getBrand', + 'createIdentityAwareProxyClient', + 'listIdentityAwareProxyClients', + 'getIdentityAwareProxyClient', + 'resetIdentityAwareProxyClientSecret', + 'deleteIdentityAwareProxyClient', + ]; for (const methodName of identityAwareProxyOAuthServiceStubMethods) { const callPromise = this.identityAwareProxyOAuthServiceStub.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 +322,14 @@ export class IdentityAwareProxyOAuthServiceClient { * @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 'iap.googleapis.com'; } @@ -289,8 +340,14 @@ export class IdentityAwareProxyOAuthServiceClient { * @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 'iap.googleapis.com'; } @@ -321,9 +378,7 @@ export class IdentityAwareProxyOAuthServiceClient { * @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; @@ -332,8 +387,9 @@ export class IdentityAwareProxyOAuthServiceClient { * 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; @@ -344,784 +400,1113 @@ export class IdentityAwareProxyOAuthServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Lists the existing brands for the project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. GCP Project number/id. - * In the following format: projects/{project_number/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.iap.v1.ListBrandsResponse|ListBrandsResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/identity_aware_proxy_o_auth_service.list_brands.js - * region_tag:iap_v1_generated_IdentityAwareProxyOAuthService_ListBrands_async - */ + /** + * Lists the existing brands for the project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. GCP Project number/id. + * In the following format: projects/{project_number/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.iap.v1.ListBrandsResponse|ListBrandsResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/identity_aware_proxy_o_auth_service.list_brands.js + * region_tag:iap_v1_generated_IdentityAwareProxyOAuthService_ListBrands_async + */ listBrands( - request?: protos.google.cloud.iap.v1.IListBrandsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.iap.v1.IListBrandsResponse, - protos.google.cloud.iap.v1.IListBrandsRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.iap.v1.IListBrandsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.iap.v1.IListBrandsResponse, + protos.google.cloud.iap.v1.IListBrandsRequest | undefined, + {} | undefined, + ] + >; listBrands( - request: protos.google.cloud.iap.v1.IListBrandsRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.iap.v1.IListBrandsResponse, - protos.google.cloud.iap.v1.IListBrandsRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.iap.v1.IListBrandsRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.iap.v1.IListBrandsResponse, + protos.google.cloud.iap.v1.IListBrandsRequest | null | undefined, + {} | null | undefined + >, + ): void; listBrands( - request: protos.google.cloud.iap.v1.IListBrandsRequest, - callback: Callback< - protos.google.cloud.iap.v1.IListBrandsResponse, - protos.google.cloud.iap.v1.IListBrandsRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.iap.v1.IListBrandsRequest, + callback: Callback< + protos.google.cloud.iap.v1.IListBrandsResponse, + protos.google.cloud.iap.v1.IListBrandsRequest | null | undefined, + {} | null | undefined + >, + ): void; listBrands( - request?: protos.google.cloud.iap.v1.IListBrandsRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.iap.v1.IListBrandsRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.iap.v1.IListBrandsResponse, - protos.google.cloud.iap.v1.IListBrandsRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.iap.v1.IListBrandsResponse, - protos.google.cloud.iap.v1.IListBrandsRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.iap.v1.IListBrandsResponse, - protos.google.cloud.iap.v1.IListBrandsRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.iap.v1.IListBrandsRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.iap.v1.IListBrandsResponse, + protos.google.cloud.iap.v1.IListBrandsRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.iap.v1.IListBrandsResponse, + protos.google.cloud.iap.v1.IListBrandsRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.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('listBrands request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.iap.v1.IListBrandsResponse, - protos.google.cloud.iap.v1.IListBrandsRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.iap.v1.IListBrandsResponse, + protos.google.cloud.iap.v1.IListBrandsRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('listBrands response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.listBrands(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.iap.v1.IListBrandsResponse, - protos.google.cloud.iap.v1.IListBrandsRequest|undefined, - {}|undefined - ]) => { - this._log.info('listBrands response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .listBrands(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.iap.v1.IListBrandsResponse, + protos.google.cloud.iap.v1.IListBrandsRequest | undefined, + {} | undefined, + ]) => { + this._log.info('listBrands response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Constructs a new OAuth brand for the project if one does not exist. - * The created brand is "internal only", meaning that OAuth clients created - * under it only accept requests from users who belong to the same Google - * Workspace organization as the project. The brand is created in an - * un-reviewed status. NOTE: The "internal only" status can be manually - * changed in the Google Cloud Console. Requires that a brand does not already - * exist for the project, and that the specified support email is owned by the - * caller. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. GCP Project number/id under which the brand is to be created. - * In the following format: projects/{project_number/id}. - * @param {google.cloud.iap.v1.Brand} request.brand - * Required. The brand 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.iap.v1.Brand|Brand}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/identity_aware_proxy_o_auth_service.create_brand.js - * region_tag:iap_v1_generated_IdentityAwareProxyOAuthService_CreateBrand_async - */ + /** + * Constructs a new OAuth brand for the project if one does not exist. + * The created brand is "internal only", meaning that OAuth clients created + * under it only accept requests from users who belong to the same Google + * Workspace organization as the project. The brand is created in an + * un-reviewed status. NOTE: The "internal only" status can be manually + * changed in the Google Cloud Console. Requires that a brand does not already + * exist for the project, and that the specified support email is owned by the + * caller. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. GCP Project number/id under which the brand is to be created. + * In the following format: projects/{project_number/id}. + * @param {google.cloud.iap.v1.Brand} request.brand + * Required. The brand 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.iap.v1.Brand|Brand}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/identity_aware_proxy_o_auth_service.create_brand.js + * region_tag:iap_v1_generated_IdentityAwareProxyOAuthService_CreateBrand_async + */ createBrand( - request?: protos.google.cloud.iap.v1.ICreateBrandRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.iap.v1.IBrand, - protos.google.cloud.iap.v1.ICreateBrandRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.iap.v1.ICreateBrandRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.iap.v1.IBrand, + protos.google.cloud.iap.v1.ICreateBrandRequest | undefined, + {} | undefined, + ] + >; createBrand( - request: protos.google.cloud.iap.v1.ICreateBrandRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.iap.v1.IBrand, - protos.google.cloud.iap.v1.ICreateBrandRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.iap.v1.ICreateBrandRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.iap.v1.IBrand, + protos.google.cloud.iap.v1.ICreateBrandRequest | null | undefined, + {} | null | undefined + >, + ): void; createBrand( - request: protos.google.cloud.iap.v1.ICreateBrandRequest, - callback: Callback< - protos.google.cloud.iap.v1.IBrand, - protos.google.cloud.iap.v1.ICreateBrandRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.iap.v1.ICreateBrandRequest, + callback: Callback< + protos.google.cloud.iap.v1.IBrand, + protos.google.cloud.iap.v1.ICreateBrandRequest | null | undefined, + {} | null | undefined + >, + ): void; createBrand( - request?: protos.google.cloud.iap.v1.ICreateBrandRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.iap.v1.ICreateBrandRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.iap.v1.IBrand, - protos.google.cloud.iap.v1.ICreateBrandRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.iap.v1.IBrand, - protos.google.cloud.iap.v1.ICreateBrandRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.iap.v1.IBrand, - protos.google.cloud.iap.v1.ICreateBrandRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.iap.v1.ICreateBrandRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.iap.v1.IBrand, + protos.google.cloud.iap.v1.ICreateBrandRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.iap.v1.IBrand, + protos.google.cloud.iap.v1.ICreateBrandRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.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('createBrand request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.iap.v1.IBrand, - protos.google.cloud.iap.v1.ICreateBrandRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.iap.v1.IBrand, + protos.google.cloud.iap.v1.ICreateBrandRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('createBrand response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.createBrand(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.iap.v1.IBrand, - protos.google.cloud.iap.v1.ICreateBrandRequest|undefined, - {}|undefined - ]) => { - this._log.info('createBrand response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .createBrand(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.iap.v1.IBrand, + protos.google.cloud.iap.v1.ICreateBrandRequest | undefined, + {} | undefined, + ]) => { + this._log.info('createBrand response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 OAuth brand of the project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the brand to be fetched. - * In the following format: projects/{project_number/id}/brands/{brand}. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.iap.v1.Brand|Brand}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/identity_aware_proxy_o_auth_service.get_brand.js - * region_tag:iap_v1_generated_IdentityAwareProxyOAuthService_GetBrand_async - */ + /** + * Retrieves the OAuth brand of the project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the brand to be fetched. + * In the following format: projects/{project_number/id}/brands/{brand}. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.iap.v1.Brand|Brand}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/identity_aware_proxy_o_auth_service.get_brand.js + * region_tag:iap_v1_generated_IdentityAwareProxyOAuthService_GetBrand_async + */ getBrand( - request?: protos.google.cloud.iap.v1.IGetBrandRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.iap.v1.IBrand, - protos.google.cloud.iap.v1.IGetBrandRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.iap.v1.IGetBrandRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.iap.v1.IBrand, + protos.google.cloud.iap.v1.IGetBrandRequest | undefined, + {} | undefined, + ] + >; getBrand( - request: protos.google.cloud.iap.v1.IGetBrandRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.iap.v1.IBrand, - protos.google.cloud.iap.v1.IGetBrandRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.iap.v1.IGetBrandRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.iap.v1.IBrand, + protos.google.cloud.iap.v1.IGetBrandRequest | null | undefined, + {} | null | undefined + >, + ): void; getBrand( - request: protos.google.cloud.iap.v1.IGetBrandRequest, - callback: Callback< - protos.google.cloud.iap.v1.IBrand, - protos.google.cloud.iap.v1.IGetBrandRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.iap.v1.IGetBrandRequest, + callback: Callback< + protos.google.cloud.iap.v1.IBrand, + protos.google.cloud.iap.v1.IGetBrandRequest | null | undefined, + {} | null | undefined + >, + ): void; getBrand( - request?: protos.google.cloud.iap.v1.IGetBrandRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.iap.v1.IGetBrandRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.iap.v1.IBrand, - protos.google.cloud.iap.v1.IGetBrandRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.iap.v1.IBrand, - protos.google.cloud.iap.v1.IGetBrandRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.iap.v1.IBrand, - protos.google.cloud.iap.v1.IGetBrandRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.iap.v1.IGetBrandRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.iap.v1.IBrand, + protos.google.cloud.iap.v1.IGetBrandRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.iap.v1.IBrand, + protos.google.cloud.iap.v1.IGetBrandRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getBrand request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.iap.v1.IBrand, - protos.google.cloud.iap.v1.IGetBrandRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.iap.v1.IBrand, + protos.google.cloud.iap.v1.IGetBrandRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getBrand response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getBrand(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.iap.v1.IBrand, - protos.google.cloud.iap.v1.IGetBrandRequest|undefined, - {}|undefined - ]) => { - this._log.info('getBrand response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getBrand(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.iap.v1.IBrand, + protos.google.cloud.iap.v1.IGetBrandRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getBrand response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 Identity Aware Proxy (IAP) OAuth client. The client is owned - * by IAP. Requires that the brand for the project exists and that it is - * set for internal-only use. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Path to create the client in. - * In the following format: - * projects/{project_number/id}/brands/{brand}. - * The project must belong to a G Suite account. - * @param {google.cloud.iap.v1.IdentityAwareProxyClient} request.identityAwareProxyClient - * Required. Identity Aware Proxy Client 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.iap.v1.IdentityAwareProxyClient|IdentityAwareProxyClient}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/identity_aware_proxy_o_auth_service.create_identity_aware_proxy_client.js - * region_tag:iap_v1_generated_IdentityAwareProxyOAuthService_CreateIdentityAwareProxyClient_async - */ + /** + * Creates an Identity Aware Proxy (IAP) OAuth client. The client is owned + * by IAP. Requires that the brand for the project exists and that it is + * set for internal-only use. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Path to create the client in. + * In the following format: + * projects/{project_number/id}/brands/{brand}. + * The project must belong to a G Suite account. + * @param {google.cloud.iap.v1.IdentityAwareProxyClient} request.identityAwareProxyClient + * Required. Identity Aware Proxy Client 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.iap.v1.IdentityAwareProxyClient|IdentityAwareProxyClient}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/identity_aware_proxy_o_auth_service.create_identity_aware_proxy_client.js + * region_tag:iap_v1_generated_IdentityAwareProxyOAuthService_CreateIdentityAwareProxyClient_async + */ createIdentityAwareProxyClient( - request?: protos.google.cloud.iap.v1.ICreateIdentityAwareProxyClientRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.iap.v1.IIdentityAwareProxyClient, - protos.google.cloud.iap.v1.ICreateIdentityAwareProxyClientRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.iap.v1.ICreateIdentityAwareProxyClientRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.iap.v1.IIdentityAwareProxyClient, + ( + | protos.google.cloud.iap.v1.ICreateIdentityAwareProxyClientRequest + | undefined + ), + {} | undefined, + ] + >; createIdentityAwareProxyClient( - request: protos.google.cloud.iap.v1.ICreateIdentityAwareProxyClientRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.iap.v1.IIdentityAwareProxyClient, - protos.google.cloud.iap.v1.ICreateIdentityAwareProxyClientRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.iap.v1.ICreateIdentityAwareProxyClientRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.iap.v1.IIdentityAwareProxyClient, + | protos.google.cloud.iap.v1.ICreateIdentityAwareProxyClientRequest + | null + | undefined, + {} | null | undefined + >, + ): void; createIdentityAwareProxyClient( - request: protos.google.cloud.iap.v1.ICreateIdentityAwareProxyClientRequest, - callback: Callback< - protos.google.cloud.iap.v1.IIdentityAwareProxyClient, - protos.google.cloud.iap.v1.ICreateIdentityAwareProxyClientRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.iap.v1.ICreateIdentityAwareProxyClientRequest, + callback: Callback< + protos.google.cloud.iap.v1.IIdentityAwareProxyClient, + | protos.google.cloud.iap.v1.ICreateIdentityAwareProxyClientRequest + | null + | undefined, + {} | null | undefined + >, + ): void; createIdentityAwareProxyClient( - request?: protos.google.cloud.iap.v1.ICreateIdentityAwareProxyClientRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.iap.v1.ICreateIdentityAwareProxyClientRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.iap.v1.IIdentityAwareProxyClient, - protos.google.cloud.iap.v1.ICreateIdentityAwareProxyClientRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.iap.v1.IIdentityAwareProxyClient, - protos.google.cloud.iap.v1.ICreateIdentityAwareProxyClientRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.iap.v1.IIdentityAwareProxyClient, - protos.google.cloud.iap.v1.ICreateIdentityAwareProxyClientRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.iap.v1.ICreateIdentityAwareProxyClientRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.iap.v1.IIdentityAwareProxyClient, + | protos.google.cloud.iap.v1.ICreateIdentityAwareProxyClientRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.iap.v1.IIdentityAwareProxyClient, + ( + | protos.google.cloud.iap.v1.ICreateIdentityAwareProxyClientRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.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('createIdentityAwareProxyClient request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.iap.v1.IIdentityAwareProxyClient, - protos.google.cloud.iap.v1.ICreateIdentityAwareProxyClientRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.iap.v1.IIdentityAwareProxyClient, + | protos.google.cloud.iap.v1.ICreateIdentityAwareProxyClientRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { - this._log.info('createIdentityAwareProxyClient response %j', response); + this._log.info( + 'createIdentityAwareProxyClient response %j', + response, + ); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.createIdentityAwareProxyClient(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.iap.v1.IIdentityAwareProxyClient, - protos.google.cloud.iap.v1.ICreateIdentityAwareProxyClientRequest|undefined, - {}|undefined - ]) => { - this._log.info('createIdentityAwareProxyClient response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .createIdentityAwareProxyClient(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.iap.v1.IIdentityAwareProxyClient, + ( + | protos.google.cloud.iap.v1.ICreateIdentityAwareProxyClientRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info( + 'createIdentityAwareProxyClient response %j', + response, + ); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 an Identity Aware Proxy (IAP) OAuth client. - * Requires that the client is owned by IAP. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the Identity Aware Proxy client to be fetched. - * In the following format: - * projects/{project_number/id}/brands/{brand}/identityAwareProxyClients/{client_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.iap.v1.IdentityAwareProxyClient|IdentityAwareProxyClient}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/identity_aware_proxy_o_auth_service.get_identity_aware_proxy_client.js - * region_tag:iap_v1_generated_IdentityAwareProxyOAuthService_GetIdentityAwareProxyClient_async - */ + /** + * Retrieves an Identity Aware Proxy (IAP) OAuth client. + * Requires that the client is owned by IAP. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the Identity Aware Proxy client to be fetched. + * In the following format: + * projects/{project_number/id}/brands/{brand}/identityAwareProxyClients/{client_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.iap.v1.IdentityAwareProxyClient|IdentityAwareProxyClient}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/identity_aware_proxy_o_auth_service.get_identity_aware_proxy_client.js + * region_tag:iap_v1_generated_IdentityAwareProxyOAuthService_GetIdentityAwareProxyClient_async + */ getIdentityAwareProxyClient( - request?: protos.google.cloud.iap.v1.IGetIdentityAwareProxyClientRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.iap.v1.IIdentityAwareProxyClient, - protos.google.cloud.iap.v1.IGetIdentityAwareProxyClientRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.iap.v1.IGetIdentityAwareProxyClientRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.iap.v1.IIdentityAwareProxyClient, + ( + | protos.google.cloud.iap.v1.IGetIdentityAwareProxyClientRequest + | undefined + ), + {} | undefined, + ] + >; getIdentityAwareProxyClient( - request: protos.google.cloud.iap.v1.IGetIdentityAwareProxyClientRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.iap.v1.IIdentityAwareProxyClient, - protos.google.cloud.iap.v1.IGetIdentityAwareProxyClientRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.iap.v1.IGetIdentityAwareProxyClientRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.iap.v1.IIdentityAwareProxyClient, + | protos.google.cloud.iap.v1.IGetIdentityAwareProxyClientRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getIdentityAwareProxyClient( - request: protos.google.cloud.iap.v1.IGetIdentityAwareProxyClientRequest, - callback: Callback< - protos.google.cloud.iap.v1.IIdentityAwareProxyClient, - protos.google.cloud.iap.v1.IGetIdentityAwareProxyClientRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.iap.v1.IGetIdentityAwareProxyClientRequest, + callback: Callback< + protos.google.cloud.iap.v1.IIdentityAwareProxyClient, + | protos.google.cloud.iap.v1.IGetIdentityAwareProxyClientRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getIdentityAwareProxyClient( - request?: protos.google.cloud.iap.v1.IGetIdentityAwareProxyClientRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.iap.v1.IIdentityAwareProxyClient, - protos.google.cloud.iap.v1.IGetIdentityAwareProxyClientRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.iap.v1.IGetIdentityAwareProxyClientRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.iap.v1.IIdentityAwareProxyClient, - protos.google.cloud.iap.v1.IGetIdentityAwareProxyClientRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.iap.v1.IIdentityAwareProxyClient, - protos.google.cloud.iap.v1.IGetIdentityAwareProxyClientRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.iap.v1.IGetIdentityAwareProxyClientRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.iap.v1.IIdentityAwareProxyClient, + | protos.google.cloud.iap.v1.IGetIdentityAwareProxyClientRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.iap.v1.IIdentityAwareProxyClient, + ( + | protos.google.cloud.iap.v1.IGetIdentityAwareProxyClientRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getIdentityAwareProxyClient request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.iap.v1.IIdentityAwareProxyClient, - protos.google.cloud.iap.v1.IGetIdentityAwareProxyClientRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.iap.v1.IIdentityAwareProxyClient, + | protos.google.cloud.iap.v1.IGetIdentityAwareProxyClientRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getIdentityAwareProxyClient response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getIdentityAwareProxyClient(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.iap.v1.IIdentityAwareProxyClient, - protos.google.cloud.iap.v1.IGetIdentityAwareProxyClientRequest|undefined, - {}|undefined - ]) => { - this._log.info('getIdentityAwareProxyClient response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getIdentityAwareProxyClient(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.iap.v1.IIdentityAwareProxyClient, + ( + | protos.google.cloud.iap.v1.IGetIdentityAwareProxyClientRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getIdentityAwareProxyClient response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Resets an Identity Aware Proxy (IAP) OAuth client secret. Useful if the - * secret was compromised. Requires that the client is owned by IAP. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the Identity Aware Proxy client to that will have its - * secret reset. In the following format: - * projects/{project_number/id}/brands/{brand}/identityAwareProxyClients/{client_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.iap.v1.IdentityAwareProxyClient|IdentityAwareProxyClient}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/identity_aware_proxy_o_auth_service.reset_identity_aware_proxy_client_secret.js - * region_tag:iap_v1_generated_IdentityAwareProxyOAuthService_ResetIdentityAwareProxyClientSecret_async - */ + /** + * Resets an Identity Aware Proxy (IAP) OAuth client secret. Useful if the + * secret was compromised. Requires that the client is owned by IAP. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the Identity Aware Proxy client to that will have its + * secret reset. In the following format: + * projects/{project_number/id}/brands/{brand}/identityAwareProxyClients/{client_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.iap.v1.IdentityAwareProxyClient|IdentityAwareProxyClient}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/identity_aware_proxy_o_auth_service.reset_identity_aware_proxy_client_secret.js + * region_tag:iap_v1_generated_IdentityAwareProxyOAuthService_ResetIdentityAwareProxyClientSecret_async + */ resetIdentityAwareProxyClientSecret( - request?: protos.google.cloud.iap.v1.IResetIdentityAwareProxyClientSecretRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.iap.v1.IIdentityAwareProxyClient, - protos.google.cloud.iap.v1.IResetIdentityAwareProxyClientSecretRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.iap.v1.IResetIdentityAwareProxyClientSecretRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.iap.v1.IIdentityAwareProxyClient, + ( + | protos.google.cloud.iap.v1.IResetIdentityAwareProxyClientSecretRequest + | undefined + ), + {} | undefined, + ] + >; resetIdentityAwareProxyClientSecret( - request: protos.google.cloud.iap.v1.IResetIdentityAwareProxyClientSecretRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.iap.v1.IIdentityAwareProxyClient, - protos.google.cloud.iap.v1.IResetIdentityAwareProxyClientSecretRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.iap.v1.IResetIdentityAwareProxyClientSecretRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.iap.v1.IIdentityAwareProxyClient, + | protos.google.cloud.iap.v1.IResetIdentityAwareProxyClientSecretRequest + | null + | undefined, + {} | null | undefined + >, + ): void; resetIdentityAwareProxyClientSecret( - request: protos.google.cloud.iap.v1.IResetIdentityAwareProxyClientSecretRequest, - callback: Callback< - protos.google.cloud.iap.v1.IIdentityAwareProxyClient, - protos.google.cloud.iap.v1.IResetIdentityAwareProxyClientSecretRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.iap.v1.IResetIdentityAwareProxyClientSecretRequest, + callback: Callback< + protos.google.cloud.iap.v1.IIdentityAwareProxyClient, + | protos.google.cloud.iap.v1.IResetIdentityAwareProxyClientSecretRequest + | null + | undefined, + {} | null | undefined + >, + ): void; resetIdentityAwareProxyClientSecret( - request?: protos.google.cloud.iap.v1.IResetIdentityAwareProxyClientSecretRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.iap.v1.IIdentityAwareProxyClient, - protos.google.cloud.iap.v1.IResetIdentityAwareProxyClientSecretRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.iap.v1.IResetIdentityAwareProxyClientSecretRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.iap.v1.IIdentityAwareProxyClient, - protos.google.cloud.iap.v1.IResetIdentityAwareProxyClientSecretRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.iap.v1.IIdentityAwareProxyClient, - protos.google.cloud.iap.v1.IResetIdentityAwareProxyClientSecretRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.iap.v1.IResetIdentityAwareProxyClientSecretRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.iap.v1.IIdentityAwareProxyClient, + | protos.google.cloud.iap.v1.IResetIdentityAwareProxyClientSecretRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.iap.v1.IIdentityAwareProxyClient, + ( + | protos.google.cloud.iap.v1.IResetIdentityAwareProxyClientSecretRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('resetIdentityAwareProxyClientSecret request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.iap.v1.IIdentityAwareProxyClient, - protos.google.cloud.iap.v1.IResetIdentityAwareProxyClientSecretRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.iap.v1.IIdentityAwareProxyClient, + | protos.google.cloud.iap.v1.IResetIdentityAwareProxyClientSecretRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { - this._log.info('resetIdentityAwareProxyClientSecret response %j', response); + this._log.info( + 'resetIdentityAwareProxyClientSecret response %j', + response, + ); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.resetIdentityAwareProxyClientSecret(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.iap.v1.IIdentityAwareProxyClient, - protos.google.cloud.iap.v1.IResetIdentityAwareProxyClientSecretRequest|undefined, - {}|undefined - ]) => { - this._log.info('resetIdentityAwareProxyClientSecret response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .resetIdentityAwareProxyClientSecret(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.iap.v1.IIdentityAwareProxyClient, + ( + | protos.google.cloud.iap.v1.IResetIdentityAwareProxyClientSecretRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info( + 'resetIdentityAwareProxyClientSecret response %j', + response, + ); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 Identity Aware Proxy (IAP) OAuth client. Useful for removing - * obsolete clients, managing the number of clients in a given project, and - * cleaning up after tests. Requires that the client is owned by IAP. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the Identity Aware Proxy client to be deleted. - * In the following format: - * projects/{project_number/id}/brands/{brand}/identityAwareProxyClients/{client_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/v1/identity_aware_proxy_o_auth_service.delete_identity_aware_proxy_client.js - * region_tag:iap_v1_generated_IdentityAwareProxyOAuthService_DeleteIdentityAwareProxyClient_async - */ + /** + * Deletes an Identity Aware Proxy (IAP) OAuth client. Useful for removing + * obsolete clients, managing the number of clients in a given project, and + * cleaning up after tests. Requires that the client is owned by IAP. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the Identity Aware Proxy client to be deleted. + * In the following format: + * projects/{project_number/id}/brands/{brand}/identityAwareProxyClients/{client_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/v1/identity_aware_proxy_o_auth_service.delete_identity_aware_proxy_client.js + * region_tag:iap_v1_generated_IdentityAwareProxyOAuthService_DeleteIdentityAwareProxyClient_async + */ deleteIdentityAwareProxyClient( - request?: protos.google.cloud.iap.v1.IDeleteIdentityAwareProxyClientRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.iap.v1.IDeleteIdentityAwareProxyClientRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.iap.v1.IDeleteIdentityAwareProxyClientRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.iap.v1.IDeleteIdentityAwareProxyClientRequest + | undefined + ), + {} | undefined, + ] + >; deleteIdentityAwareProxyClient( - request: protos.google.cloud.iap.v1.IDeleteIdentityAwareProxyClientRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.iap.v1.IDeleteIdentityAwareProxyClientRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.iap.v1.IDeleteIdentityAwareProxyClientRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.iap.v1.IDeleteIdentityAwareProxyClientRequest + | null + | undefined, + {} | null | undefined + >, + ): void; deleteIdentityAwareProxyClient( - request: protos.google.cloud.iap.v1.IDeleteIdentityAwareProxyClientRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.iap.v1.IDeleteIdentityAwareProxyClientRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.iap.v1.IDeleteIdentityAwareProxyClientRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.iap.v1.IDeleteIdentityAwareProxyClientRequest + | null + | undefined, + {} | null | undefined + >, + ): void; deleteIdentityAwareProxyClient( - request?: protos.google.cloud.iap.v1.IDeleteIdentityAwareProxyClientRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.iap.v1.IDeleteIdentityAwareProxyClientRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.iap.v1.IDeleteIdentityAwareProxyClientRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.protobuf.IEmpty, - protos.google.cloud.iap.v1.IDeleteIdentityAwareProxyClientRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.iap.v1.IDeleteIdentityAwareProxyClientRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.iap.v1.IDeleteIdentityAwareProxyClientRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.iap.v1.IDeleteIdentityAwareProxyClientRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.iap.v1.IDeleteIdentityAwareProxyClientRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('deleteIdentityAwareProxyClient request %j', request); - const wrappedCallback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.iap.v1.IDeleteIdentityAwareProxyClientRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.iap.v1.IDeleteIdentityAwareProxyClientRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { - this._log.info('deleteIdentityAwareProxyClient response %j', response); + this._log.info( + 'deleteIdentityAwareProxyClient response %j', + response, + ); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.deleteIdentityAwareProxyClient(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.protobuf.IEmpty, - protos.google.cloud.iap.v1.IDeleteIdentityAwareProxyClientRequest|undefined, - {}|undefined - ]) => { - this._log.info('deleteIdentityAwareProxyClient response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .deleteIdentityAwareProxyClient(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.iap.v1.IDeleteIdentityAwareProxyClientRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info( + 'deleteIdentityAwareProxyClient response %j', + response, + ); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 the existing clients for the brand. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Full brand path. - * In the following format: projects/{project_number/id}/brands/{brand}. - * @param {number} request.pageSize - * The maximum number of clients to return. The service may return fewer than - * this value. - * If unspecified, at most 100 clients 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 `ListIdentityAwareProxyClients` - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * `ListIdentityAwareProxyClients` 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.iap.v1.IdentityAwareProxyClient|IdentityAwareProxyClient}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listIdentityAwareProxyClientsAsync()` - * method described below for async iteration which you can stop as 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 existing clients for the brand. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Full brand path. + * In the following format: projects/{project_number/id}/brands/{brand}. + * @param {number} request.pageSize + * The maximum number of clients to return. The service may return fewer than + * this value. + * If unspecified, at most 100 clients 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 `ListIdentityAwareProxyClients` + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * `ListIdentityAwareProxyClients` 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.iap.v1.IdentityAwareProxyClient|IdentityAwareProxyClient}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listIdentityAwareProxyClientsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listIdentityAwareProxyClients( - request?: protos.google.cloud.iap.v1.IListIdentityAwareProxyClientsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.iap.v1.IIdentityAwareProxyClient[], - protos.google.cloud.iap.v1.IListIdentityAwareProxyClientsRequest|null, - protos.google.cloud.iap.v1.IListIdentityAwareProxyClientsResponse - ]>; + request?: protos.google.cloud.iap.v1.IListIdentityAwareProxyClientsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.iap.v1.IIdentityAwareProxyClient[], + protos.google.cloud.iap.v1.IListIdentityAwareProxyClientsRequest | null, + protos.google.cloud.iap.v1.IListIdentityAwareProxyClientsResponse, + ] + >; listIdentityAwareProxyClients( - request: protos.google.cloud.iap.v1.IListIdentityAwareProxyClientsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.iap.v1.IListIdentityAwareProxyClientsRequest, - protos.google.cloud.iap.v1.IListIdentityAwareProxyClientsResponse|null|undefined, - protos.google.cloud.iap.v1.IIdentityAwareProxyClient>): void; + request: protos.google.cloud.iap.v1.IListIdentityAwareProxyClientsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.iap.v1.IListIdentityAwareProxyClientsRequest, + | protos.google.cloud.iap.v1.IListIdentityAwareProxyClientsResponse + | null + | undefined, + protos.google.cloud.iap.v1.IIdentityAwareProxyClient + >, + ): void; listIdentityAwareProxyClients( - request: protos.google.cloud.iap.v1.IListIdentityAwareProxyClientsRequest, - callback: PaginationCallback< - protos.google.cloud.iap.v1.IListIdentityAwareProxyClientsRequest, - protos.google.cloud.iap.v1.IListIdentityAwareProxyClientsResponse|null|undefined, - protos.google.cloud.iap.v1.IIdentityAwareProxyClient>): void; + request: protos.google.cloud.iap.v1.IListIdentityAwareProxyClientsRequest, + callback: PaginationCallback< + protos.google.cloud.iap.v1.IListIdentityAwareProxyClientsRequest, + | protos.google.cloud.iap.v1.IListIdentityAwareProxyClientsResponse + | null + | undefined, + protos.google.cloud.iap.v1.IIdentityAwareProxyClient + >, + ): void; listIdentityAwareProxyClients( - request?: protos.google.cloud.iap.v1.IListIdentityAwareProxyClientsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< + request?: protos.google.cloud.iap.v1.IListIdentityAwareProxyClientsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.iap.v1.IListIdentityAwareProxyClientsRequest, - protos.google.cloud.iap.v1.IListIdentityAwareProxyClientsResponse|null|undefined, - protos.google.cloud.iap.v1.IIdentityAwareProxyClient>, - callback?: PaginationCallback< - protos.google.cloud.iap.v1.IListIdentityAwareProxyClientsRequest, - protos.google.cloud.iap.v1.IListIdentityAwareProxyClientsResponse|null|undefined, - protos.google.cloud.iap.v1.IIdentityAwareProxyClient>): - Promise<[ - protos.google.cloud.iap.v1.IIdentityAwareProxyClient[], - protos.google.cloud.iap.v1.IListIdentityAwareProxyClientsRequest|null, - protos.google.cloud.iap.v1.IListIdentityAwareProxyClientsResponse - ]>|void { + | protos.google.cloud.iap.v1.IListIdentityAwareProxyClientsResponse + | null + | undefined, + protos.google.cloud.iap.v1.IIdentityAwareProxyClient + >, + callback?: PaginationCallback< + protos.google.cloud.iap.v1.IListIdentityAwareProxyClientsRequest, + | protos.google.cloud.iap.v1.IListIdentityAwareProxyClientsResponse + | null + | undefined, + protos.google.cloud.iap.v1.IIdentityAwareProxyClient + >, + ): Promise< + [ + protos.google.cloud.iap.v1.IIdentityAwareProxyClient[], + protos.google.cloud.iap.v1.IListIdentityAwareProxyClientsRequest | null, + protos.google.cloud.iap.v1.IListIdentityAwareProxyClientsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-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.iap.v1.IListIdentityAwareProxyClientsRequest, - protos.google.cloud.iap.v1.IListIdentityAwareProxyClientsResponse|null|undefined, - protos.google.cloud.iap.v1.IIdentityAwareProxyClient>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.iap.v1.IListIdentityAwareProxyClientsRequest, + | protos.google.cloud.iap.v1.IListIdentityAwareProxyClientsResponse + | null + | undefined, + protos.google.cloud.iap.v1.IIdentityAwareProxyClient + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listIdentityAwareProxyClients values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1130,124 +1515,128 @@ export class IdentityAwareProxyOAuthServiceClient { this._log.info('listIdentityAwareProxyClients request %j', request); return this.innerApiCalls .listIdentityAwareProxyClients(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.iap.v1.IIdentityAwareProxyClient[], - protos.google.cloud.iap.v1.IListIdentityAwareProxyClientsRequest|null, - protos.google.cloud.iap.v1.IListIdentityAwareProxyClientsResponse - ]) => { - this._log.info('listIdentityAwareProxyClients values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.iap.v1.IIdentityAwareProxyClient[], + protos.google.cloud.iap.v1.IListIdentityAwareProxyClientsRequest | null, + protos.google.cloud.iap.v1.IListIdentityAwareProxyClientsResponse, + ]) => { + this._log.info('listIdentityAwareProxyClients values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listIdentityAwareProxyClients`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Full brand path. - * In the following format: projects/{project_number/id}/brands/{brand}. - * @param {number} request.pageSize - * The maximum number of clients to return. The service may return fewer than - * this value. - * If unspecified, at most 100 clients 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 `ListIdentityAwareProxyClients` - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * `ListIdentityAwareProxyClients` 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.iap.v1.IdentityAwareProxyClient|IdentityAwareProxyClient} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listIdentityAwareProxyClientsAsync()` - * method described below for async iteration which you can stop as 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 `listIdentityAwareProxyClients`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Full brand path. + * In the following format: projects/{project_number/id}/brands/{brand}. + * @param {number} request.pageSize + * The maximum number of clients to return. The service may return fewer than + * this value. + * If unspecified, at most 100 clients 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 `ListIdentityAwareProxyClients` + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * `ListIdentityAwareProxyClients` 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.iap.v1.IdentityAwareProxyClient|IdentityAwareProxyClient} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listIdentityAwareProxyClientsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listIdentityAwareProxyClientsStream( - request?: protos.google.cloud.iap.v1.IListIdentityAwareProxyClientsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.iap.v1.IListIdentityAwareProxyClientsRequest, + 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['listIdentityAwareProxyClients']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listIdentityAwareProxyClients stream %j', request); return this.descriptors.page.listIdentityAwareProxyClients.createStream( this.innerApiCalls.listIdentityAwareProxyClients as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listIdentityAwareProxyClients`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Full brand path. - * In the following format: projects/{project_number/id}/brands/{brand}. - * @param {number} request.pageSize - * The maximum number of clients to return. The service may return fewer than - * this value. - * If unspecified, at most 100 clients 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 `ListIdentityAwareProxyClients` - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * `ListIdentityAwareProxyClients` 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.iap.v1.IdentityAwareProxyClient|IdentityAwareProxyClient}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@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/identity_aware_proxy_o_auth_service.list_identity_aware_proxy_clients.js - * region_tag:iap_v1_generated_IdentityAwareProxyOAuthService_ListIdentityAwareProxyClients_async - */ + /** + * Equivalent to `listIdentityAwareProxyClients`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Full brand path. + * In the following format: projects/{project_number/id}/brands/{brand}. + * @param {number} request.pageSize + * The maximum number of clients to return. The service may return fewer than + * this value. + * If unspecified, at most 100 clients 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 `ListIdentityAwareProxyClients` + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * `ListIdentityAwareProxyClients` 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.iap.v1.IdentityAwareProxyClient|IdentityAwareProxyClient}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@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/identity_aware_proxy_o_auth_service.list_identity_aware_proxy_clients.js + * region_tag:iap_v1_generated_IdentityAwareProxyOAuthService_ListIdentityAwareProxyClients_async + */ listIdentityAwareProxyClientsAsync( - request?: protos.google.cloud.iap.v1.IListIdentityAwareProxyClientsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.iap.v1.IListIdentityAwareProxyClientsRequest, + 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['listIdentityAwareProxyClients']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listIdentityAwareProxyClients iterate %j', request); return this.descriptors.page.listIdentityAwareProxyClients.asyncIterate( this.innerApiCalls['listIdentityAwareProxyClients'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } // -------------------- @@ -1260,7 +1649,7 @@ export class IdentityAwareProxyOAuthServiceClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -1285,7 +1674,7 @@ export class IdentityAwareProxyOAuthServiceClient { * @param {string} dest_group * @returns {string} Resource name string. */ - tunnelDestGroupPath(project:string,location:string,destGroup:string) { + tunnelDestGroupPath(project: string, location: string, destGroup: string) { return this.pathTemplates.tunnelDestGroupPathTemplate.render({ project: project, location: location, @@ -1301,7 +1690,9 @@ export class IdentityAwareProxyOAuthServiceClient { * @returns {string} A string representing the project. */ matchProjectFromTunnelDestGroupName(tunnelDestGroupName: string) { - return this.pathTemplates.tunnelDestGroupPathTemplate.match(tunnelDestGroupName).project; + return this.pathTemplates.tunnelDestGroupPathTemplate.match( + tunnelDestGroupName, + ).project; } /** @@ -1312,7 +1703,9 @@ export class IdentityAwareProxyOAuthServiceClient { * @returns {string} A string representing the location. */ matchLocationFromTunnelDestGroupName(tunnelDestGroupName: string) { - return this.pathTemplates.tunnelDestGroupPathTemplate.match(tunnelDestGroupName).location; + return this.pathTemplates.tunnelDestGroupPathTemplate.match( + tunnelDestGroupName, + ).location; } /** @@ -1323,7 +1716,9 @@ export class IdentityAwareProxyOAuthServiceClient { * @returns {string} A string representing the dest_group. */ matchDestGroupFromTunnelDestGroupName(tunnelDestGroupName: string) { - return this.pathTemplates.tunnelDestGroupPathTemplate.match(tunnelDestGroupName).dest_group; + return this.pathTemplates.tunnelDestGroupPathTemplate.match( + tunnelDestGroupName, + ).dest_group; } /** @@ -1333,7 +1728,7 @@ export class IdentityAwareProxyOAuthServiceClient { * @param {string} location * @returns {string} Resource name string. */ - tunnelLocationPath(project:string,location:string) { + tunnelLocationPath(project: string, location: string) { return this.pathTemplates.tunnelLocationPathTemplate.render({ project: project, location: location, @@ -1348,7 +1743,9 @@ export class IdentityAwareProxyOAuthServiceClient { * @returns {string} A string representing the project. */ matchProjectFromTunnelLocationName(tunnelLocationName: string) { - return this.pathTemplates.tunnelLocationPathTemplate.match(tunnelLocationName).project; + return this.pathTemplates.tunnelLocationPathTemplate.match( + tunnelLocationName, + ).project; } /** @@ -1359,7 +1756,9 @@ export class IdentityAwareProxyOAuthServiceClient { * @returns {string} A string representing the location. */ matchLocationFromTunnelLocationName(tunnelLocationName: string) { - return this.pathTemplates.tunnelLocationPathTemplate.match(tunnelLocationName).location; + return this.pathTemplates.tunnelLocationPathTemplate.match( + tunnelLocationName, + ).location; } /** @@ -1370,7 +1769,7 @@ export class IdentityAwareProxyOAuthServiceClient { */ close(): Promise { if (this.identityAwareProxyOAuthServiceStub && !this._terminated) { - return this.identityAwareProxyOAuthServiceStub.then(stub => { + return this.identityAwareProxyOAuthServiceStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); @@ -1378,4 +1777,4 @@ export class IdentityAwareProxyOAuthServiceClient { } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-iap/src/v1/index.ts b/packages/google-cloud-iap/src/v1/index.ts index 5d9f33cc7c63..b812bf689c13 100644 --- a/packages/google-cloud-iap/src/v1/index.ts +++ b/packages/google-cloud-iap/src/v1/index.ts @@ -16,5 +16,5 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {IdentityAwareProxyAdminServiceClient} from './identity_aware_proxy_admin_service_client'; -export {IdentityAwareProxyOAuthServiceClient} from './identity_aware_proxy_o_auth_service_client'; +export { IdentityAwareProxyAdminServiceClient } from './identity_aware_proxy_admin_service_client'; +export { IdentityAwareProxyOAuthServiceClient } from './identity_aware_proxy_o_auth_service_client'; diff --git a/packages/google-cloud-iap/src/v1beta1/identity_aware_proxy_admin_v1_beta1_client.ts b/packages/google-cloud-iap/src/v1beta1/identity_aware_proxy_admin_v1_beta1_client.ts index b51e903a1db2..225f28d41827 100644 --- a/packages/google-cloud-iap/src/v1beta1/identity_aware_proxy_admin_v1_beta1_client.ts +++ b/packages/google-cloud-iap/src/v1beta1/identity_aware_proxy_admin_v1_beta1_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 IdentityAwareProxyAdminV1Beta1Client { 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('iap'); @@ -57,8 +62,8 @@ export class IdentityAwareProxyAdminV1Beta1Client { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - identityAwareProxyAdminV1Beta1Stub?: Promise<{[name: string]: Function}>; + innerApiCalls: { [name: string]: Function }; + identityAwareProxyAdminV1Beta1Stub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of IdentityAwareProxyAdminV1Beta1Client. @@ -99,21 +104,43 @@ export class IdentityAwareProxyAdminV1Beta1Client { * const client = new IdentityAwareProxyAdminV1Beta1Client({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 IdentityAwareProxyAdminV1Beta1Client; - 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 IdentityAwareProxyAdminV1Beta1Client; + 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 = 'iap.' + 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; @@ -138,7 +165,7 @@ export class IdentityAwareProxyAdminV1Beta1Client { 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; @@ -152,10 +179,7 @@ export class IdentityAwareProxyAdminV1Beta1Client { } // 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 { @@ -174,8 +198,11 @@ export class IdentityAwareProxyAdminV1Beta1Client { // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.iap.v1beta1.IdentityAwareProxyAdminV1Beta1', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.iap.v1beta1.IdentityAwareProxyAdminV1Beta1', + 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 @@ -206,36 +233,45 @@ export class IdentityAwareProxyAdminV1Beta1Client { // Put together the "service stub" for // google.cloud.iap.v1beta1.IdentityAwareProxyAdminV1Beta1. this.identityAwareProxyAdminV1Beta1Stub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.iap.v1beta1.IdentityAwareProxyAdminV1Beta1') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.iap.v1beta1.IdentityAwareProxyAdminV1Beta1, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.iap.v1beta1.IdentityAwareProxyAdminV1Beta1', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.iap.v1beta1 + .IdentityAwareProxyAdminV1Beta1, + 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 identityAwareProxyAdminV1Beta1StubMethods = - ['setIamPolicy', 'getIamPolicy', 'testIamPermissions']; + const identityAwareProxyAdminV1Beta1StubMethods = [ + 'setIamPolicy', + 'getIamPolicy', + 'testIamPermissions', + ]; for (const methodName of identityAwareProxyAdminV1Beta1StubMethods) { const callPromise = this.identityAwareProxyAdminV1Beta1Stub.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; @@ -250,8 +286,14 @@ export class IdentityAwareProxyAdminV1Beta1Client { * @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 'iap.googleapis.com'; } @@ -262,8 +304,14 @@ export class IdentityAwareProxyAdminV1Beta1Client { * @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 'iap.googleapis.com'; } @@ -294,9 +342,7 @@ export class IdentityAwareProxyAdminV1Beta1Client { * @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; @@ -305,8 +351,9 @@ export class IdentityAwareProxyAdminV1Beta1Client { * 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; @@ -317,323 +364,412 @@ export class IdentityAwareProxyAdminV1Beta1Client { // ------------------- // -- Service calls -- // ------------------- -/** - * Sets the access control policy for an Identity-Aware Proxy protected - * resource. Replaces any existing policy. - * More information about managing access via IAP can be found at: - * https://cloud.google.com/iap/docs/managing-access#managing_access_via_the_api - * - * @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/identity_aware_proxy_admin_v1_beta1.set_iam_policy.js - * region_tag:iap_v1beta1_generated_IdentityAwareProxyAdminV1Beta1_SetIamPolicy_async - */ + /** + * Sets the access control policy for an Identity-Aware Proxy protected + * resource. Replaces any existing policy. + * More information about managing access via IAP can be found at: + * https://cloud.google.com/iap/docs/managing-access#managing_access_via_the_api + * + * @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/identity_aware_proxy_admin_v1_beta1.set_iam_policy.js + * region_tag:iap_v1beta1_generated_IdentityAwareProxyAdminV1Beta1_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; }); } -/** - * Gets the access control policy for an Identity-Aware Proxy protected - * resource. - * More information about managing access via IAP can be found at: - * https://cloud.google.com/iap/docs/managing-access#managing_access_via_the_api - * - * @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/identity_aware_proxy_admin_v1_beta1.get_iam_policy.js - * region_tag:iap_v1beta1_generated_IdentityAwareProxyAdminV1Beta1_GetIamPolicy_async - */ + /** + * Gets the access control policy for an Identity-Aware Proxy protected + * resource. + * More information about managing access via IAP can be found at: + * https://cloud.google.com/iap/docs/managing-access#managing_access_via_the_api + * + * @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/identity_aware_proxy_admin_v1_beta1.get_iam_policy.js + * region_tag:iap_v1beta1_generated_IdentityAwareProxyAdminV1Beta1_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< + 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< - 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; }); } -/** - * Returns permissions that a caller has on the Identity-Aware Proxy protected - * resource. If the resource does not exist or the caller does not have - * Identity-Aware Proxy permissions a [google.rpc.Code.PERMISSION_DENIED] - * will be returned. - * More information about managing access via IAP can be found at: - * https://cloud.google.com/iap/docs/managing-access#managing_access_via_the_api - * - * @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/identity_aware_proxy_admin_v1_beta1.test_iam_permissions.js - * region_tag:iap_v1beta1_generated_IdentityAwareProxyAdminV1Beta1_TestIamPermissions_async - */ + /** + * Returns permissions that a caller has on the Identity-Aware Proxy protected + * resource. If the resource does not exist or the caller does not have + * Identity-Aware Proxy permissions a [google.rpc.Code.PERMISSION_DENIED] + * will be returned. + * More information about managing access via IAP can be found at: + * https://cloud.google.com/iap/docs/managing-access#managing_access_via_the_api + * + * @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/identity_aware_proxy_admin_v1_beta1.test_iam_permissions.js + * region_tag:iap_v1beta1_generated_IdentityAwareProxyAdminV1Beta1_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; }); } - /** * Terminate the gRPC channel and close the client. * @@ -642,7 +778,7 @@ export class IdentityAwareProxyAdminV1Beta1Client { */ close(): Promise { if (this.identityAwareProxyAdminV1Beta1Stub && !this._terminated) { - return this.identityAwareProxyAdminV1Beta1Stub.then(stub => { + return this.identityAwareProxyAdminV1Beta1Stub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); @@ -650,4 +786,4 @@ export class IdentityAwareProxyAdminV1Beta1Client { } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-iap/src/v1beta1/index.ts b/packages/google-cloud-iap/src/v1beta1/index.ts index c52b6608d7dd..2aebfd202011 100644 --- a/packages/google-cloud-iap/src/v1beta1/index.ts +++ b/packages/google-cloud-iap/src/v1beta1/index.ts @@ -16,4 +16,4 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {IdentityAwareProxyAdminV1Beta1Client} from './identity_aware_proxy_admin_v1_beta1_client'; +export { IdentityAwareProxyAdminV1Beta1Client } from './identity_aware_proxy_admin_v1_beta1_client'; diff --git a/packages/google-cloud-iap/system-test/fixtures/sample/src/index.ts b/packages/google-cloud-iap/system-test/fixtures/sample/src/index.ts index 0a6c4bdc6530..b18354206145 100644 --- a/packages/google-cloud-iap/system-test/fixtures/sample/src/index.ts +++ b/packages/google-cloud-iap/system-test/fixtures/sample/src/index.ts @@ -16,23 +16,36 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -import {IdentityAwareProxyAdminServiceClient, IdentityAwareProxyOAuthServiceClient} from '@google-cloud/iap'; +import { + IdentityAwareProxyAdminServiceClient, + IdentityAwareProxyOAuthServiceClient, +} from '@google-cloud/iap'; // check that the client class type name can be used -function doStuffWithIdentityAwareProxyAdminServiceClient(client: IdentityAwareProxyAdminServiceClient) { +function doStuffWithIdentityAwareProxyAdminServiceClient( + client: IdentityAwareProxyAdminServiceClient, +) { client.close(); } -function doStuffWithIdentityAwareProxyOAuthServiceClient(client: IdentityAwareProxyOAuthServiceClient) { +function doStuffWithIdentityAwareProxyOAuthServiceClient( + client: IdentityAwareProxyOAuthServiceClient, +) { client.close(); } function main() { // check that the client instance can be created - const identityAwareProxyAdminServiceClient = new IdentityAwareProxyAdminServiceClient(); - doStuffWithIdentityAwareProxyAdminServiceClient(identityAwareProxyAdminServiceClient); + const identityAwareProxyAdminServiceClient = + new IdentityAwareProxyAdminServiceClient(); + doStuffWithIdentityAwareProxyAdminServiceClient( + identityAwareProxyAdminServiceClient, + ); // check that the client instance can be created - const identityAwareProxyOAuthServiceClient = new IdentityAwareProxyOAuthServiceClient(); - doStuffWithIdentityAwareProxyOAuthServiceClient(identityAwareProxyOAuthServiceClient); + const identityAwareProxyOAuthServiceClient = + new IdentityAwareProxyOAuthServiceClient(); + doStuffWithIdentityAwareProxyOAuthServiceClient( + identityAwareProxyOAuthServiceClient, + ); } main(); diff --git a/packages/google-cloud-iap/system-test/install.ts b/packages/google-cloud-iap/system-test/install.ts index f66069aa3940..ccf167042d2e 100644 --- a/packages/google-cloud-iap/system-test/install.ts +++ b/packages/google-cloud-iap/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-iap/test/gapic_identity_aware_proxy_admin_service_v1.ts b/packages/google-cloud-iap/test/gapic_identity_aware_proxy_admin_service_v1.ts index 8f6cb7f258df..3c8f78111ea3 100644 --- a/packages/google-cloud-iap/test/gapic_identity_aware_proxy_admin_service_v1.ts +++ b/packages/google-cloud-iap/test/gapic_identity_aware_proxy_admin_service_v1.ts @@ -19,1693 +19,2295 @@ 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 identityawareproxyadminserviceModule 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.IdentityAwareProxyAdminServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'iap.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient(); - 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 = identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient.servicePath; - assert.strictEqual(servicePath, 'iap.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'iap.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'iap.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'iap.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 identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'iap.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 identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'iap.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 identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); - - it('has port', () => { - const port = identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.identityAwareProxyAdminServiceStub, undefined); - await client.initialize(); - assert(client.identityAwareProxyAdminServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.identityAwareProxyAdminServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = + new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'iap.googleapis.com'); + }); - it('has close method for the non-initialized client', done => { - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.identityAwareProxyAdminServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has universeDomain', () => { + const client = + new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + identityawareproxyadminserviceModule.v1 + .IdentityAwareProxyAdminServiceClient.servicePath; + assert.strictEqual(servicePath, 'iap.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + identityawareproxyadminserviceModule.v1 + .IdentityAwareProxyAdminServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'iap.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = + new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { universeDomain: 'example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'iap.example.com'); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = + new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { universe_domain: 'example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'iap.example.com'); }); - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({ - 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)); + 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 identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'iap.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - it('invokes setIamPolicy without error using callback', async () => { - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({ - 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('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 identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { universeDomain: 'configured.example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'iap.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 identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { universe_domain: 'example.com', universeDomain: 'example.net' }, + ); + }); + }); - it('invokes setIamPolicy with error', async () => { - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({ - 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('has port', () => { + const port = + identityawareproxyadminserviceModule.v1 + .IdentityAwareProxyAdminServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('invokes setIamPolicy with closed client', async () => { - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({ - 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('should create a client with no option', () => { + const client = + new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient(); + assert(client); }); - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({ - 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('should create a client with gRPC fallback', () => { + const client = + new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { + fallback: true, + }, + ); + assert(client); + }); - it('invokes getIamPolicy without error using callback', async () => { - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({ - 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('has initialize method and supports deferred initialization', async () => { + const client = + new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + assert.strictEqual(client.identityAwareProxyAdminServiceStub, undefined); + await client.initialize(); + assert(client.identityAwareProxyAdminServiceStub); + }); - it('invokes getIamPolicy with error', async () => { - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({ - 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('has close method for the initialized client', (done) => { + const client = + new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + client.initialize().catch((err) => { + throw err; + }); + assert(client.identityAwareProxyAdminServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes getIamPolicy with closed client', async () => { - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({ - 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('has close method for the non-initialized client', (done) => { + const client = + new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + assert.strictEqual(client.identityAwareProxyAdminServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({ - 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('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { + 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 testIamPermissions without error using callback', async () => { - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({ - 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('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { + 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('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = + new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { + 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 with error', async () => { - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({ - 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 without error using callback', async () => { + const client = + new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { + 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 closed client', async () => { - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({ - 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 error', async () => { + const client = + new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { + 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)); }); - describe('getIapSettings', () => { - it('invokes getIapSettings without error', async () => { - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.GetIapSettingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.GetIapSettingsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.iap.v1.IapSettings() - ); - client.innerApiCalls.getIapSettings = stubSimpleCall(expectedResponse); - const [response] = await client.getIapSettings(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getIapSettings as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getIapSettings 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 identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { + 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('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = + new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { + 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 getIapSettings without error using callback', async () => { - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.GetIapSettingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.GetIapSettingsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.iap.v1.IapSettings() - ); - client.innerApiCalls.getIapSettings = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIapSettings( - request, - (err?: Error|null, result?: protos.google.cloud.iap.v1.IIapSettings|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getIapSettings as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getIapSettings 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 identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { + 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 getIapSettings with error', async () => { - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.GetIapSettingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.GetIapSettingsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getIapSettings = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIapSettings(request), expectedError); - const actualRequest = (client.innerApiCalls.getIapSettings as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getIapSettings 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 identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { + 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 getIapSettings with closed client', async () => { - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.GetIapSettingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.GetIapSettingsRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getIapSettings(request), expectedError); - }); + it('invokes getIamPolicy with closed client', async () => { + const client = + new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { + 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('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = + new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { + 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('updateIapSettings', () => { - it('invokes updateIapSettings without error', async () => { - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.UpdateIapSettingsRequest() - ); - request.iapSettings ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.UpdateIapSettingsRequest', ['iapSettings', 'name']); - request.iapSettings.name = defaultValue1; - const expectedHeaderRequestParams = `iap_settings.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.iap.v1.IapSettings() - ); - client.innerApiCalls.updateIapSettings = stubSimpleCall(expectedResponse); - const [response] = await client.updateIapSettings(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateIapSettings as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateIapSettings 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 identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { + 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 updateIapSettings without error using callback', async () => { - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.UpdateIapSettingsRequest() - ); - request.iapSettings ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.UpdateIapSettingsRequest', ['iapSettings', 'name']); - request.iapSettings.name = defaultValue1; - const expectedHeaderRequestParams = `iap_settings.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.iap.v1.IapSettings() - ); - client.innerApiCalls.updateIapSettings = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateIapSettings( - request, - (err?: Error|null, result?: protos.google.cloud.iap.v1.IIapSettings|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateIapSettings as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateIapSettings 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 identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { + 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 updateIapSettings with error', async () => { - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.UpdateIapSettingsRequest() - ); - request.iapSettings ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.UpdateIapSettingsRequest', ['iapSettings', 'name']); - request.iapSettings.name = defaultValue1; - const expectedHeaderRequestParams = `iap_settings.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateIapSettings = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateIapSettings(request), expectedError); - const actualRequest = (client.innerApiCalls.updateIapSettings as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateIapSettings 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 identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { + 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('getIapSettings', () => { + it('invokes getIapSettings without error', async () => { + const client = + new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.GetIapSettingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.GetIapSettingsRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.iap.v1.IapSettings(), + ); + client.innerApiCalls.getIapSettings = stubSimpleCall(expectedResponse); + const [response] = await client.getIapSettings(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getIapSettings as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getIapSettings as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateIapSettings with closed client', async () => { - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.UpdateIapSettingsRequest() - ); - request.iapSettings ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.UpdateIapSettingsRequest', ['iapSettings', 'name']); - request.iapSettings.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.updateIapSettings(request), expectedError); - }); + it('invokes getIapSettings without error using callback', async () => { + const client = + new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.GetIapSettingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.GetIapSettingsRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.iap.v1.IapSettings(), + ); + client.innerApiCalls.getIapSettings = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIapSettings( + request, + ( + err?: Error | null, + result?: protos.google.cloud.iap.v1.IIapSettings | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getIapSettings as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getIapSettings as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('validateIapAttributeExpression', () => { - it('invokes validateIapAttributeExpression without error', async () => { - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.ValidateIapAttributeExpressionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.ValidateIapAttributeExpressionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.iap.v1.ValidateIapAttributeExpressionResponse() - ); - client.innerApiCalls.validateIapAttributeExpression = stubSimpleCall(expectedResponse); - const [response] = await client.validateIapAttributeExpression(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.validateIapAttributeExpression as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.validateIapAttributeExpression as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getIapSettings with error', async () => { + const client = + new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.GetIapSettingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.GetIapSettingsRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getIapSettings = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getIapSettings(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getIapSettings as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getIapSettings as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes validateIapAttributeExpression without error using callback', async () => { - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.ValidateIapAttributeExpressionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.ValidateIapAttributeExpressionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.iap.v1.ValidateIapAttributeExpressionResponse() - ); - client.innerApiCalls.validateIapAttributeExpression = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.validateIapAttributeExpression( - request, - (err?: Error|null, result?: protos.google.cloud.iap.v1.IValidateIapAttributeExpressionResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.validateIapAttributeExpression as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.validateIapAttributeExpression as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getIapSettings with closed client', async () => { + const client = + new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.GetIapSettingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.GetIapSettingsRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getIapSettings(request), expectedError); + }); + }); + + describe('updateIapSettings', () => { + it('invokes updateIapSettings without error', async () => { + const client = + new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.UpdateIapSettingsRequest(), + ); + request.iapSettings ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.UpdateIapSettingsRequest', + ['iapSettings', 'name'], + ); + request.iapSettings.name = defaultValue1; + const expectedHeaderRequestParams = `iap_settings.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.iap.v1.IapSettings(), + ); + client.innerApiCalls.updateIapSettings = stubSimpleCall(expectedResponse); + const [response] = await client.updateIapSettings(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateIapSettings as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateIapSettings as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes validateIapAttributeExpression with error', async () => { - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.ValidateIapAttributeExpressionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.ValidateIapAttributeExpressionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.validateIapAttributeExpression = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.validateIapAttributeExpression(request), expectedError); - const actualRequest = (client.innerApiCalls.validateIapAttributeExpression as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.validateIapAttributeExpression as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateIapSettings without error using callback', async () => { + const client = + new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.UpdateIapSettingsRequest(), + ); + request.iapSettings ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.UpdateIapSettingsRequest', + ['iapSettings', 'name'], + ); + request.iapSettings.name = defaultValue1; + const expectedHeaderRequestParams = `iap_settings.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.iap.v1.IapSettings(), + ); + client.innerApiCalls.updateIapSettings = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateIapSettings( + request, + ( + err?: Error | null, + result?: protos.google.cloud.iap.v1.IIapSettings | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateIapSettings as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateIapSettings as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes validateIapAttributeExpression with closed client', async () => { - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.ValidateIapAttributeExpressionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.ValidateIapAttributeExpressionRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.validateIapAttributeExpression(request), expectedError); - }); + it('invokes updateIapSettings with error', async () => { + const client = + new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.UpdateIapSettingsRequest(), + ); + request.iapSettings ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.UpdateIapSettingsRequest', + ['iapSettings', 'name'], + ); + request.iapSettings.name = defaultValue1; + const expectedHeaderRequestParams = `iap_settings.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateIapSettings = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateIapSettings(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateIapSettings as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateIapSettings as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createTunnelDestGroup', () => { - it('invokes createTunnelDestGroup without error', async () => { - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.CreateTunnelDestGroupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.CreateTunnelDestGroupRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.iap.v1.TunnelDestGroup() - ); - client.innerApiCalls.createTunnelDestGroup = stubSimpleCall(expectedResponse); - const [response] = await client.createTunnelDestGroup(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createTunnelDestGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createTunnelDestGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateIapSettings with closed client', async () => { + const client = + new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.UpdateIapSettingsRequest(), + ); + request.iapSettings ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.UpdateIapSettingsRequest', + ['iapSettings', 'name'], + ); + request.iapSettings.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.updateIapSettings(request), expectedError); + }); + }); + + describe('validateIapAttributeExpression', () => { + it('invokes validateIapAttributeExpression without error', async () => { + const client = + new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.ValidateIapAttributeExpressionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.ValidateIapAttributeExpressionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.iap.v1.ValidateIapAttributeExpressionResponse(), + ); + client.innerApiCalls.validateIapAttributeExpression = + stubSimpleCall(expectedResponse); + const [response] = await client.validateIapAttributeExpression(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.validateIapAttributeExpression as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.validateIapAttributeExpression as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createTunnelDestGroup without error using callback', async () => { - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.CreateTunnelDestGroupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.CreateTunnelDestGroupRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.iap.v1.TunnelDestGroup() - ); - client.innerApiCalls.createTunnelDestGroup = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createTunnelDestGroup( - request, - (err?: Error|null, result?: protos.google.cloud.iap.v1.ITunnelDestGroup|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createTunnelDestGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createTunnelDestGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes validateIapAttributeExpression without error using callback', async () => { + const client = + new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.ValidateIapAttributeExpressionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.ValidateIapAttributeExpressionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.iap.v1.ValidateIapAttributeExpressionResponse(), + ); + client.innerApiCalls.validateIapAttributeExpression = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.validateIapAttributeExpression( + request, + ( + err?: Error | null, + result?: protos.google.cloud.iap.v1.IValidateIapAttributeExpressionResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.validateIapAttributeExpression as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.validateIapAttributeExpression as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createTunnelDestGroup with error', async () => { - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.CreateTunnelDestGroupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.CreateTunnelDestGroupRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createTunnelDestGroup = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createTunnelDestGroup(request), expectedError); - const actualRequest = (client.innerApiCalls.createTunnelDestGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createTunnelDestGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes validateIapAttributeExpression with error', async () => { + const client = + new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.ValidateIapAttributeExpressionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.ValidateIapAttributeExpressionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.validateIapAttributeExpression = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.validateIapAttributeExpression(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.validateIapAttributeExpression as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.validateIapAttributeExpression as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createTunnelDestGroup with closed client', async () => { - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.CreateTunnelDestGroupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.CreateTunnelDestGroupRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.createTunnelDestGroup(request), expectedError); - }); + it('invokes validateIapAttributeExpression with closed client', async () => { + const client = + new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.ValidateIapAttributeExpressionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.ValidateIapAttributeExpressionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.validateIapAttributeExpression(request), + expectedError, + ); + }); + }); + + describe('createTunnelDestGroup', () => { + it('invokes createTunnelDestGroup without error', async () => { + const client = + new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.CreateTunnelDestGroupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.CreateTunnelDestGroupRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.iap.v1.TunnelDestGroup(), + ); + client.innerApiCalls.createTunnelDestGroup = + stubSimpleCall(expectedResponse); + const [response] = await client.createTunnelDestGroup(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createTunnelDestGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTunnelDestGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getTunnelDestGroup', () => { - it('invokes getTunnelDestGroup without error', async () => { - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.GetTunnelDestGroupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.GetTunnelDestGroupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.iap.v1.TunnelDestGroup() - ); - client.innerApiCalls.getTunnelDestGroup = stubSimpleCall(expectedResponse); - const [response] = await client.getTunnelDestGroup(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getTunnelDestGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getTunnelDestGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createTunnelDestGroup without error using callback', async () => { + const client = + new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.CreateTunnelDestGroupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.CreateTunnelDestGroupRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.iap.v1.TunnelDestGroup(), + ); + client.innerApiCalls.createTunnelDestGroup = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createTunnelDestGroup( + request, + ( + err?: Error | null, + result?: protos.google.cloud.iap.v1.ITunnelDestGroup | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createTunnelDestGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTunnelDestGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getTunnelDestGroup without error using callback', async () => { - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.GetTunnelDestGroupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.GetTunnelDestGroupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.iap.v1.TunnelDestGroup() - ); - client.innerApiCalls.getTunnelDestGroup = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getTunnelDestGroup( - request, - (err?: Error|null, result?: protos.google.cloud.iap.v1.ITunnelDestGroup|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getTunnelDestGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getTunnelDestGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createTunnelDestGroup with error', async () => { + const client = + new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.CreateTunnelDestGroupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.CreateTunnelDestGroupRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createTunnelDestGroup = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.createTunnelDestGroup(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.createTunnelDestGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTunnelDestGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getTunnelDestGroup with error', async () => { - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.GetTunnelDestGroupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.GetTunnelDestGroupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getTunnelDestGroup = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getTunnelDestGroup(request), expectedError); - const actualRequest = (client.innerApiCalls.getTunnelDestGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getTunnelDestGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createTunnelDestGroup with closed client', async () => { + const client = + new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.CreateTunnelDestGroupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.CreateTunnelDestGroupRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.createTunnelDestGroup(request), + expectedError, + ); + }); + }); + + describe('getTunnelDestGroup', () => { + it('invokes getTunnelDestGroup without error', async () => { + const client = + new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.GetTunnelDestGroupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.GetTunnelDestGroupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.iap.v1.TunnelDestGroup(), + ); + client.innerApiCalls.getTunnelDestGroup = + stubSimpleCall(expectedResponse); + const [response] = await client.getTunnelDestGroup(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getTunnelDestGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTunnelDestGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getTunnelDestGroup with closed client', async () => { - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.GetTunnelDestGroupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.GetTunnelDestGroupRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getTunnelDestGroup(request), expectedError); - }); + it('invokes getTunnelDestGroup without error using callback', async () => { + const client = + new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.GetTunnelDestGroupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.GetTunnelDestGroupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.iap.v1.TunnelDestGroup(), + ); + client.innerApiCalls.getTunnelDestGroup = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getTunnelDestGroup( + request, + ( + err?: Error | null, + result?: protos.google.cloud.iap.v1.ITunnelDestGroup | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getTunnelDestGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTunnelDestGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteTunnelDestGroup', () => { - it('invokes deleteTunnelDestGroup without error', async () => { - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.DeleteTunnelDestGroupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.DeleteTunnelDestGroupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteTunnelDestGroup = stubSimpleCall(expectedResponse); - const [response] = await client.deleteTunnelDestGroup(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteTunnelDestGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteTunnelDestGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getTunnelDestGroup with error', async () => { + const client = + new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.GetTunnelDestGroupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.GetTunnelDestGroupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getTunnelDestGroup = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getTunnelDestGroup(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getTunnelDestGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTunnelDestGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteTunnelDestGroup without error using callback', async () => { - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.DeleteTunnelDestGroupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.DeleteTunnelDestGroupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteTunnelDestGroup = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteTunnelDestGroup( - 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.deleteTunnelDestGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteTunnelDestGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getTunnelDestGroup with closed client', async () => { + const client = + new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.GetTunnelDestGroupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.GetTunnelDestGroupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getTunnelDestGroup(request), expectedError); + }); + }); + + describe('deleteTunnelDestGroup', () => { + it('invokes deleteTunnelDestGroup without error', async () => { + const client = + new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.DeleteTunnelDestGroupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.DeleteTunnelDestGroupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteTunnelDestGroup = + stubSimpleCall(expectedResponse); + const [response] = await client.deleteTunnelDestGroup(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteTunnelDestGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTunnelDestGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteTunnelDestGroup with error', async () => { - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.DeleteTunnelDestGroupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.DeleteTunnelDestGroupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteTunnelDestGroup = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteTunnelDestGroup(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteTunnelDestGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteTunnelDestGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteTunnelDestGroup without error using callback', async () => { + const client = + new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.DeleteTunnelDestGroupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.DeleteTunnelDestGroupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteTunnelDestGroup = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteTunnelDestGroup( + 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.deleteTunnelDestGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTunnelDestGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteTunnelDestGroup with closed client', async () => { - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.DeleteTunnelDestGroupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.DeleteTunnelDestGroupRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.deleteTunnelDestGroup(request), expectedError); - }); + it('invokes deleteTunnelDestGroup with error', async () => { + const client = + new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.DeleteTunnelDestGroupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.DeleteTunnelDestGroupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteTunnelDestGroup = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.deleteTunnelDestGroup(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.deleteTunnelDestGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTunnelDestGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateTunnelDestGroup', () => { - it('invokes updateTunnelDestGroup without error', async () => { - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.UpdateTunnelDestGroupRequest() - ); - request.tunnelDestGroup ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.UpdateTunnelDestGroupRequest', ['tunnelDestGroup', 'name']); - request.tunnelDestGroup.name = defaultValue1; - const expectedHeaderRequestParams = `tunnel_dest_group.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.iap.v1.TunnelDestGroup() - ); - client.innerApiCalls.updateTunnelDestGroup = stubSimpleCall(expectedResponse); - const [response] = await client.updateTunnelDestGroup(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateTunnelDestGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateTunnelDestGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteTunnelDestGroup with closed client', async () => { + const client = + new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.DeleteTunnelDestGroupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.DeleteTunnelDestGroupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.deleteTunnelDestGroup(request), + expectedError, + ); + }); + }); + + describe('updateTunnelDestGroup', () => { + it('invokes updateTunnelDestGroup without error', async () => { + const client = + new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.UpdateTunnelDestGroupRequest(), + ); + request.tunnelDestGroup ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.UpdateTunnelDestGroupRequest', + ['tunnelDestGroup', 'name'], + ); + request.tunnelDestGroup.name = defaultValue1; + const expectedHeaderRequestParams = `tunnel_dest_group.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.iap.v1.TunnelDestGroup(), + ); + client.innerApiCalls.updateTunnelDestGroup = + stubSimpleCall(expectedResponse); + const [response] = await client.updateTunnelDestGroup(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateTunnelDestGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateTunnelDestGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateTunnelDestGroup without error using callback', async () => { - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.UpdateTunnelDestGroupRequest() - ); - request.tunnelDestGroup ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.UpdateTunnelDestGroupRequest', ['tunnelDestGroup', 'name']); - request.tunnelDestGroup.name = defaultValue1; - const expectedHeaderRequestParams = `tunnel_dest_group.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.iap.v1.TunnelDestGroup() - ); - client.innerApiCalls.updateTunnelDestGroup = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateTunnelDestGroup( - request, - (err?: Error|null, result?: protos.google.cloud.iap.v1.ITunnelDestGroup|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateTunnelDestGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateTunnelDestGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateTunnelDestGroup without error using callback', async () => { + const client = + new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.UpdateTunnelDestGroupRequest(), + ); + request.tunnelDestGroup ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.UpdateTunnelDestGroupRequest', + ['tunnelDestGroup', 'name'], + ); + request.tunnelDestGroup.name = defaultValue1; + const expectedHeaderRequestParams = `tunnel_dest_group.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.iap.v1.TunnelDestGroup(), + ); + client.innerApiCalls.updateTunnelDestGroup = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateTunnelDestGroup( + request, + ( + err?: Error | null, + result?: protos.google.cloud.iap.v1.ITunnelDestGroup | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateTunnelDestGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateTunnelDestGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateTunnelDestGroup with error', async () => { - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.UpdateTunnelDestGroupRequest() - ); - request.tunnelDestGroup ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.UpdateTunnelDestGroupRequest', ['tunnelDestGroup', 'name']); - request.tunnelDestGroup.name = defaultValue1; - const expectedHeaderRequestParams = `tunnel_dest_group.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateTunnelDestGroup = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateTunnelDestGroup(request), expectedError); - const actualRequest = (client.innerApiCalls.updateTunnelDestGroup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateTunnelDestGroup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateTunnelDestGroup with error', async () => { + const client = + new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.UpdateTunnelDestGroupRequest(), + ); + request.tunnelDestGroup ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.UpdateTunnelDestGroupRequest', + ['tunnelDestGroup', 'name'], + ); + request.tunnelDestGroup.name = defaultValue1; + const expectedHeaderRequestParams = `tunnel_dest_group.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateTunnelDestGroup = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.updateTunnelDestGroup(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.updateTunnelDestGroup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateTunnelDestGroup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateTunnelDestGroup with closed client', async () => { - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.UpdateTunnelDestGroupRequest() - ); - request.tunnelDestGroup ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.UpdateTunnelDestGroupRequest', ['tunnelDestGroup', 'name']); - request.tunnelDestGroup.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.updateTunnelDestGroup(request), expectedError); - }); + it('invokes updateTunnelDestGroup with closed client', async () => { + const client = + new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.UpdateTunnelDestGroupRequest(), + ); + request.tunnelDestGroup ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.UpdateTunnelDestGroupRequest', + ['tunnelDestGroup', 'name'], + ); + request.tunnelDestGroup.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.updateTunnelDestGroup(request), + expectedError, + ); + }); + }); + + describe('listTunnelDestGroups', () => { + it('invokes listTunnelDestGroups without error', async () => { + const client = + new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.ListTunnelDestGroupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.ListTunnelDestGroupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.iap.v1.TunnelDestGroup()), + generateSampleMessage(new protos.google.cloud.iap.v1.TunnelDestGroup()), + generateSampleMessage(new protos.google.cloud.iap.v1.TunnelDestGroup()), + ]; + client.innerApiCalls.listTunnelDestGroups = + stubSimpleCall(expectedResponse); + const [response] = await client.listTunnelDestGroups(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listTunnelDestGroups as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTunnelDestGroups as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listTunnelDestGroups', () => { - it('invokes listTunnelDestGroups without error', async () => { - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.ListTunnelDestGroupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.ListTunnelDestGroupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.iap.v1.TunnelDestGroup()), - generateSampleMessage(new protos.google.cloud.iap.v1.TunnelDestGroup()), - generateSampleMessage(new protos.google.cloud.iap.v1.TunnelDestGroup()), - ]; - client.innerApiCalls.listTunnelDestGroups = stubSimpleCall(expectedResponse); - const [response] = await client.listTunnelDestGroups(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listTunnelDestGroups as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listTunnelDestGroups as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listTunnelDestGroups without error using callback', async () => { + const client = + new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.ListTunnelDestGroupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.ListTunnelDestGroupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.iap.v1.TunnelDestGroup()), + generateSampleMessage(new protos.google.cloud.iap.v1.TunnelDestGroup()), + generateSampleMessage(new protos.google.cloud.iap.v1.TunnelDestGroup()), + ]; + client.innerApiCalls.listTunnelDestGroups = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listTunnelDestGroups( + request, + ( + err?: Error | null, + result?: protos.google.cloud.iap.v1.ITunnelDestGroup[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listTunnelDestGroups as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTunnelDestGroups as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listTunnelDestGroups without error using callback', async () => { - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.ListTunnelDestGroupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.ListTunnelDestGroupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.iap.v1.TunnelDestGroup()), - generateSampleMessage(new protos.google.cloud.iap.v1.TunnelDestGroup()), - generateSampleMessage(new protos.google.cloud.iap.v1.TunnelDestGroup()), - ]; - client.innerApiCalls.listTunnelDestGroups = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listTunnelDestGroups( - request, - (err?: Error|null, result?: protos.google.cloud.iap.v1.ITunnelDestGroup[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listTunnelDestGroups as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listTunnelDestGroups as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listTunnelDestGroups with error', async () => { + const client = + new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.ListTunnelDestGroupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.ListTunnelDestGroupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listTunnelDestGroups = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listTunnelDestGroups(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listTunnelDestGroups as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTunnelDestGroups as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listTunnelDestGroups with error', async () => { - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.ListTunnelDestGroupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.ListTunnelDestGroupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listTunnelDestGroups = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listTunnelDestGroups(request), expectedError); - const actualRequest = (client.innerApiCalls.listTunnelDestGroups as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listTunnelDestGroups as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes listTunnelDestGroupsStream without error', async () => { + const client = + new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.ListTunnelDestGroupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.ListTunnelDestGroupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.iap.v1.TunnelDestGroup()), + generateSampleMessage(new protos.google.cloud.iap.v1.TunnelDestGroup()), + generateSampleMessage(new protos.google.cloud.iap.v1.TunnelDestGroup()), + ]; + client.descriptors.page.listTunnelDestGroups.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listTunnelDestGroupsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.iap.v1.TunnelDestGroup[] = []; + stream.on( + 'data', + (response: protos.google.cloud.iap.v1.TunnelDestGroup) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('invokes listTunnelDestGroupsStream without error', async () => { - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.ListTunnelDestGroupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.ListTunnelDestGroupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.iap.v1.TunnelDestGroup()), - generateSampleMessage(new protos.google.cloud.iap.v1.TunnelDestGroup()), - generateSampleMessage(new protos.google.cloud.iap.v1.TunnelDestGroup()), - ]; - client.descriptors.page.listTunnelDestGroups.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listTunnelDestGroupsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.iap.v1.TunnelDestGroup[] = []; - stream.on('data', (response: protos.google.cloud.iap.v1.TunnelDestGroup) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listTunnelDestGroups.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listTunnelDestGroups, request)); - assert( - (client.descriptors.page.listTunnelDestGroups.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.listTunnelDestGroups.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listTunnelDestGroups, request), + ); + assert( + (client.descriptors.page.listTunnelDestGroups.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listTunnelDestGroupsStream with error', async () => { - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.ListTunnelDestGroupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.ListTunnelDestGroupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listTunnelDestGroups.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listTunnelDestGroupsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.iap.v1.TunnelDestGroup[] = []; - stream.on('data', (response: protos.google.cloud.iap.v1.TunnelDestGroup) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listTunnelDestGroups.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listTunnelDestGroups, request)); - assert( - (client.descriptors.page.listTunnelDestGroups.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); + it('invokes listTunnelDestGroupsStream with error', async () => { + const client = + new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.ListTunnelDestGroupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.ListTunnelDestGroupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listTunnelDestGroups.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listTunnelDestGroupsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.iap.v1.TunnelDestGroup[] = []; + stream.on( + 'data', + (response: protos.google.cloud.iap.v1.TunnelDestGroup) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('uses async iteration with listTunnelDestGroups without error', async () => { - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.ListTunnelDestGroupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.ListTunnelDestGroupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.iap.v1.TunnelDestGroup()), - generateSampleMessage(new protos.google.cloud.iap.v1.TunnelDestGroup()), - generateSampleMessage(new protos.google.cloud.iap.v1.TunnelDestGroup()), - ]; - client.descriptors.page.listTunnelDestGroups.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.iap.v1.ITunnelDestGroup[] = []; - const iterable = client.listTunnelDestGroupsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listTunnelDestGroups.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listTunnelDestGroups.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.listTunnelDestGroups.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listTunnelDestGroups, request), + ); + assert( + (client.descriptors.page.listTunnelDestGroups.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listTunnelDestGroups with error', async () => { - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.ListTunnelDestGroupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.ListTunnelDestGroupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listTunnelDestGroups.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listTunnelDestGroupsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.iap.v1.ITunnelDestGroup[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listTunnelDestGroups.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listTunnelDestGroups.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listTunnelDestGroups without error', async () => { + const client = + new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.ListTunnelDestGroupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.ListTunnelDestGroupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.iap.v1.TunnelDestGroup()), + generateSampleMessage(new protos.google.cloud.iap.v1.TunnelDestGroup()), + generateSampleMessage(new protos.google.cloud.iap.v1.TunnelDestGroup()), + ]; + client.descriptors.page.listTunnelDestGroups.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.iap.v1.ITunnelDestGroup[] = []; + const iterable = client.listTunnelDestGroupsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listTunnelDestGroups.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listTunnelDestGroups.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 identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({ - 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 listTunnelDestGroups with error', async () => { + const client = + new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.ListTunnelDestGroupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.ListTunnelDestGroupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listTunnelDestGroups.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listTunnelDestGroupsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.iap.v1.ITunnelDestGroup[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listTunnelDestGroups.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listTunnelDestGroups.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 identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { + 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('tunnelDestGroup', async () => { - const fakePath = "/rendered/path/tunnelDestGroup"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - dest_group: "destGroupValue", - }; - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.tunnelDestGroupPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tunnelDestGroupPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tunnelDestGroupPath', () => { - const result = client.tunnelDestGroupPath("projectValue", "locationValue", "destGroupValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tunnelDestGroupPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromTunnelDestGroupName', () => { - const result = client.matchProjectFromTunnelDestGroupName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.tunnelDestGroupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromTunnelDestGroupName', () => { - const result = client.matchLocationFromTunnelDestGroupName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.tunnelDestGroupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDestGroupFromTunnelDestGroupName', () => { - const result = client.matchDestGroupFromTunnelDestGroupName(fakePath); - assert.strictEqual(result, "destGroupValue"); - assert((client.pathTemplates.tunnelDestGroupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('tunnelDestGroup', async () => { + const fakePath = '/rendered/path/tunnelDestGroup'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + dest_group: 'destGroupValue', + }; + const client = + new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.tunnelDestGroupPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.tunnelDestGroupPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('tunnelDestGroupPath', () => { + const result = client.tunnelDestGroupPath( + 'projectValue', + 'locationValue', + 'destGroupValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.tunnelDestGroupPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromTunnelDestGroupName', () => { + const result = client.matchProjectFromTunnelDestGroupName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.tunnelDestGroupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromTunnelDestGroupName', () => { + const result = client.matchLocationFromTunnelDestGroupName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.tunnelDestGroupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchDestGroupFromTunnelDestGroupName', () => { + const result = client.matchDestGroupFromTunnelDestGroupName(fakePath); + assert.strictEqual(result, 'destGroupValue'); + assert( + (client.pathTemplates.tunnelDestGroupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('tunnelLocation', async () => { - const fakePath = "/rendered/path/tunnelLocation"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.tunnelLocationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tunnelLocationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tunnelLocationPath', () => { - const result = client.tunnelLocationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tunnelLocationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromTunnelLocationName', () => { - const result = client.matchProjectFromTunnelLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.tunnelLocationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromTunnelLocationName', () => { - const result = client.matchLocationFromTunnelLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.tunnelLocationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('tunnelLocation', async () => { + const fakePath = '/rendered/path/tunnelLocation'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = + new identityawareproxyadminserviceModule.v1.IdentityAwareProxyAdminServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.tunnelLocationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.tunnelLocationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('tunnelLocationPath', () => { + const result = client.tunnelLocationPath( + 'projectValue', + 'locationValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.tunnelLocationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromTunnelLocationName', () => { + const result = client.matchProjectFromTunnelLocationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.tunnelLocationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromTunnelLocationName', () => { + const result = client.matchLocationFromTunnelLocationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.tunnelLocationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-iap/test/gapic_identity_aware_proxy_admin_v1_beta1_v1beta1.ts b/packages/google-cloud-iap/test/gapic_identity_aware_proxy_admin_v1_beta1_v1beta1.ts index 5c69e28201a3..5e75bf05b1f0 100644 --- a/packages/google-cloud-iap/test/gapic_identity_aware_proxy_admin_v1_beta1_v1beta1.ts +++ b/packages/google-cloud-iap/test/gapic_identity_aware_proxy_admin_v1_beta1_v1beta1.ts @@ -19,520 +19,699 @@ 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 identityawareproxyadminv1beta1Module 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('v1beta1.IdentityAwareProxyAdminV1Beta1Client', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new identityawareproxyadminv1beta1Module.v1beta1.IdentityAwareProxyAdminV1Beta1Client(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'iap.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new identityawareproxyadminv1beta1Module.v1beta1.IdentityAwareProxyAdminV1Beta1Client(); - 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 = identityawareproxyadminv1beta1Module.v1beta1.IdentityAwareProxyAdminV1Beta1Client.servicePath; - assert.strictEqual(servicePath, 'iap.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = identityawareproxyadminv1beta1Module.v1beta1.IdentityAwareProxyAdminV1Beta1Client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'iap.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new identityawareproxyadminv1beta1Module.v1beta1.IdentityAwareProxyAdminV1Beta1Client({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'iap.example.com'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = + new identityawareproxyadminv1beta1Module.v1beta1.IdentityAwareProxyAdminV1Beta1Client(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'iap.googleapis.com'); + }); - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new identityawareproxyadminv1beta1Module.v1beta1.IdentityAwareProxyAdminV1Beta1Client({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'iap.example.com'); - }); + it('has universeDomain', () => { + const client = + new identityawareproxyadminv1beta1Module.v1beta1.IdentityAwareProxyAdminV1Beta1Client(); + 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 identityawareproxyadminv1beta1Module.v1beta1.IdentityAwareProxyAdminV1Beta1Client(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'iap.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 identityawareproxyadminv1beta1Module.v1beta1.IdentityAwareProxyAdminV1Beta1Client({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'iap.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 identityawareproxyadminv1beta1Module.v1beta1.IdentityAwareProxyAdminV1Beta1Client({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 = + identityawareproxyadminv1beta1Module.v1beta1 + .IdentityAwareProxyAdminV1Beta1Client.servicePath; + assert.strictEqual(servicePath, 'iap.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + identityawareproxyadminv1beta1Module.v1beta1 + .IdentityAwareProxyAdminV1Beta1Client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'iap.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = + new identityawareproxyadminv1beta1Module.v1beta1.IdentityAwareProxyAdminV1Beta1Client( + { universeDomain: 'example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'iap.example.com'); + }); - it('has port', () => { - const port = identityawareproxyadminv1beta1Module.v1beta1.IdentityAwareProxyAdminV1Beta1Client.port; - assert(port); - assert(typeof port === 'number'); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = + new identityawareproxyadminv1beta1Module.v1beta1.IdentityAwareProxyAdminV1Beta1Client( + { universe_domain: 'example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'iap.example.com'); + }); - it('should create a client with no option', () => { - const client = new identityawareproxyadminv1beta1Module.v1beta1.IdentityAwareProxyAdminV1Beta1Client(); - 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 identityawareproxyadminv1beta1Module.v1beta1.IdentityAwareProxyAdminV1Beta1Client(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'iap.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 identityawareproxyadminv1beta1Module.v1beta1.IdentityAwareProxyAdminV1Beta1Client({ - 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 identityawareproxyadminv1beta1Module.v1beta1.IdentityAwareProxyAdminV1Beta1Client( + { universeDomain: 'configured.example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'iap.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 identityawareproxyadminv1beta1Module.v1beta1.IdentityAwareProxyAdminV1Beta1Client( + { universe_domain: 'example.com', universeDomain: 'example.net' }, + ); + }); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new identityawareproxyadminv1beta1Module.v1beta1.IdentityAwareProxyAdminV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.identityAwareProxyAdminV1Beta1Stub, undefined); - await client.initialize(); - assert(client.identityAwareProxyAdminV1Beta1Stub); - }); + it('has port', () => { + const port = + identityawareproxyadminv1beta1Module.v1beta1 + .IdentityAwareProxyAdminV1Beta1Client.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has close method for the initialized client', done => { - const client = new identityawareproxyadminv1beta1Module.v1beta1.IdentityAwareProxyAdminV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.identityAwareProxyAdminV1Beta1Stub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('should create a client with no option', () => { + const client = + new identityawareproxyadminv1beta1Module.v1beta1.IdentityAwareProxyAdminV1Beta1Client(); + assert(client); + }); - it('has close method for the non-initialized client', done => { - const client = new identityawareproxyadminv1beta1Module.v1beta1.IdentityAwareProxyAdminV1Beta1Client({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.identityAwareProxyAdminV1Beta1Stub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('should create a client with gRPC fallback', () => { + const client = + new identityawareproxyadminv1beta1Module.v1beta1.IdentityAwareProxyAdminV1Beta1Client( + { + fallback: true, + }, + ); + assert(client); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new identityawareproxyadminv1beta1Module.v1beta1.IdentityAwareProxyAdminV1Beta1Client({ - 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 identityawareproxyadminv1beta1Module.v1beta1.IdentityAwareProxyAdminV1Beta1Client( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + assert.strictEqual(client.identityAwareProxyAdminV1Beta1Stub, undefined); + await client.initialize(); + assert(client.identityAwareProxyAdminV1Beta1Stub); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new identityawareproxyadminv1beta1Module.v1beta1.IdentityAwareProxyAdminV1Beta1Client({ - 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 identityawareproxyadminv1beta1Module.v1beta1.IdentityAwareProxyAdminV1Beta1Client( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + client.initialize().catch((err) => { + throw err; + }); + assert(client.identityAwareProxyAdminV1Beta1Stub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new identityawareproxyadminv1beta1Module.v1beta1.IdentityAwareProxyAdminV1Beta1Client({ - 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('has close method for the non-initialized client', (done) => { + const client = + new identityawareproxyadminv1beta1Module.v1beta1.IdentityAwareProxyAdminV1Beta1Client( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + assert.strictEqual(client.identityAwareProxyAdminV1Beta1Stub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes setIamPolicy without error using callback', async () => { - const client = new identityawareproxyadminv1beta1Module.v1beta1.IdentityAwareProxyAdminV1Beta1Client({ - 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('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new identityawareproxyadminv1beta1Module.v1beta1.IdentityAwareProxyAdminV1Beta1Client( + { + 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 setIamPolicy with error', async () => { - const client = new identityawareproxyadminv1beta1Module.v1beta1.IdentityAwareProxyAdminV1Beta1Client({ - 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('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new identityawareproxyadminv1beta1Module.v1beta1.IdentityAwareProxyAdminV1Beta1Client( + { + 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('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = + new identityawareproxyadminv1beta1Module.v1beta1.IdentityAwareProxyAdminV1Beta1Client( + { + 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 with closed client', async () => { - const client = new identityawareproxyadminv1beta1Module.v1beta1.IdentityAwareProxyAdminV1Beta1Client({ - 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 without error using callback', async () => { + const client = + new identityawareproxyadminv1beta1Module.v1beta1.IdentityAwareProxyAdminV1Beta1Client( + { + 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)); }); - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new identityawareproxyadminv1beta1Module.v1beta1.IdentityAwareProxyAdminV1Beta1Client({ - 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 identityawareproxyadminv1beta1Module.v1beta1.IdentityAwareProxyAdminV1Beta1Client( + { + 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 identityawareproxyadminv1beta1Module.v1beta1.IdentityAwareProxyAdminV1Beta1Client({ - 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 identityawareproxyadminv1beta1Module.v1beta1.IdentityAwareProxyAdminV1Beta1Client( + { + 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('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = + new identityawareproxyadminv1beta1Module.v1beta1.IdentityAwareProxyAdminV1Beta1Client( + { + 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 identityawareproxyadminv1beta1Module.v1beta1.IdentityAwareProxyAdminV1Beta1Client({ - 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 identityawareproxyadminv1beta1Module.v1beta1.IdentityAwareProxyAdminV1Beta1Client( + { + 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 identityawareproxyadminv1beta1Module.v1beta1.IdentityAwareProxyAdminV1Beta1Client({ - 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 identityawareproxyadminv1beta1Module.v1beta1.IdentityAwareProxyAdminV1Beta1Client( + { + 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 identityawareproxyadminv1beta1Module.v1beta1.IdentityAwareProxyAdminV1Beta1Client({ - 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 identityawareproxyadminv1beta1Module.v1beta1.IdentityAwareProxyAdminV1Beta1Client( + { + 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('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = + new identityawareproxyadminv1beta1Module.v1beta1.IdentityAwareProxyAdminV1Beta1Client( + { + 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 identityawareproxyadminv1beta1Module.v1beta1.IdentityAwareProxyAdminV1Beta1Client({ - 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 identityawareproxyadminv1beta1Module.v1beta1.IdentityAwareProxyAdminV1Beta1Client( + { + 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 identityawareproxyadminv1beta1Module.v1beta1.IdentityAwareProxyAdminV1Beta1Client({ - 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 identityawareproxyadminv1beta1Module.v1beta1.IdentityAwareProxyAdminV1Beta1Client( + { + 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 identityawareproxyadminv1beta1Module.v1beta1.IdentityAwareProxyAdminV1Beta1Client({ - 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 testIamPermissions with closed client', async () => { + const client = + new identityawareproxyadminv1beta1Module.v1beta1.IdentityAwareProxyAdminV1Beta1Client( + { + 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); }); + }); }); diff --git a/packages/google-cloud-iap/test/gapic_identity_aware_proxy_o_auth_service_v1.ts b/packages/google-cloud-iap/test/gapic_identity_aware_proxy_o_auth_service_v1.ts index ec25a0256e76..19dced46f2e5 100644 --- a/packages/google-cloud-iap/test/gapic_identity_aware_proxy_o_auth_service_v1.ts +++ b/packages/google-cloud-iap/test/gapic_identity_aware_proxy_o_auth_service_v1.ts @@ -19,1361 +19,1910 @@ 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 identityawareproxyoauthserviceModule 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.IdentityAwareProxyOAuthServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'iap.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient(); - 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 = identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient.servicePath; - assert.strictEqual(servicePath, 'iap.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'iap.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'iap.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'iap.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 identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'iap.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 identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'iap.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 identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); - - it('has port', () => { - const port = identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient(); - assert(client); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = + new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'iap.googleapis.com'); + }); - it('should create a client with gRPC fallback', () => { - const client = new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient({ - fallback: true, - }); - assert(client); - }); + it('has universeDomain', () => { + const client = + new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.identityAwareProxyOAuthServiceStub, undefined); - await client.initialize(); - assert(client.identityAwareProxyOAuthServiceStub); - }); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + identityawareproxyoauthserviceModule.v1 + .IdentityAwareProxyOAuthServiceClient.servicePath; + assert.strictEqual(servicePath, 'iap.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + identityawareproxyoauthserviceModule.v1 + .IdentityAwareProxyOAuthServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'iap.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = + new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient( + { universeDomain: 'example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'iap.example.com'); + }); - it('has close method for the initialized client', done => { - const client = new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.identityAwareProxyOAuthServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = + new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient( + { universe_domain: 'example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'iap.example.com'); + }); - it('has close method for the non-initialized client', done => { - const client = new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.identityAwareProxyOAuthServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = + new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'iap.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + it('value configured in code has priority over environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = + new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient( + { universeDomain: 'configured.example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'iap.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 identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient( + { universe_domain: 'example.com', universeDomain: 'example.net' }, + ); + }); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); + it('has port', () => { + const port = + identityawareproxyoauthserviceModule.v1 + .IdentityAwareProxyOAuthServiceClient.port; + assert(port); + assert(typeof port === 'number'); }); - describe('listBrands', () => { - it('invokes listBrands without error', async () => { - const client = new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.ListBrandsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.ListBrandsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.iap.v1.ListBrandsResponse() - ); - client.innerApiCalls.listBrands = stubSimpleCall(expectedResponse); - const [response] = await client.listBrands(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listBrands as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listBrands 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 identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient(); + assert(client); + }); - it('invokes listBrands without error using callback', async () => { - const client = new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.ListBrandsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.ListBrandsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.iap.v1.ListBrandsResponse() - ); - client.innerApiCalls.listBrands = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listBrands( - request, - (err?: Error|null, result?: protos.google.cloud.iap.v1.IListBrandsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listBrands as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listBrands 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 identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient( + { + fallback: true, + }, + ); + assert(client); + }); - it('invokes listBrands with error', async () => { - const client = new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.ListBrandsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.ListBrandsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listBrands = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listBrands(request), expectedError); - const actualRequest = (client.innerApiCalls.listBrands as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listBrands 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 identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + assert.strictEqual(client.identityAwareProxyOAuthServiceStub, undefined); + await client.initialize(); + assert(client.identityAwareProxyOAuthServiceStub); + }); - it('invokes listBrands with closed client', async () => { - const client = new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.ListBrandsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.ListBrandsRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.listBrands(request), expectedError); + it('has close method for the initialized client', (done) => { + const client = + new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + client.initialize().catch((err) => { + throw err; + }); + assert(client.identityAwareProxyOAuthServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('createBrand', () => { - it('invokes createBrand without error', async () => { - const client = new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.CreateBrandRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.CreateBrandRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.iap.v1.Brand() - ); - client.innerApiCalls.createBrand = stubSimpleCall(expectedResponse); - const [response] = await client.createBrand(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createBrand as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createBrand 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 identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + assert.strictEqual(client.identityAwareProxyOAuthServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes createBrand without error using callback', async () => { - const client = new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.CreateBrandRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.CreateBrandRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.iap.v1.Brand() - ); - client.innerApiCalls.createBrand = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createBrand( - request, - (err?: Error|null, result?: protos.google.cloud.iap.v1.IBrand|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createBrand as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createBrand 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 identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient( + { + 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 createBrand with error', async () => { - const client = new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.CreateBrandRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.CreateBrandRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createBrand = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createBrand(request), expectedError); - const actualRequest = (client.innerApiCalls.createBrand as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createBrand 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 identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient( + { + 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('listBrands', () => { + it('invokes listBrands without error', async () => { + const client = + new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.ListBrandsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.ListBrandsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.iap.v1.ListBrandsResponse(), + ); + client.innerApiCalls.listBrands = stubSimpleCall(expectedResponse); + const [response] = await client.listBrands(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listBrands as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listBrands as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createBrand with closed client', async () => { - const client = new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.CreateBrandRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.CreateBrandRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.createBrand(request), expectedError); - }); + it('invokes listBrands without error using callback', async () => { + const client = + new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.ListBrandsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.ListBrandsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.iap.v1.ListBrandsResponse(), + ); + client.innerApiCalls.listBrands = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listBrands( + request, + ( + err?: Error | null, + result?: protos.google.cloud.iap.v1.IListBrandsResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listBrands as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listBrands as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getBrand', () => { - it('invokes getBrand without error', async () => { - const client = new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.GetBrandRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.GetBrandRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.iap.v1.Brand() - ); - client.innerApiCalls.getBrand = stubSimpleCall(expectedResponse); - const [response] = await client.getBrand(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getBrand as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getBrand as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listBrands with error', async () => { + const client = + new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.ListBrandsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.ListBrandsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listBrands = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listBrands(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listBrands as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listBrands as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getBrand without error using callback', async () => { - const client = new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.GetBrandRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.GetBrandRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.iap.v1.Brand() - ); - client.innerApiCalls.getBrand = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getBrand( - request, - (err?: Error|null, result?: protos.google.cloud.iap.v1.IBrand|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getBrand as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getBrand as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listBrands with closed client', async () => { + const client = + new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.ListBrandsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.ListBrandsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.listBrands(request), expectedError); + }); + }); + + describe('createBrand', () => { + it('invokes createBrand without error', async () => { + const client = + new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.CreateBrandRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.CreateBrandRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.iap.v1.Brand(), + ); + client.innerApiCalls.createBrand = stubSimpleCall(expectedResponse); + const [response] = await client.createBrand(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createBrand as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createBrand as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getBrand with error', async () => { - const client = new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.GetBrandRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.GetBrandRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getBrand = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getBrand(request), expectedError); - const actualRequest = (client.innerApiCalls.getBrand as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getBrand as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createBrand without error using callback', async () => { + const client = + new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.CreateBrandRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.CreateBrandRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.iap.v1.Brand(), + ); + client.innerApiCalls.createBrand = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createBrand( + request, + ( + err?: Error | null, + result?: protos.google.cloud.iap.v1.IBrand | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createBrand as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createBrand as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getBrand with closed client', async () => { - const client = new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.GetBrandRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.GetBrandRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getBrand(request), expectedError); - }); + it('invokes createBrand with error', async () => { + const client = + new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.CreateBrandRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.CreateBrandRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createBrand = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.createBrand(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createBrand as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createBrand as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createIdentityAwareProxyClient', () => { - it('invokes createIdentityAwareProxyClient without error', async () => { - const client = new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.CreateIdentityAwareProxyClientRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.CreateIdentityAwareProxyClientRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.iap.v1.IdentityAwareProxyClient() - ); - client.innerApiCalls.createIdentityAwareProxyClient = stubSimpleCall(expectedResponse); - const [response] = await client.createIdentityAwareProxyClient(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createIdentityAwareProxyClient as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createIdentityAwareProxyClient as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createBrand with closed client', async () => { + const client = + new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.CreateBrandRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.CreateBrandRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.createBrand(request), expectedError); + }); + }); + + describe('getBrand', () => { + it('invokes getBrand without error', async () => { + const client = + new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.GetBrandRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.GetBrandRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.iap.v1.Brand(), + ); + client.innerApiCalls.getBrand = stubSimpleCall(expectedResponse); + const [response] = await client.getBrand(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getBrand as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getBrand as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createIdentityAwareProxyClient without error using callback', async () => { - const client = new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.CreateIdentityAwareProxyClientRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.CreateIdentityAwareProxyClientRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.iap.v1.IdentityAwareProxyClient() - ); - client.innerApiCalls.createIdentityAwareProxyClient = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createIdentityAwareProxyClient( - request, - (err?: Error|null, result?: protos.google.cloud.iap.v1.IIdentityAwareProxyClient|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createIdentityAwareProxyClient as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createIdentityAwareProxyClient as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getBrand without error using callback', async () => { + const client = + new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.GetBrandRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.GetBrandRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.iap.v1.Brand(), + ); + client.innerApiCalls.getBrand = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getBrand( + request, + ( + err?: Error | null, + result?: protos.google.cloud.iap.v1.IBrand | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getBrand as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getBrand as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createIdentityAwareProxyClient with error', async () => { - const client = new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.CreateIdentityAwareProxyClientRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.CreateIdentityAwareProxyClientRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createIdentityAwareProxyClient = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createIdentityAwareProxyClient(request), expectedError); - const actualRequest = (client.innerApiCalls.createIdentityAwareProxyClient as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createIdentityAwareProxyClient as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getBrand with error', async () => { + const client = + new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.GetBrandRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.GetBrandRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getBrand = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getBrand(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getBrand as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getBrand as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createIdentityAwareProxyClient with closed client', async () => { - const client = new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.CreateIdentityAwareProxyClientRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.CreateIdentityAwareProxyClientRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.createIdentityAwareProxyClient(request), expectedError); - }); + it('invokes getBrand with closed client', async () => { + const client = + new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.GetBrandRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.GetBrandRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getBrand(request), expectedError); + }); + }); + + describe('createIdentityAwareProxyClient', () => { + it('invokes createIdentityAwareProxyClient without error', async () => { + const client = + new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.CreateIdentityAwareProxyClientRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.CreateIdentityAwareProxyClientRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.iap.v1.IdentityAwareProxyClient(), + ); + client.innerApiCalls.createIdentityAwareProxyClient = + stubSimpleCall(expectedResponse); + const [response] = await client.createIdentityAwareProxyClient(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createIdentityAwareProxyClient as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createIdentityAwareProxyClient as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getIdentityAwareProxyClient', () => { - it('invokes getIdentityAwareProxyClient without error', async () => { - const client = new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.GetIdentityAwareProxyClientRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.GetIdentityAwareProxyClientRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.iap.v1.IdentityAwareProxyClient() - ); - client.innerApiCalls.getIdentityAwareProxyClient = stubSimpleCall(expectedResponse); - const [response] = await client.getIdentityAwareProxyClient(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getIdentityAwareProxyClient as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getIdentityAwareProxyClient as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createIdentityAwareProxyClient without error using callback', async () => { + const client = + new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.CreateIdentityAwareProxyClientRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.CreateIdentityAwareProxyClientRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.iap.v1.IdentityAwareProxyClient(), + ); + client.innerApiCalls.createIdentityAwareProxyClient = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createIdentityAwareProxyClient( + request, + ( + err?: Error | null, + result?: protos.google.cloud.iap.v1.IIdentityAwareProxyClient | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createIdentityAwareProxyClient as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createIdentityAwareProxyClient as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getIdentityAwareProxyClient without error using callback', async () => { - const client = new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.GetIdentityAwareProxyClientRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.GetIdentityAwareProxyClientRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.iap.v1.IdentityAwareProxyClient() - ); - client.innerApiCalls.getIdentityAwareProxyClient = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIdentityAwareProxyClient( - request, - (err?: Error|null, result?: protos.google.cloud.iap.v1.IIdentityAwareProxyClient|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getIdentityAwareProxyClient as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getIdentityAwareProxyClient as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createIdentityAwareProxyClient with error', async () => { + const client = + new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.CreateIdentityAwareProxyClientRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.CreateIdentityAwareProxyClientRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createIdentityAwareProxyClient = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.createIdentityAwareProxyClient(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.createIdentityAwareProxyClient as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createIdentityAwareProxyClient as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getIdentityAwareProxyClient with error', async () => { - const client = new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.GetIdentityAwareProxyClientRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.GetIdentityAwareProxyClientRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getIdentityAwareProxyClient = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIdentityAwareProxyClient(request), expectedError); - const actualRequest = (client.innerApiCalls.getIdentityAwareProxyClient as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getIdentityAwareProxyClient as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createIdentityAwareProxyClient with closed client', async () => { + const client = + new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.CreateIdentityAwareProxyClientRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.CreateIdentityAwareProxyClientRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.createIdentityAwareProxyClient(request), + expectedError, + ); + }); + }); + + describe('getIdentityAwareProxyClient', () => { + it('invokes getIdentityAwareProxyClient without error', async () => { + const client = + new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.GetIdentityAwareProxyClientRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.GetIdentityAwareProxyClientRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.iap.v1.IdentityAwareProxyClient(), + ); + client.innerApiCalls.getIdentityAwareProxyClient = + stubSimpleCall(expectedResponse); + const [response] = await client.getIdentityAwareProxyClient(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getIdentityAwareProxyClient as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getIdentityAwareProxyClient as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getIdentityAwareProxyClient with closed client', async () => { - const client = new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.GetIdentityAwareProxyClientRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.GetIdentityAwareProxyClientRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getIdentityAwareProxyClient(request), expectedError); - }); + it('invokes getIdentityAwareProxyClient without error using callback', async () => { + const client = + new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.GetIdentityAwareProxyClientRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.GetIdentityAwareProxyClientRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.iap.v1.IdentityAwareProxyClient(), + ); + client.innerApiCalls.getIdentityAwareProxyClient = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIdentityAwareProxyClient( + request, + ( + err?: Error | null, + result?: protos.google.cloud.iap.v1.IIdentityAwareProxyClient | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getIdentityAwareProxyClient as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getIdentityAwareProxyClient as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('resetIdentityAwareProxyClientSecret', () => { - it('invokes resetIdentityAwareProxyClientSecret without error', async () => { - const client = new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.ResetIdentityAwareProxyClientSecretRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.ResetIdentityAwareProxyClientSecretRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.iap.v1.IdentityAwareProxyClient() - ); - client.innerApiCalls.resetIdentityAwareProxyClientSecret = stubSimpleCall(expectedResponse); - const [response] = await client.resetIdentityAwareProxyClientSecret(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.resetIdentityAwareProxyClientSecret as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resetIdentityAwareProxyClientSecret as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getIdentityAwareProxyClient with error', async () => { + const client = + new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.GetIdentityAwareProxyClientRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.GetIdentityAwareProxyClientRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getIdentityAwareProxyClient = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getIdentityAwareProxyClient(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.getIdentityAwareProxyClient as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getIdentityAwareProxyClient as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes resetIdentityAwareProxyClientSecret without error using callback', async () => { - const client = new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.ResetIdentityAwareProxyClientSecretRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.ResetIdentityAwareProxyClientSecretRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.iap.v1.IdentityAwareProxyClient() - ); - client.innerApiCalls.resetIdentityAwareProxyClientSecret = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.resetIdentityAwareProxyClientSecret( - request, - (err?: Error|null, result?: protos.google.cloud.iap.v1.IIdentityAwareProxyClient|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.resetIdentityAwareProxyClientSecret as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resetIdentityAwareProxyClientSecret as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getIdentityAwareProxyClient with closed client', async () => { + const client = + new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.GetIdentityAwareProxyClientRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.GetIdentityAwareProxyClientRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.getIdentityAwareProxyClient(request), + expectedError, + ); + }); + }); + + describe('resetIdentityAwareProxyClientSecret', () => { + it('invokes resetIdentityAwareProxyClientSecret without error', async () => { + const client = + new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.ResetIdentityAwareProxyClientSecretRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.ResetIdentityAwareProxyClientSecretRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.iap.v1.IdentityAwareProxyClient(), + ); + client.innerApiCalls.resetIdentityAwareProxyClientSecret = + stubSimpleCall(expectedResponse); + const [response] = + await client.resetIdentityAwareProxyClientSecret(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.resetIdentityAwareProxyClientSecret as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resetIdentityAwareProxyClientSecret as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes resetIdentityAwareProxyClientSecret with error', async () => { - const client = new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.ResetIdentityAwareProxyClientSecretRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.ResetIdentityAwareProxyClientSecretRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.resetIdentityAwareProxyClientSecret = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.resetIdentityAwareProxyClientSecret(request), expectedError); - const actualRequest = (client.innerApiCalls.resetIdentityAwareProxyClientSecret as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resetIdentityAwareProxyClientSecret as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes resetIdentityAwareProxyClientSecret without error using callback', async () => { + const client = + new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.ResetIdentityAwareProxyClientSecretRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.ResetIdentityAwareProxyClientSecretRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.iap.v1.IdentityAwareProxyClient(), + ); + client.innerApiCalls.resetIdentityAwareProxyClientSecret = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.resetIdentityAwareProxyClientSecret( + request, + ( + err?: Error | null, + result?: protos.google.cloud.iap.v1.IIdentityAwareProxyClient | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.resetIdentityAwareProxyClientSecret as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resetIdentityAwareProxyClientSecret as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes resetIdentityAwareProxyClientSecret with closed client', async () => { - const client = new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.ResetIdentityAwareProxyClientSecretRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.ResetIdentityAwareProxyClientSecretRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.resetIdentityAwareProxyClientSecret(request), expectedError); - }); + it('invokes resetIdentityAwareProxyClientSecret with error', async () => { + const client = + new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.ResetIdentityAwareProxyClientSecretRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.ResetIdentityAwareProxyClientSecretRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.resetIdentityAwareProxyClientSecret = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.resetIdentityAwareProxyClientSecret(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.resetIdentityAwareProxyClientSecret as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resetIdentityAwareProxyClientSecret as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteIdentityAwareProxyClient', () => { - it('invokes deleteIdentityAwareProxyClient without error', async () => { - const client = new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.DeleteIdentityAwareProxyClientRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.DeleteIdentityAwareProxyClientRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteIdentityAwareProxyClient = stubSimpleCall(expectedResponse); - const [response] = await client.deleteIdentityAwareProxyClient(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteIdentityAwareProxyClient as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteIdentityAwareProxyClient as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes resetIdentityAwareProxyClientSecret with closed client', async () => { + const client = + new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.ResetIdentityAwareProxyClientSecretRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.ResetIdentityAwareProxyClientSecretRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.resetIdentityAwareProxyClientSecret(request), + expectedError, + ); + }); + }); + + describe('deleteIdentityAwareProxyClient', () => { + it('invokes deleteIdentityAwareProxyClient without error', async () => { + const client = + new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.DeleteIdentityAwareProxyClientRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.DeleteIdentityAwareProxyClientRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteIdentityAwareProxyClient = + stubSimpleCall(expectedResponse); + const [response] = await client.deleteIdentityAwareProxyClient(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteIdentityAwareProxyClient as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteIdentityAwareProxyClient as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteIdentityAwareProxyClient without error using callback', async () => { - const client = new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.DeleteIdentityAwareProxyClientRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.DeleteIdentityAwareProxyClientRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteIdentityAwareProxyClient = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteIdentityAwareProxyClient( - 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.deleteIdentityAwareProxyClient as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteIdentityAwareProxyClient as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteIdentityAwareProxyClient without error using callback', async () => { + const client = + new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.DeleteIdentityAwareProxyClientRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.DeleteIdentityAwareProxyClientRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteIdentityAwareProxyClient = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteIdentityAwareProxyClient( + 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.deleteIdentityAwareProxyClient as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteIdentityAwareProxyClient as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteIdentityAwareProxyClient with error', async () => { - const client = new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.DeleteIdentityAwareProxyClientRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.DeleteIdentityAwareProxyClientRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteIdentityAwareProxyClient = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteIdentityAwareProxyClient(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteIdentityAwareProxyClient as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteIdentityAwareProxyClient as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteIdentityAwareProxyClient with error', async () => { + const client = + new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.DeleteIdentityAwareProxyClientRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.DeleteIdentityAwareProxyClientRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteIdentityAwareProxyClient = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.deleteIdentityAwareProxyClient(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.deleteIdentityAwareProxyClient as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteIdentityAwareProxyClient as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteIdentityAwareProxyClient with closed client', async () => { - const client = new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.DeleteIdentityAwareProxyClientRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.DeleteIdentityAwareProxyClientRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.deleteIdentityAwareProxyClient(request), expectedError); - }); + it('invokes deleteIdentityAwareProxyClient with closed client', async () => { + const client = + new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.DeleteIdentityAwareProxyClientRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.DeleteIdentityAwareProxyClientRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.deleteIdentityAwareProxyClient(request), + expectedError, + ); + }); + }); + + describe('listIdentityAwareProxyClients', () => { + it('invokes listIdentityAwareProxyClients without error', async () => { + const client = + new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.ListIdentityAwareProxyClientsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.ListIdentityAwareProxyClientsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.iap.v1.IdentityAwareProxyClient(), + ), + generateSampleMessage( + new protos.google.cloud.iap.v1.IdentityAwareProxyClient(), + ), + generateSampleMessage( + new protos.google.cloud.iap.v1.IdentityAwareProxyClient(), + ), + ]; + client.innerApiCalls.listIdentityAwareProxyClients = + stubSimpleCall(expectedResponse); + const [response] = await client.listIdentityAwareProxyClients(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listIdentityAwareProxyClients as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listIdentityAwareProxyClients as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listIdentityAwareProxyClients', () => { - it('invokes listIdentityAwareProxyClients without error', async () => { - const client = new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.ListIdentityAwareProxyClientsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.ListIdentityAwareProxyClientsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.iap.v1.IdentityAwareProxyClient()), - generateSampleMessage(new protos.google.cloud.iap.v1.IdentityAwareProxyClient()), - generateSampleMessage(new protos.google.cloud.iap.v1.IdentityAwareProxyClient()), - ]; - client.innerApiCalls.listIdentityAwareProxyClients = stubSimpleCall(expectedResponse); - const [response] = await client.listIdentityAwareProxyClients(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listIdentityAwareProxyClients as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listIdentityAwareProxyClients as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listIdentityAwareProxyClients without error using callback', async () => { + const client = + new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.ListIdentityAwareProxyClientsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.ListIdentityAwareProxyClientsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.iap.v1.IdentityAwareProxyClient(), + ), + generateSampleMessage( + new protos.google.cloud.iap.v1.IdentityAwareProxyClient(), + ), + generateSampleMessage( + new protos.google.cloud.iap.v1.IdentityAwareProxyClient(), + ), + ]; + client.innerApiCalls.listIdentityAwareProxyClients = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listIdentityAwareProxyClients( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.iap.v1.IIdentityAwareProxyClient[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listIdentityAwareProxyClients as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listIdentityAwareProxyClients as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listIdentityAwareProxyClients without error using callback', async () => { - const client = new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.ListIdentityAwareProxyClientsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.ListIdentityAwareProxyClientsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.iap.v1.IdentityAwareProxyClient()), - generateSampleMessage(new protos.google.cloud.iap.v1.IdentityAwareProxyClient()), - generateSampleMessage(new protos.google.cloud.iap.v1.IdentityAwareProxyClient()), - ]; - client.innerApiCalls.listIdentityAwareProxyClients = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listIdentityAwareProxyClients( - request, - (err?: Error|null, result?: protos.google.cloud.iap.v1.IIdentityAwareProxyClient[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listIdentityAwareProxyClients as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listIdentityAwareProxyClients as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listIdentityAwareProxyClients with error', async () => { + const client = + new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.ListIdentityAwareProxyClientsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.ListIdentityAwareProxyClientsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listIdentityAwareProxyClients = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.listIdentityAwareProxyClients(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.listIdentityAwareProxyClients as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listIdentityAwareProxyClients as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listIdentityAwareProxyClients with error', async () => { - const client = new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.ListIdentityAwareProxyClientsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.ListIdentityAwareProxyClientsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listIdentityAwareProxyClients = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listIdentityAwareProxyClients(request), expectedError); - const actualRequest = (client.innerApiCalls.listIdentityAwareProxyClients as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listIdentityAwareProxyClients as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes listIdentityAwareProxyClientsStream without error', async () => { + const client = + new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.ListIdentityAwareProxyClientsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.ListIdentityAwareProxyClientsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.iap.v1.IdentityAwareProxyClient(), + ), + generateSampleMessage( + new protos.google.cloud.iap.v1.IdentityAwareProxyClient(), + ), + generateSampleMessage( + new protos.google.cloud.iap.v1.IdentityAwareProxyClient(), + ), + ]; + client.descriptors.page.listIdentityAwareProxyClients.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listIdentityAwareProxyClientsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.iap.v1.IdentityAwareProxyClient[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.iap.v1.IdentityAwareProxyClient) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('invokes listIdentityAwareProxyClientsStream without error', async () => { - const client = new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.ListIdentityAwareProxyClientsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.ListIdentityAwareProxyClientsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.iap.v1.IdentityAwareProxyClient()), - generateSampleMessage(new protos.google.cloud.iap.v1.IdentityAwareProxyClient()), - generateSampleMessage(new protos.google.cloud.iap.v1.IdentityAwareProxyClient()), - ]; - client.descriptors.page.listIdentityAwareProxyClients.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listIdentityAwareProxyClientsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.iap.v1.IdentityAwareProxyClient[] = []; - stream.on('data', (response: protos.google.cloud.iap.v1.IdentityAwareProxyClient) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listIdentityAwareProxyClients.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listIdentityAwareProxyClients, request)); - assert( - (client.descriptors.page.listIdentityAwareProxyClients.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.listIdentityAwareProxyClients + .createStream as SinonStub + ) + .getCall(0) + .calledWith( + client.innerApiCalls.listIdentityAwareProxyClients, + request, + ), + ); + assert( + ( + client.descriptors.page.listIdentityAwareProxyClients + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listIdentityAwareProxyClientsStream with error', async () => { - const client = new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.ListIdentityAwareProxyClientsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.ListIdentityAwareProxyClientsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listIdentityAwareProxyClients.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listIdentityAwareProxyClientsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.iap.v1.IdentityAwareProxyClient[] = []; - stream.on('data', (response: protos.google.cloud.iap.v1.IdentityAwareProxyClient) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listIdentityAwareProxyClients.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listIdentityAwareProxyClients, request)); - assert( - (client.descriptors.page.listIdentityAwareProxyClients.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); + it('invokes listIdentityAwareProxyClientsStream with error', async () => { + const client = + new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.ListIdentityAwareProxyClientsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.ListIdentityAwareProxyClientsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listIdentityAwareProxyClients.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listIdentityAwareProxyClientsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.iap.v1.IdentityAwareProxyClient[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.iap.v1.IdentityAwareProxyClient) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('uses async iteration with listIdentityAwareProxyClients without error', async () => { - const client = new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.ListIdentityAwareProxyClientsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.ListIdentityAwareProxyClientsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.iap.v1.IdentityAwareProxyClient()), - generateSampleMessage(new protos.google.cloud.iap.v1.IdentityAwareProxyClient()), - generateSampleMessage(new protos.google.cloud.iap.v1.IdentityAwareProxyClient()), - ]; - client.descriptors.page.listIdentityAwareProxyClients.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.iap.v1.IIdentityAwareProxyClient[] = []; - const iterable = client.listIdentityAwareProxyClientsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listIdentityAwareProxyClients.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listIdentityAwareProxyClients.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.listIdentityAwareProxyClients + .createStream as SinonStub + ) + .getCall(0) + .calledWith( + client.innerApiCalls.listIdentityAwareProxyClients, + request, + ), + ); + assert( + ( + client.descriptors.page.listIdentityAwareProxyClients + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('uses async iteration with listIdentityAwareProxyClients with error', async () => { - const client = new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iap.v1.ListIdentityAwareProxyClientsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iap.v1.ListIdentityAwareProxyClientsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listIdentityAwareProxyClients.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listIdentityAwareProxyClientsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.iap.v1.IIdentityAwareProxyClient[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listIdentityAwareProxyClients.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listIdentityAwareProxyClients.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listIdentityAwareProxyClients without error', async () => { + const client = + new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.ListIdentityAwareProxyClientsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.ListIdentityAwareProxyClientsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.iap.v1.IdentityAwareProxyClient(), + ), + generateSampleMessage( + new protos.google.cloud.iap.v1.IdentityAwareProxyClient(), + ), + generateSampleMessage( + new protos.google.cloud.iap.v1.IdentityAwareProxyClient(), + ), + ]; + client.descriptors.page.listIdentityAwareProxyClients.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.iap.v1.IIdentityAwareProxyClient[] = + []; + const iterable = client.listIdentityAwareProxyClientsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listIdentityAwareProxyClients + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listIdentityAwareProxyClients + .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 identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient({ - 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 listIdentityAwareProxyClients with error', async () => { + const client = + new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iap.v1.ListIdentityAwareProxyClientsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iap.v1.ListIdentityAwareProxyClientsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listIdentityAwareProxyClients.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listIdentityAwareProxyClientsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.iap.v1.IIdentityAwareProxyClient[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listIdentityAwareProxyClients + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listIdentityAwareProxyClients + .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 identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient( + { + 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('tunnelDestGroup', async () => { - const fakePath = "/rendered/path/tunnelDestGroup"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - dest_group: "destGroupValue", - }; - const client = new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.tunnelDestGroupPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tunnelDestGroupPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tunnelDestGroupPath', () => { - const result = client.tunnelDestGroupPath("projectValue", "locationValue", "destGroupValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tunnelDestGroupPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromTunnelDestGroupName', () => { - const result = client.matchProjectFromTunnelDestGroupName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.tunnelDestGroupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromTunnelDestGroupName', () => { - const result = client.matchLocationFromTunnelDestGroupName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.tunnelDestGroupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDestGroupFromTunnelDestGroupName', () => { - const result = client.matchDestGroupFromTunnelDestGroupName(fakePath); - assert.strictEqual(result, "destGroupValue"); - assert((client.pathTemplates.tunnelDestGroupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('tunnelDestGroup', async () => { + const fakePath = '/rendered/path/tunnelDestGroup'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + dest_group: 'destGroupValue', + }; + const client = + new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.tunnelDestGroupPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.tunnelDestGroupPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('tunnelDestGroupPath', () => { + const result = client.tunnelDestGroupPath( + 'projectValue', + 'locationValue', + 'destGroupValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.tunnelDestGroupPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromTunnelDestGroupName', () => { + const result = client.matchProjectFromTunnelDestGroupName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.tunnelDestGroupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromTunnelDestGroupName', () => { + const result = client.matchLocationFromTunnelDestGroupName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.tunnelDestGroupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchDestGroupFromTunnelDestGroupName', () => { + const result = client.matchDestGroupFromTunnelDestGroupName(fakePath); + assert.strictEqual(result, 'destGroupValue'); + assert( + (client.pathTemplates.tunnelDestGroupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('tunnelLocation', async () => { - const fakePath = "/rendered/path/tunnelLocation"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.tunnelLocationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tunnelLocationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tunnelLocationPath', () => { - const result = client.tunnelLocationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tunnelLocationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromTunnelLocationName', () => { - const result = client.matchProjectFromTunnelLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.tunnelLocationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromTunnelLocationName', () => { - const result = client.matchLocationFromTunnelLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.tunnelLocationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('tunnelLocation', async () => { + const fakePath = '/rendered/path/tunnelLocation'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = + new identityawareproxyoauthserviceModule.v1.IdentityAwareProxyOAuthServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.tunnelLocationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.tunnelLocationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('tunnelLocationPath', () => { + const result = client.tunnelLocationPath( + 'projectValue', + 'locationValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.tunnelLocationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromTunnelLocationName', () => { + const result = client.matchProjectFromTunnelLocationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.tunnelLocationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromTunnelLocationName', () => { + const result = client.matchLocationFromTunnelLocationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.tunnelLocationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-iap/webpack.config.js b/packages/google-cloud-iap/webpack.config.js index 3e8a474dbfb8..8b5bcd41c973 100644 --- a/packages/google-cloud-iap/webpack.config.js +++ b/packages/google-cloud-iap/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-ids/.eslintignore b/packages/google-cloud-ids/.eslintignore new file mode 100644 index 000000000000..cfc348ec4d11 --- /dev/null +++ b/packages/google-cloud-ids/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/packages/google-cloud-ids/.eslintrc.json b/packages/google-cloud-ids/.eslintrc.json new file mode 100644 index 000000000000..3e8d97ccb390 --- /dev/null +++ b/packages/google-cloud-ids/.eslintrc.json @@ -0,0 +1,4 @@ +{ + "extends": "./node_modules/gts", + "root": true +} diff --git a/packages/google-cloud-ids/README.md b/packages/google-cloud-ids/README.md index 558f7623aa26..7a4f1a6c341f 100644 --- a/packages/google-cloud-ids/README.md +++ b/packages/google-cloud-ids/README.md @@ -96,7 +96,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-ids/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`) @@ -106,7 +106,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-ids/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-ids/protos/protos.d.ts b/packages/google-cloud-ids/protos/protos.d.ts index c83465bcf99a..b06b858998eb 100644 --- a/packages/google-cloud-ids/protos/protos.d.ts +++ b/packages/google-cloud-ids/protos/protos.d.ts @@ -1364,6 +1364,9 @@ export namespace google { /** CommonLanguageSettings destinations */ destinations?: (google.api.ClientLibraryDestination[]|null); + + /** CommonLanguageSettings selectiveGapicGeneration */ + selectiveGapicGeneration?: (google.api.ISelectiveGapicGeneration|null); } /** Represents a CommonLanguageSettings. */ @@ -1381,6 +1384,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 @@ -2081,6 +2087,9 @@ export namespace google { /** PythonSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** PythonSettings experimentalFeatures */ + experimentalFeatures?: (google.api.PythonSettings.IExperimentalFeatures|null); } /** Represents a PythonSettings. */ @@ -2095,6 +2104,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 @@ -2173,6 +2185,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 { @@ -2499,6 +2623,9 @@ export namespace google { /** GoSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** GoSettings renamedServices */ + renamedServices?: ({ [k: string]: string }|null); } /** Represents a GoSettings. */ @@ -2513,6 +2640,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 @@ -2837,6 +2967,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, @@ -3218,6 +3451,7 @@ export namespace google { /** Edition enum. */ enum Edition { EDITION_UNKNOWN = 0, + EDITION_LEGACY = 900, EDITION_PROTO2 = 998, EDITION_PROTO3 = 999, EDITION_2023 = 1000, @@ -3248,6 +3482,9 @@ export namespace google { /** FileDescriptorProto weakDependency */ weakDependency?: (number[]|null); + /** FileDescriptorProto optionDependency */ + optionDependency?: (string[]|null); + /** FileDescriptorProto messageType */ messageType?: (google.protobuf.IDescriptorProto[]|null); @@ -3297,6 +3534,9 @@ export namespace google { /** FileDescriptorProto weakDependency. */ public weakDependency: number[]; + /** FileDescriptorProto optionDependency. */ + public optionDependency: string[]; + /** FileDescriptorProto messageType. */ public messageType: google.protobuf.IDescriptorProto[]; @@ -3431,6 +3671,9 @@ export namespace google { /** DescriptorProto reservedName */ reservedName?: (string[]|null); + + /** DescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents a DescriptorProto. */ @@ -3472,6 +3715,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 @@ -4319,6 +4565,9 @@ export namespace google { /** EnumDescriptorProto reservedName */ reservedName?: (string[]|null); + + /** EnumDescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents an EnumDescriptorProto. */ @@ -4345,6 +4594,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 @@ -5279,6 +5531,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); @@ -5334,6 +5589,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[]; @@ -5554,6 +5812,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. */ @@ -5792,6 +6165,9 @@ export namespace google { /** EnumValueOptions debugRedact */ debugRedact?: (boolean|null); + /** EnumValueOptions featureSupport */ + featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** EnumValueOptions uninterpretedOption */ uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); } @@ -5814,6 +6190,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[]; @@ -6406,6 +6785,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. */ @@ -6435,6 +6820,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 @@ -6557,6 +6948,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. */ @@ -6676,8 +7177,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. */ @@ -6692,8 +7196,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. @@ -7226,6 +7733,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-ids/protos/protos.js b/packages/google-cloud-ids/protos/protos.js index 8480ddb4eb3f..7b4456d9743e 100644 --- a/packages/google-cloud-ids/protos/protos.js +++ b/packages/google-cloud-ids/protos/protos.js @@ -3474,6 +3474,7 @@ * @interface ICommonLanguageSettings * @property {string|null} [referenceDocsUri] CommonLanguageSettings referenceDocsUri * @property {Array.|null} [destinations] CommonLanguageSettings destinations + * @property {google.api.ISelectiveGapicGeneration|null} [selectiveGapicGeneration] CommonLanguageSettings selectiveGapicGeneration */ /** @@ -3508,6 +3509,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 @@ -3540,6 +3549,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; }; @@ -3591,6 +3602,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; @@ -3642,6 +3657,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; }; @@ -3684,6 +3704,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; }; @@ -3702,8 +3727,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) { @@ -3711,6 +3738,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; }; @@ -5533,6 +5562,7 @@ * @memberof google.api * @interface IPythonSettings * @property {google.api.ICommonLanguageSettings|null} [common] PythonSettings common + * @property {google.api.PythonSettings.IExperimentalFeatures|null} [experimentalFeatures] PythonSettings experimentalFeatures */ /** @@ -5558,6 +5588,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 @@ -5584,6 +5622,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; }; @@ -5624,6 +5664,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; @@ -5664,6 +5708,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; }; @@ -5684,6 +5733,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; }; @@ -5700,10 +5754,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; }; @@ -5733,6 +5791,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; })(); @@ -6609,6 +6919,7 @@ * @memberof google.api * @interface IGoSettings * @property {google.api.ICommonLanguageSettings|null} [common] GoSettings common + * @property {Object.|null} [renamedServices] GoSettings renamedServices */ /** @@ -6620,6 +6931,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) @@ -6634,6 +6946,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 @@ -6660,6 +6980,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; }; @@ -6690,7 +7013,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) @@ -6700,6 +7023,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; @@ -6740,6 +7086,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; }; @@ -6760,6 +7114,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; }; @@ -6776,10 +7137,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; }; @@ -7418,29 +7787,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; })(); @@ -8403,6 +9017,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 @@ -8417,6 +9032,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; @@ -8441,6 +9057,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 @@ -8463,6 +9080,7 @@ this.dependency = []; this.publicDependency = []; this.weakDependency = []; + this.optionDependency = []; this.messageType = []; this.enumType = []; this.service = []; @@ -8513,6 +9131,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 @@ -8634,6 +9260,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; }; @@ -8706,6 +9335,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 = []; @@ -8808,6 +9443,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"; @@ -8862,6 +9504,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -8914,6 +9557,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"); @@ -8977,6 +9627,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -9042,6 +9696,7 @@ object.extension = []; object.publicDependency = []; object.weakDependency = []; + object.optionDependency = []; } if (options.defaults) { object.name = ""; @@ -9098,6 +9753,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; }; @@ -9146,6 +9806,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 */ /** @@ -9251,6 +9912,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 @@ -9303,6 +9972,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; }; @@ -9395,6 +10066,10 @@ message.reservedName.push(reader.string()); break; } + case 11: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -9508,6 +10183,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; }; @@ -9607,6 +10291,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; }; @@ -9636,6 +10340,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; @@ -9681,6 +10386,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; }; @@ -11725,6 +12432,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 */ /** @@ -11785,6 +12493,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 @@ -11822,6 +12538,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; }; @@ -11884,6 +12602,10 @@ message.reservedName.push(reader.string()); break; } + case 6: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -11952,6 +12674,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; }; @@ -12001,6 +12732,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; }; @@ -12025,6 +12776,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; @@ -12045,6 +12797,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; }; @@ -14363,6 +15117,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 @@ -14483,6 +15238,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 @@ -14557,6 +15320,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(); @@ -14658,6 +15423,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 = []; @@ -14793,6 +15562,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"; @@ -14981,6 +15755,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"); @@ -15078,6 +15857,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")) @@ -15110,6 +15890,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) @@ -15382,6 +16164,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -15423,103 +16206,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; @@ -16114,6 +17383,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 */ @@ -16157,6 +17427,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 @@ -16195,6 +17473,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(); @@ -16246,6 +17526,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 = []; @@ -16298,6 +17582,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"; @@ -16331,6 +17620,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"); @@ -16363,6 +17657,7 @@ object.deprecated = false; object.features = null; object.debugRedact = false; + object.featureSupport = null; } if (message.deprecated != null && message.hasOwnProperty("deprecated")) object.deprecated = message.deprecated; @@ -16370,6 +17665,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) @@ -17837,6 +19134,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 */ /** @@ -17902,6 +19201,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 @@ -17938,6 +19253,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; }; @@ -17998,6 +19317,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; @@ -18088,6 +19415,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; }; @@ -18227,6 +19574,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; }; @@ -18250,6 +19645,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; @@ -18263,6 +19660,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; }; @@ -18390,6 +19791,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; })(); @@ -18574,6 +20188,7 @@ default: return "minimumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -18591,6 +20206,7 @@ default: return "maximumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -18639,6 +20255,10 @@ case 0: message.minimumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.minimumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.minimumEdition = 998; @@ -18691,6 +20311,10 @@ case 0: message.maximumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.maximumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.maximumEdition = 998; @@ -18799,7 +20423,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 */ /** @@ -18826,12 +20451,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. @@ -18857,10 +20490,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; }; @@ -18901,8 +20536,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: @@ -18945,6 +20584,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -18957,10 +20597,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; }; @@ -18988,6 +20633,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -19029,10 +20678,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; }; @@ -19051,13 +20705,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; }; @@ -20272,6 +21929,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-ids/protos/protos.json b/packages/google-cloud-ids/protos/protos.json index 318871f089b6..ad2405e3649e 100644 --- a/packages/google-cloud-ids/protos/protos.json +++ b/packages/google-cloud-ids/protos/protos.json @@ -391,8 +391,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": { @@ -516,6 +515,10 @@ "rule": "repeated", "type": "ClientLibraryDestination", "id": 2 + }, + "selectiveGapicGeneration": { + "type": "SelectiveGapicGeneration", + "id": 3 } } }, @@ -656,6 +659,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 + } + } } } }, @@ -713,6 +738,11 @@ "common": { "type": "CommonLanguageSettings", "id": 1 + }, + "renamedServices": { + "keyType": "string", + "type": "string", + "id": 2 } } }, @@ -774,6 +804,19 @@ "PACKAGE_MANAGER": 20 } }, + "SelectiveGapicGeneration": { + "fields": { + "methods": { + "rule": "repeated", + "type": "string", + "id": 1 + }, + "generateOmittedAsInternal": { + "type": "bool", + "id": 2 + } + } + }, "LaunchStage": { "values": { "LAUNCH_STAGE_UNSPECIFIED": 0, @@ -906,12 +949,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, @@ -950,6 +1000,11 @@ "type": "int32", "id": 11 }, + "optionDependency": { + "rule": "repeated", + "type": "string", + "id": 15 + }, "messageType": { "rule": "repeated", "type": "DescriptorProto", @@ -1038,6 +1093,10 @@ "rule": "repeated", "type": "string", "id": 10 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 11 } }, "nested": { @@ -1263,6 +1322,10 @@ "rule": "repeated", "type": "string", "id": 5 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 6 } }, "nested": { @@ -1313,7 +1376,14 @@ "type": "ServiceOptions", "id": 3 } - } + }, + "reserved": [ + [ + 4, + 4 + ], + "stream" + ] }, "MethodDescriptorProto": { "edition": "proto2", @@ -1477,6 +1547,7 @@ 42, 42 ], + "php_generic_services", [ 38, 38 @@ -1612,7 +1683,8 @@ "type": "bool", "id": 10, "options": { - "default": false + "default": false, + "deprecated": true } }, "debugRedact": { @@ -1640,6 +1712,10 @@ "type": "FeatureSet", "id": 21 }, + "featureSupport": { + "type": "FeatureSupport", + "id": 22 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -1709,6 +1785,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 + } + } } } }, @@ -1797,6 +1893,10 @@ "default": false } }, + "featureSupport": { + "type": "FieldOptions.FeatureSupport", + "id": 4 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -1939,6 +2039,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_2023", "edition_defaults.value": "EXPLICIT" } @@ -1949,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": "OPEN" } @@ -1959,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": "PACKED" } @@ -1969,6 +2072,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "VERIFY" } @@ -1979,7 +2083,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" } }, @@ -1989,27 +2094,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, @@ -2054,7 +2170,13 @@ "UTF8_VALIDATION_UNKNOWN": 0, "VERIFY": 2, "NONE": 3 - } + }, + "reserved": [ + [ + 1, + 1 + ] + ] }, "MessageEncoding": { "values": { @@ -2069,6 +2191,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 + } + } + } } } }, @@ -2096,11 +2245,26 @@ "type": "Edition", "id": 3 }, - "features": { + "overridableFeatures": { "type": "FeatureSet", - "id": 2 + "id": 4 + }, + "fixedFeatures": { + "type": "FeatureSet", + "id": 5 } - } + }, + "reserved": [ + [ + 1, + 1 + ], + [ + 2, + 2 + ], + "features" + ] } } }, @@ -2113,6 +2277,12 @@ "id": 1 } }, + "extensions": [ + [ + 536000000, + 536000000 + ] + ], "nested": { "Location": { "fields": { @@ -2198,6 +2368,14 @@ } } }, + "SymbolVisibility": { + "edition": "proto2", + "values": { + "VISIBILITY_UNSET": 0, + "VISIBILITY_LOCAL": 1, + "VISIBILITY_EXPORT": 2 + } + }, "Duration": { "fields": { "seconds": { @@ -2247,6 +2425,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-ids/samples/generated/v1/snippet_metadata_google.cloud.ids.v1.json b/packages/google-cloud-ids/samples/generated/v1/snippet_metadata_google.cloud.ids.v1.json index 69bbdde88d7e..d9ec4a34a9a1 100644 --- a/packages/google-cloud-ids/samples/generated/v1/snippet_metadata_google.cloud.ids.v1.json +++ b/packages/google-cloud-ids/samples/generated/v1/snippet_metadata_google.cloud.ids.v1.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-ids", - "version": "4.2.1", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-ids/src/v1/i_d_s_client.ts b/packages/google-cloud-ids/src/v1/i_d_s_client.ts index 54151fecd17e..fb176b5e392d 100644 --- a/packages/google-cloud-ids/src/v1/i_d_s_client.ts +++ b/packages/google-cloud-ids/src/v1/i_d_s_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 IDSClient { 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('ids'); @@ -57,10 +66,10 @@ export class IDSClient { 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; - iDSStub?: Promise<{[name: string]: Function}>; + iDSStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of IDSClient. @@ -101,21 +110,42 @@ export class IDSClient { * const client = new IDSClient({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 IDSClient; - 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 = 'ids.' + 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 IDSClient { 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 IDSClient { } // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process === 'object' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -179,13 +206,13 @@ export class IDSClient { // Create useful helper objects for these. this.pathTemplates = { endpointPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/endpoints/{endpoint}' + 'projects/{project}/locations/{location}/endpoints/{endpoint}', ), locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' + 'projects/{project}/locations/{location}', ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' + 'projects/{project}', ), }; @@ -193,8 +220,11 @@ export class IDSClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listEndpoints: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'endpoints') + listEndpoints: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'endpoints', + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -203,37 +233,88 @@ export class IDSClient { // rather than holding a request open. const lroOptions: GrpcClientOptions = { auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1/{name=projects/*}/locations',},{selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',get: '/v1/{resource=projects/*/locations/*/endpoints/*}:getIamPolicy',},{selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',post: '/v1/{resource=projects/*/locations/*/endpoints/*}:setIamPolicy',body: '*',},{selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',post: '/v1/{resource=projects/*/locations/*/endpoints/*}:testIamPermissions',body: '*',},{selector: 'google.longrunning.Operations.CancelOperation',post: '/v1/{name=projects/*/locations/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1/{name=projects/*/locations/*}/operations',}]; + lroOptions.httpRules = [ + { + selector: 'google.cloud.location.Locations.GetLocation', + get: '/v1/{name=projects/*/locations/*}', + }, + { + selector: 'google.cloud.location.Locations.ListLocations', + get: '/v1/{name=projects/*}/locations', + }, + { + selector: 'google.iam.v1.IAMPolicy.GetIamPolicy', + get: '/v1/{resource=projects/*/locations/*/endpoints/*}:getIamPolicy', + }, + { + selector: 'google.iam.v1.IAMPolicy.SetIamPolicy', + post: '/v1/{resource=projects/*/locations/*/endpoints/*}:setIamPolicy', + body: '*', + }, + { + selector: 'google.iam.v1.IAMPolicy.TestIamPermissions', + post: '/v1/{resource=projects/*/locations/*/endpoints/*}:testIamPermissions', + body: '*', + }, + { + selector: 'google.longrunning.Operations.CancelOperation', + post: '/v1/{name=projects/*/locations/*/operations/*}:cancel', + body: '*', + }, + { + selector: 'google.longrunning.Operations.DeleteOperation', + delete: '/v1/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v1/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v1/{name=projects/*/locations/*}/operations', + }, + ]; } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); const createEndpointResponse = protoFilesRoot.lookup( - '.google.cloud.ids.v1.Endpoint') as gax.protobuf.Type; + '.google.cloud.ids.v1.Endpoint', + ) as gax.protobuf.Type; const createEndpointMetadata = protoFilesRoot.lookup( - '.google.cloud.ids.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.ids.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteEndpointResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteEndpointMetadata = protoFilesRoot.lookup( - '.google.cloud.ids.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.ids.v1.OperationMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { createEndpoint: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createEndpointResponse.decode.bind(createEndpointResponse), - createEndpointMetadata.decode.bind(createEndpointMetadata)), + createEndpointMetadata.decode.bind(createEndpointMetadata), + ), deleteEndpoint: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteEndpointResponse.decode.bind(deleteEndpointResponse), - deleteEndpointMetadata.decode.bind(deleteEndpointMetadata)) + deleteEndpointMetadata.decode.bind(deleteEndpointMetadata), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.ids.v1.IDS', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.ids.v1.IDS', + 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 @@ -264,28 +345,38 @@ export class IDSClient { // Put together the "service stub" for // google.cloud.ids.v1.IDS. this.iDSStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.ids.v1.IDS') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.ids.v1.IDS', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.ids.v1.IDS, - 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 iDSStubMethods = - ['listEndpoints', 'getEndpoint', 'createEndpoint', 'deleteEndpoint']; + const iDSStubMethods = [ + 'listEndpoints', + 'getEndpoint', + 'createEndpoint', + 'deleteEndpoint', + ]; for (const methodName of iDSStubMethods) { const callPromise = this.iDSStub.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] || @@ -295,7 +386,7 @@ export class IDSClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -310,8 +401,14 @@ export class IDSClient { * @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 'ids.googleapis.com'; } @@ -322,8 +419,14 @@ export class IDSClient { * @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 'ids.googleapis.com'; } @@ -354,9 +457,7 @@ export class IDSClient { * @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; @@ -365,8 +466,9 @@ export class IDSClient { * 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; @@ -377,445 +479,614 @@ export class IDSClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Gets details of a single Endpoint. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the endpoint to retrieve. - * Format: `projects/{project}/locations/{location}/endpoints/{endpoint}` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.ids.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/i_d_s.get_endpoint.js - * region_tag:ids_v1_generated_IDS_GetEndpoint_async - */ + /** + * Gets details of a single Endpoint. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the endpoint to retrieve. + * Format: `projects/{project}/locations/{location}/endpoints/{endpoint}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.ids.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/i_d_s.get_endpoint.js + * region_tag:ids_v1_generated_IDS_GetEndpoint_async + */ getEndpoint( - request?: protos.google.cloud.ids.v1.IGetEndpointRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.ids.v1.IEndpoint, - protos.google.cloud.ids.v1.IGetEndpointRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.ids.v1.IGetEndpointRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.ids.v1.IEndpoint, + protos.google.cloud.ids.v1.IGetEndpointRequest | undefined, + {} | undefined, + ] + >; getEndpoint( - request: protos.google.cloud.ids.v1.IGetEndpointRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.ids.v1.IEndpoint, - protos.google.cloud.ids.v1.IGetEndpointRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.ids.v1.IGetEndpointRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.ids.v1.IEndpoint, + protos.google.cloud.ids.v1.IGetEndpointRequest | null | undefined, + {} | null | undefined + >, + ): void; getEndpoint( - request: protos.google.cloud.ids.v1.IGetEndpointRequest, - callback: Callback< - protos.google.cloud.ids.v1.IEndpoint, - protos.google.cloud.ids.v1.IGetEndpointRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.ids.v1.IGetEndpointRequest, + callback: Callback< + protos.google.cloud.ids.v1.IEndpoint, + protos.google.cloud.ids.v1.IGetEndpointRequest | null | undefined, + {} | null | undefined + >, + ): void; getEndpoint( - request?: protos.google.cloud.ids.v1.IGetEndpointRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.ids.v1.IEndpoint, - protos.google.cloud.ids.v1.IGetEndpointRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.ids.v1.IGetEndpointRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.ids.v1.IEndpoint, - protos.google.cloud.ids.v1.IGetEndpointRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.ids.v1.IEndpoint, - protos.google.cloud.ids.v1.IGetEndpointRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.ids.v1.IGetEndpointRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.ids.v1.IEndpoint, + protos.google.cloud.ids.v1.IGetEndpointRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.ids.v1.IEndpoint, + protos.google.cloud.ids.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.ids.v1.IEndpoint, - protos.google.cloud.ids.v1.IGetEndpointRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.ids.v1.IEndpoint, + protos.google.cloud.ids.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.ids.v1.IEndpoint, - protos.google.cloud.ids.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.ids.v1.IEndpoint, + protos.google.cloud.ids.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; }); } -/** - * Creates a new Endpoint in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The endpoint's parent. - * @param {string} request.endpointId - * Required. The endpoint identifier. This will be part of the endpoint's - * resource name. - * This value must start with a lowercase letter followed by up to 62 - * lowercase letters, numbers, or hyphens, and cannot end with a hyphen. - * Values that do not match this pattern will trigger an INVALID_ARGUMENT - * error. - * @param {google.cloud.ids.v1.Endpoint} request.endpoint - * Required. The endpoint to create. - * @param {string} request.requestId - * An optional request ID to identify requests. Specify a unique request ID - * so that if you must retry your request, the server will know to ignore - * the request if it has already been completed. The server will guarantee - * that for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and t - * he request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/i_d_s.create_endpoint.js - * region_tag:ids_v1_generated_IDS_CreateEndpoint_async - */ + /** + * Creates a new Endpoint in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The endpoint's parent. + * @param {string} request.endpointId + * Required. The endpoint identifier. This will be part of the endpoint's + * resource name. + * This value must start with a lowercase letter followed by up to 62 + * lowercase letters, numbers, or hyphens, and cannot end with a hyphen. + * Values that do not match this pattern will trigger an INVALID_ARGUMENT + * error. + * @param {google.cloud.ids.v1.Endpoint} request.endpoint + * Required. The endpoint to create. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID + * so that if you must retry your request, the server will know to ignore + * the request if it has already been completed. The server will guarantee + * that for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and t + * he request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/i_d_s.create_endpoint.js + * region_tag:ids_v1_generated_IDS_CreateEndpoint_async + */ createEndpoint( - request?: protos.google.cloud.ids.v1.ICreateEndpointRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.ids.v1.ICreateEndpointRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.ids.v1.IEndpoint, + protos.google.cloud.ids.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createEndpoint( - request: protos.google.cloud.ids.v1.ICreateEndpointRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.ids.v1.ICreateEndpointRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.ids.v1.IEndpoint, + protos.google.cloud.ids.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createEndpoint( - request: protos.google.cloud.ids.v1.ICreateEndpointRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.ids.v1.ICreateEndpointRequest, + callback: Callback< + LROperation< + protos.google.cloud.ids.v1.IEndpoint, + protos.google.cloud.ids.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createEndpoint( - request?: protos.google.cloud.ids.v1.ICreateEndpointRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.ids.v1.ICreateEndpointRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.ids.v1.IEndpoint, + protos.google.cloud.ids.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.ids.v1.IEndpoint, + protos.google.cloud.ids.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.ids.v1.IEndpoint, + protos.google.cloud.ids.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.ids.v1.IEndpoint, + protos.google.cloud.ids.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createEndpoint response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createEndpoint request %j', request); - return this.innerApiCalls.createEndpoint(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createEndpoint response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createEndpoint(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.ids.v1.IEndpoint, + protos.google.cloud.ids.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createEndpoint response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createEndpoint()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/i_d_s.create_endpoint.js - * region_tag:ids_v1_generated_IDS_CreateEndpoint_async - */ - async checkCreateEndpointProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createEndpoint()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/i_d_s.create_endpoint.js + * region_tag:ids_v1_generated_IDS_CreateEndpoint_async + */ + async checkCreateEndpointProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.ids.v1.Endpoint, + protos.google.cloud.ids.v1.OperationMetadata + > + > { this._log.info('createEndpoint long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createEndpoint, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createEndpoint, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.ids.v1.Endpoint, + protos.google.cloud.ids.v1.OperationMetadata + >; } -/** - * Deletes a single Endpoint. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the endpoint to delete. - * @param {string} request.requestId - * An optional request ID to identify requests. Specify a unique request ID - * so that if you must retry your request, the server will know to ignore - * the request if it has already been completed. The server will guarantee - * that for at least 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and t - * he request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/i_d_s.delete_endpoint.js - * region_tag:ids_v1_generated_IDS_DeleteEndpoint_async - */ + /** + * Deletes a single Endpoint. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the endpoint to delete. + * @param {string} request.requestId + * An optional request ID to identify requests. Specify a unique request ID + * so that if you must retry your request, the server will know to ignore + * the request if it has already been completed. The server will guarantee + * that for at least 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and t + * he request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/i_d_s.delete_endpoint.js + * region_tag:ids_v1_generated_IDS_DeleteEndpoint_async + */ deleteEndpoint( - request?: protos.google.cloud.ids.v1.IDeleteEndpointRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.ids.v1.IDeleteEndpointRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.ids.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteEndpoint( - request: protos.google.cloud.ids.v1.IDeleteEndpointRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.ids.v1.IDeleteEndpointRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.ids.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteEndpoint( - request: protos.google.cloud.ids.v1.IDeleteEndpointRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.ids.v1.IDeleteEndpointRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.ids.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteEndpoint( - request?: protos.google.cloud.ids.v1.IDeleteEndpointRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.ids.v1.IDeleteEndpointRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.ids.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.ids.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.ids.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.ids.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteEndpoint response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteEndpoint request %j', request); - return this.innerApiCalls.deleteEndpoint(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteEndpoint response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteEndpoint(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.ids.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteEndpoint response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteEndpoint()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/i_d_s.delete_endpoint.js - * region_tag:ids_v1_generated_IDS_DeleteEndpoint_async - */ - async checkDeleteEndpointProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteEndpoint()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/i_d_s.delete_endpoint.js + * region_tag:ids_v1_generated_IDS_DeleteEndpoint_async + */ + async checkDeleteEndpointProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.ids.v1.OperationMetadata + > + > { this._log.info('deleteEndpoint long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteEndpoint, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteEndpoint, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.ids.v1.OperationMetadata + >; } - /** - * Lists Endpoints in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent, which owns this collection of endpoints. - * @param {number} [request.pageSize] - * Optional. The maximum number of endpoints to return. The service may return fewer - * than this value. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListEndpoints` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListEndpoints` must - * match the call that provided the page token. - * @param {string} [request.filter] - * Optional. The filter expression, following the syntax outlined in - * https://google.aip.dev/160. - * @param {string} [request.orderBy] - * Optional. One or more fields to compare and use to sort the output. - * See https://google.aip.dev/132#ordering. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link protos.google.cloud.ids.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 Endpoints in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent, which owns this collection of endpoints. + * @param {number} [request.pageSize] + * Optional. The maximum number of endpoints to return. The service may return fewer + * than this value. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListEndpoints` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListEndpoints` must + * match the call that provided the page token. + * @param {string} [request.filter] + * Optional. The filter expression, following the syntax outlined in + * https://google.aip.dev/160. + * @param {string} [request.orderBy] + * Optional. One or more fields to compare and use to sort the output. + * See https://google.aip.dev/132#ordering. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.ids.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.ids.v1.IListEndpointsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.ids.v1.IEndpoint[], - protos.google.cloud.ids.v1.IListEndpointsRequest|null, - protos.google.cloud.ids.v1.IListEndpointsResponse - ]>; + request?: protos.google.cloud.ids.v1.IListEndpointsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.ids.v1.IEndpoint[], + protos.google.cloud.ids.v1.IListEndpointsRequest | null, + protos.google.cloud.ids.v1.IListEndpointsResponse, + ] + >; listEndpoints( - request: protos.google.cloud.ids.v1.IListEndpointsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.ids.v1.IListEndpointsRequest, - protos.google.cloud.ids.v1.IListEndpointsResponse|null|undefined, - protos.google.cloud.ids.v1.IEndpoint>): void; + request: protos.google.cloud.ids.v1.IListEndpointsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.ids.v1.IListEndpointsRequest, + protos.google.cloud.ids.v1.IListEndpointsResponse | null | undefined, + protos.google.cloud.ids.v1.IEndpoint + >, + ): void; listEndpoints( - request: protos.google.cloud.ids.v1.IListEndpointsRequest, - callback: PaginationCallback< - protos.google.cloud.ids.v1.IListEndpointsRequest, - protos.google.cloud.ids.v1.IListEndpointsResponse|null|undefined, - protos.google.cloud.ids.v1.IEndpoint>): void; + request: protos.google.cloud.ids.v1.IListEndpointsRequest, + callback: PaginationCallback< + protos.google.cloud.ids.v1.IListEndpointsRequest, + protos.google.cloud.ids.v1.IListEndpointsResponse | null | undefined, + protos.google.cloud.ids.v1.IEndpoint + >, + ): void; listEndpoints( - request?: protos.google.cloud.ids.v1.IListEndpointsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< + request?: protos.google.cloud.ids.v1.IListEndpointsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.ids.v1.IListEndpointsRequest, - protos.google.cloud.ids.v1.IListEndpointsResponse|null|undefined, - protos.google.cloud.ids.v1.IEndpoint>, - callback?: PaginationCallback< - protos.google.cloud.ids.v1.IListEndpointsRequest, - protos.google.cloud.ids.v1.IListEndpointsResponse|null|undefined, - protos.google.cloud.ids.v1.IEndpoint>): - Promise<[ - protos.google.cloud.ids.v1.IEndpoint[], - protos.google.cloud.ids.v1.IListEndpointsRequest|null, - protos.google.cloud.ids.v1.IListEndpointsResponse - ]>|void { + protos.google.cloud.ids.v1.IListEndpointsResponse | null | undefined, + protos.google.cloud.ids.v1.IEndpoint + >, + callback?: PaginationCallback< + protos.google.cloud.ids.v1.IListEndpointsRequest, + protos.google.cloud.ids.v1.IListEndpointsResponse | null | undefined, + protos.google.cloud.ids.v1.IEndpoint + >, + ): Promise< + [ + protos.google.cloud.ids.v1.IEndpoint[], + protos.google.cloud.ids.v1.IListEndpointsRequest | null, + protos.google.cloud.ids.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.ids.v1.IListEndpointsRequest, - protos.google.cloud.ids.v1.IListEndpointsResponse|null|undefined, - protos.google.cloud.ids.v1.IEndpoint>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.ids.v1.IListEndpointsRequest, + protos.google.cloud.ids.v1.IListEndpointsResponse | null | undefined, + protos.google.cloud.ids.v1.IEndpoint + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listEndpoints values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -824,128 +1095,132 @@ export class IDSClient { this._log.info('listEndpoints request %j', request); return this.innerApiCalls .listEndpoints(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.ids.v1.IEndpoint[], - protos.google.cloud.ids.v1.IListEndpointsRequest|null, - protos.google.cloud.ids.v1.IListEndpointsResponse - ]) => { - this._log.info('listEndpoints values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.ids.v1.IEndpoint[], + protos.google.cloud.ids.v1.IListEndpointsRequest | null, + protos.google.cloud.ids.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 parent, which owns this collection of endpoints. - * @param {number} [request.pageSize] - * Optional. The maximum number of endpoints to return. The service may return fewer - * than this value. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListEndpoints` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListEndpoints` must - * match the call that provided the page token. - * @param {string} [request.filter] - * Optional. The filter expression, following the syntax outlined in - * https://google.aip.dev/160. - * @param {string} [request.orderBy] - * Optional. One or more fields to compare and use to sort the output. - * See https://google.aip.dev/132#ordering. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.ids.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 parent, which owns this collection of endpoints. + * @param {number} [request.pageSize] + * Optional. The maximum number of endpoints to return. The service may return fewer + * than this value. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListEndpoints` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListEndpoints` must + * match the call that provided the page token. + * @param {string} [request.filter] + * Optional. The filter expression, following the syntax outlined in + * https://google.aip.dev/160. + * @param {string} [request.orderBy] + * Optional. One or more fields to compare and use to sort the output. + * See https://google.aip.dev/132#ordering. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.ids.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.ids.v1.IListEndpointsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.ids.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 parent, which owns this collection of endpoints. - * @param {number} [request.pageSize] - * Optional. The maximum number of endpoints to return. The service may return fewer - * than this value. - * @param {string} [request.pageToken] - * Optional. A page token, received from a previous `ListEndpoints` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListEndpoints` must - * match the call that provided the page token. - * @param {string} [request.filter] - * Optional. The filter expression, following the syntax outlined in - * https://google.aip.dev/160. - * @param {string} [request.orderBy] - * Optional. One or more fields to compare and use to sort the output. - * See https://google.aip.dev/132#ordering. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.ids.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/i_d_s.list_endpoints.js - * region_tag:ids_v1_generated_IDS_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 parent, which owns this collection of endpoints. + * @param {number} [request.pageSize] + * Optional. The maximum number of endpoints to return. The service may return fewer + * than this value. + * @param {string} [request.pageToken] + * Optional. A page token, received from a previous `ListEndpoints` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListEndpoints` must + * match the call that provided the page token. + * @param {string} [request.filter] + * Optional. The filter expression, following the syntax outlined in + * https://google.aip.dev/160. + * @param {string} [request.orderBy] + * Optional. One or more fields to compare and use to sort the output. + * See https://google.aip.dev/132#ordering. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.ids.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/i_d_s.list_endpoints.js + * region_tag:ids_v1_generated_IDS_ListEndpoints_async + */ listEndpointsAsync( - request?: protos.google.cloud.ids.v1.IListEndpointsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.ids.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; } // -------------------- @@ -960,7 +1235,7 @@ export class IDSClient { * @param {string} endpoint * @returns {string} Resource name string. */ - endpointPath(project:string,location:string,endpoint:string) { + endpointPath(project: string, location: string, endpoint: string) { return this.pathTemplates.endpointPathTemplate.render({ project: project, location: location, @@ -1008,7 +1283,7 @@ export class IDSClient { * @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, @@ -1043,7 +1318,7 @@ export class IDSClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -1068,7 +1343,7 @@ export class IDSClient { */ close(): Promise { if (this.iDSStub && !this._terminated) { - return this.iDSStub.then(stub => { + return this.iDSStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); @@ -1077,4 +1352,4 @@ export class IDSClient { } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-ids/src/v1/index.ts b/packages/google-cloud-ids/src/v1/index.ts index 34a45b11ebb8..7d9d84b55e83 100644 --- a/packages/google-cloud-ids/src/v1/index.ts +++ b/packages/google-cloud-ids/src/v1/index.ts @@ -16,4 +16,4 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {IDSClient} from './i_d_s_client'; +export { IDSClient } from './i_d_s_client'; diff --git a/packages/google-cloud-ids/system-test/fixtures/sample/src/index.ts b/packages/google-cloud-ids/system-test/fixtures/sample/src/index.ts index 34f20c9d0697..1a66e98d43b9 100644 --- a/packages/google-cloud-ids/system-test/fixtures/sample/src/index.ts +++ b/packages/google-cloud-ids/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 {IDSClient} from '@google-cloud/ids'; +import { IDSClient } from '@google-cloud/ids'; // check that the client class type name can be used function doStuffWithIDSClient(client: IDSClient) { diff --git a/packages/google-cloud-ids/system-test/install.ts b/packages/google-cloud-ids/system-test/install.ts index f66069aa3940..ccf167042d2e 100644 --- a/packages/google-cloud-ids/system-test/install.ts +++ b/packages/google-cloud-ids/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-ids/test/gapic_i_d_s_v1.ts b/packages/google-cloud-ids/test/gapic_i_d_s_v1.ts index 5ead0bf83cbe..daaffcf6bae6 100644 --- a/packages/google-cloud-ids/test/gapic_i_d_s_v1.ts +++ b/packages/google-cloud-ids/test/gapic_i_d_s_v1.ts @@ -19,1037 +19,1299 @@ 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 idsModule 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('v1.IDSClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new idsModule.v1.IDSClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'ids.googleapis.com'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new idsModule.v1.IDSClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'ids.googleapis.com'); + }); - it('has universeDomain', () => { - const client = new idsModule.v1.IDSClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); + it('has universeDomain', () => { + const client = new idsModule.v1.IDSClient(); + 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 = idsModule.v1.IDSClient.servicePath; - assert.strictEqual(servicePath, 'ids.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = idsModule.v1.IDSClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'ids.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new idsModule.v1.IDSClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'ids.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 = idsModule.v1.IDSClient.servicePath; + assert.strictEqual(servicePath, 'ids.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = idsModule.v1.IDSClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'ids.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new idsModule.v1.IDSClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'ids.example.com'); + }); - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new idsModule.v1.IDSClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'ids.example.com'); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new idsModule.v1.IDSClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'ids.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 idsModule.v1.IDSClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'ids.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 idsModule.v1.IDSClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'ids.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 idsModule.v1.IDSClient({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 idsModule.v1.IDSClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'ids.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - it('has port', () => { - const port = idsModule.v1.IDSClient.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 idsModule.v1.IDSClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'ids.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 idsModule.v1.IDSClient(); - assert(client); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new idsModule.v1.IDSClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('should create a client with gRPC fallback', () => { - const client = new idsModule.v1.IDSClient({ - fallback: true, - }); - assert(client); - }); + it('has port', () => { + const port = idsModule.v1.IDSClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new idsModule.v1.IDSClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.iDSStub, undefined); - await client.initialize(); - assert(client.iDSStub); - }); + it('should create a client with no option', () => { + const client = new idsModule.v1.IDSClient(); + assert(client); + }); - it('has close method for the initialized client', done => { - const client = new idsModule.v1.IDSClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.iDSStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('should create a client with gRPC fallback', () => { + const client = new idsModule.v1.IDSClient({ + fallback: true, + }); + assert(client); + }); - it('has close method for the non-initialized client', done => { - const client = new idsModule.v1.IDSClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.iDSStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new idsModule.v1.IDSClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.iDSStub, undefined); + await client.initialize(); + assert(client.iDSStub); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new idsModule.v1.IDSClient({ - 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 idsModule.v1.IDSClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.iDSStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new idsModule.v1.IDSClient({ - 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 idsModule.v1.IDSClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.iDSStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('getEndpoint', () => { - it('invokes getEndpoint without error', async () => { - const client = new idsModule.v1.IDSClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.ids.v1.GetEndpointRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.ids.v1.GetEndpointRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.ids.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('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new idsModule.v1.IDSClient({ + 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 getEndpoint without error using callback', async () => { - const client = new idsModule.v1.IDSClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.ids.v1.GetEndpointRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.ids.v1.GetEndpointRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.ids.v1.Endpoint() - ); - client.innerApiCalls.getEndpoint = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getEndpoint( - request, - (err?: Error|null, result?: protos.google.cloud.ids.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('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new idsModule.v1.IDSClient({ + 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('getEndpoint', () => { + it('invokes getEndpoint without error', async () => { + const client = new idsModule.v1.IDSClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.ids.v1.GetEndpointRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.ids.v1.GetEndpointRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.ids.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 getEndpoint with error', async () => { - const client = new idsModule.v1.IDSClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.ids.v1.GetEndpointRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.ids.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 getEndpoint without error using callback', async () => { + const client = new idsModule.v1.IDSClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.ids.v1.GetEndpointRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.ids.v1.GetEndpointRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.ids.v1.Endpoint(), + ); + client.innerApiCalls.getEndpoint = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getEndpoint( + request, + ( + err?: Error | null, + result?: protos.google.cloud.ids.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 getEndpoint with closed client', async () => { - const client = new idsModule.v1.IDSClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.ids.v1.GetEndpointRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.ids.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 getEndpoint with error', async () => { + const client = new idsModule.v1.IDSClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.ids.v1.GetEndpointRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.ids.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)); }); - describe('createEndpoint', () => { - it('invokes createEndpoint without error', async () => { - const client = new idsModule.v1.IDSClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.ids.v1.CreateEndpointRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.ids.v1.CreateEndpointRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createEndpoint = stubLongRunningCall(expectedResponse); - const [operation] = await client.createEndpoint(request); - const [response] = await operation.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 idsModule.v1.IDSClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.ids.v1.GetEndpointRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.ids.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('createEndpoint', () => { + it('invokes createEndpoint without error', async () => { + const client = new idsModule.v1.IDSClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.ids.v1.CreateEndpointRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.ids.v1.CreateEndpointRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createEndpoint = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createEndpoint(request); + const [response] = await operation.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 without error using callback', async () => { - const client = new idsModule.v1.IDSClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.ids.v1.CreateEndpointRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.ids.v1.CreateEndpointRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createEndpoint = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createEndpoint( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.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 without error using callback', async () => { + const client = new idsModule.v1.IDSClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.ids.v1.CreateEndpointRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.ids.v1.CreateEndpointRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createEndpoint = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createEndpoint( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.ids.v1.IEndpoint, + protos.google.cloud.ids.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.ids.v1.IEndpoint, + protos.google.cloud.ids.v1.IOperationMetadata + >; + const [response] = await operation.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 call error', async () => { - const client = new idsModule.v1.IDSClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.ids.v1.CreateEndpointRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.ids.v1.CreateEndpointRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createEndpoint = stubLongRunningCall(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 call error', async () => { + const client = new idsModule.v1.IDSClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.ids.v1.CreateEndpointRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.ids.v1.CreateEndpointRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createEndpoint = stubLongRunningCall( + 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 LRO error', async () => { - const client = new idsModule.v1.IDSClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.ids.v1.CreateEndpointRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.ids.v1.CreateEndpointRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createEndpoint = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createEndpoint(request); - await assert.rejects(operation.promise(), 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 LRO error', async () => { + const client = new idsModule.v1.IDSClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.ids.v1.CreateEndpointRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.ids.v1.CreateEndpointRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createEndpoint = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createEndpoint(request); + await assert.rejects(operation.promise(), 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 checkCreateEndpointProgress without error', async () => { - const client = new idsModule.v1.IDSClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateEndpointProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkCreateEndpointProgress without error', async () => { + const client = new idsModule.v1.IDSClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateEndpointProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkCreateEndpointProgress with error', async () => { - const client = new idsModule.v1.IDSClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateEndpointProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkCreateEndpointProgress with error', async () => { + const client = new idsModule.v1.IDSClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateEndpointProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteEndpoint', () => { + it('invokes deleteEndpoint without error', async () => { + const client = new idsModule.v1.IDSClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.ids.v1.DeleteEndpointRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.ids.v1.DeleteEndpointRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteEndpoint = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteEndpoint(request); + const [response] = await operation.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('deleteEndpoint', () => { - it('invokes deleteEndpoint without error', async () => { - const client = new idsModule.v1.IDSClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.ids.v1.DeleteEndpointRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.ids.v1.DeleteEndpointRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteEndpoint = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteEndpoint(request); - const [response] = await operation.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 without error using callback', async () => { + const client = new idsModule.v1.IDSClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.ids.v1.DeleteEndpointRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.ids.v1.DeleteEndpointRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteEndpoint = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteEndpoint( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.ids.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.ids.v1.IOperationMetadata + >; + const [response] = await operation.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 without error using callback', async () => { - const client = new idsModule.v1.IDSClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.ids.v1.DeleteEndpointRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.ids.v1.DeleteEndpointRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteEndpoint = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteEndpoint( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.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 call error', async () => { + const client = new idsModule.v1.IDSClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.ids.v1.DeleteEndpointRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.ids.v1.DeleteEndpointRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteEndpoint = stubLongRunningCall( + 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 call error', async () => { - const client = new idsModule.v1.IDSClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.ids.v1.DeleteEndpointRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.ids.v1.DeleteEndpointRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteEndpoint = stubLongRunningCall(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 LRO error', async () => { + const client = new idsModule.v1.IDSClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.ids.v1.DeleteEndpointRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.ids.v1.DeleteEndpointRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteEndpoint = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteEndpoint(request); + await assert.rejects(operation.promise(), 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 LRO error', async () => { - const client = new idsModule.v1.IDSClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.ids.v1.DeleteEndpointRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.ids.v1.DeleteEndpointRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteEndpoint = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteEndpoint(request); - await assert.rejects(operation.promise(), 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 checkDeleteEndpointProgress without error', async () => { + const client = new idsModule.v1.IDSClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteEndpointProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkDeleteEndpointProgress without error', async () => { - const client = new idsModule.v1.IDSClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteEndpointProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkDeleteEndpointProgress with error', async () => { + const client = new idsModule.v1.IDSClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteEndpointProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listEndpoints', () => { + it('invokes listEndpoints without error', async () => { + const client = new idsModule.v1.IDSClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.ids.v1.ListEndpointsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.ids.v1.ListEndpointsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.ids.v1.Endpoint()), + generateSampleMessage(new protos.google.cloud.ids.v1.Endpoint()), + generateSampleMessage(new protos.google.cloud.ids.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 checkDeleteEndpointProgress with error', async () => { - const client = new idsModule.v1.IDSClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteEndpointProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes listEndpoints without error using callback', async () => { + const client = new idsModule.v1.IDSClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.ids.v1.ListEndpointsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.ids.v1.ListEndpointsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.ids.v1.Endpoint()), + generateSampleMessage(new protos.google.cloud.ids.v1.Endpoint()), + generateSampleMessage(new protos.google.cloud.ids.v1.Endpoint()), + ]; + client.innerApiCalls.listEndpoints = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listEndpoints( + request, + ( + err?: Error | null, + result?: protos.google.cloud.ids.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)); }); - describe('listEndpoints', () => { - it('invokes listEndpoints without error', async () => { - const client = new idsModule.v1.IDSClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.ids.v1.ListEndpointsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.ids.v1.ListEndpointsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.ids.v1.Endpoint()), - generateSampleMessage(new protos.google.cloud.ids.v1.Endpoint()), - generateSampleMessage(new protos.google.cloud.ids.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 with error', async () => { + const client = new idsModule.v1.IDSClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.ids.v1.ListEndpointsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.ids.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 without error using callback', async () => { - const client = new idsModule.v1.IDSClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.ids.v1.ListEndpointsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.ids.v1.ListEndpointsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.ids.v1.Endpoint()), - generateSampleMessage(new protos.google.cloud.ids.v1.Endpoint()), - generateSampleMessage(new protos.google.cloud.ids.v1.Endpoint()), - ]; - client.innerApiCalls.listEndpoints = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listEndpoints( - request, - (err?: Error|null, result?: protos.google.cloud.ids.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 listEndpointsStream without error', async () => { + const client = new idsModule.v1.IDSClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.ids.v1.ListEndpointsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.ids.v1.ListEndpointsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.ids.v1.Endpoint()), + generateSampleMessage(new protos.google.cloud.ids.v1.Endpoint()), + generateSampleMessage(new protos.google.cloud.ids.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.ids.v1.Endpoint[] = []; + stream.on('data', (response: protos.google.cloud.ids.v1.Endpoint) => { + responses.push(response); }); - - it('invokes listEndpoints with error', async () => { - const client = new idsModule.v1.IDSClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.ids.v1.ListEndpointsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.ids.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)); + stream.on('end', () => { + resolve(responses); }); - - it('invokes listEndpointsStream without error', async () => { - const client = new idsModule.v1.IDSClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.ids.v1.ListEndpointsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.ids.v1.ListEndpointsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.ids.v1.Endpoint()), - generateSampleMessage(new protos.google.cloud.ids.v1.Endpoint()), - generateSampleMessage(new protos.google.cloud.ids.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.ids.v1.Endpoint[] = []; - stream.on('data', (response: protos.google.cloud.ids.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 - ) - ); + 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 idsModule.v1.IDSClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.ids.v1.ListEndpointsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.ids.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.ids.v1.Endpoint[] = []; - stream.on('data', (response: protos.google.cloud.ids.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 idsModule.v1.IDSClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.ids.v1.ListEndpointsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.ids.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.ids.v1.Endpoint[] = []; + stream.on('data', (response: protos.google.cloud.ids.v1.Endpoint) => { + responses.push(response); }); - - it('uses async iteration with listEndpoints without error', async () => { - const client = new idsModule.v1.IDSClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.ids.v1.ListEndpointsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.ids.v1.ListEndpointsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.ids.v1.Endpoint()), - generateSampleMessage(new protos.google.cloud.ids.v1.Endpoint()), - generateSampleMessage(new protos.google.cloud.ids.v1.Endpoint()), - ]; - client.descriptors.page.listEndpoints.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.ids.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 - ) - ); + stream.on('end', () => { + resolve(responses); }); - - it('uses async iteration with listEndpoints with error', async () => { - const client = new idsModule.v1.IDSClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.ids.v1.ListEndpointsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.ids.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.ids.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 - ) - ); + 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), + ); }); - describe('Path templates', () => { - - describe('endpoint', async () => { - const fakePath = "/rendered/path/endpoint"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - endpoint: "endpointValue", - }; - const client = new idsModule.v1.IDSClient({ - 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", "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('matchEndpointFromEndpointName', () => { - const result = client.matchEndpointFromEndpointName(fakePath); - assert.strictEqual(result, "endpointValue"); - assert((client.pathTemplates.endpointPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('uses async iteration with listEndpoints without error', async () => { + const client = new idsModule.v1.IDSClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.ids.v1.ListEndpointsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.ids.v1.ListEndpointsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.ids.v1.Endpoint()), + generateSampleMessage(new protos.google.cloud.ids.v1.Endpoint()), + generateSampleMessage(new protos.google.cloud.ids.v1.Endpoint()), + ]; + client.descriptors.page.listEndpoints.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.ids.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), + ); + }); - describe('location', async () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new idsModule.v1.IDSClient({ - 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('uses async iteration with listEndpoints with error', async () => { + const client = new idsModule.v1.IDSClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.ids.v1.ListEndpointsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.ids.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.ids.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('Path templates', () => { + describe('endpoint', async () => { + const fakePath = '/rendered/path/endpoint'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + endpoint: 'endpointValue', + }; + const client = new idsModule.v1.IDSClient({ + 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', + '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('matchEndpointFromEndpointName', () => { + const result = client.matchEndpointFromEndpointName(fakePath); + assert.strictEqual(result, 'endpointValue'); + assert( + (client.pathTemplates.endpointPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('project', async () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new idsModule.v1.IDSClient({ - 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('location', async () => { + const fakePath = '/rendered/path/location'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = new idsModule.v1.IDSClient({ + 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 idsModule.v1.IDSClient({ + 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-ids/webpack.config.js b/packages/google-cloud-ids/webpack.config.js index 77a786b1ee25..6a2bec3e34a7 100644 --- a/packages/google-cloud-ids/webpack.config.js +++ b/packages/google-cloud-ids/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-iot/.eslintignore b/packages/google-cloud-iot/.eslintignore new file mode 100644 index 000000000000..cfc348ec4d11 --- /dev/null +++ b/packages/google-cloud-iot/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/packages/google-cloud-iot/.eslintrc.json b/packages/google-cloud-iot/.eslintrc.json new file mode 100644 index 000000000000..3e8d97ccb390 --- /dev/null +++ b/packages/google-cloud-iot/.eslintrc.json @@ -0,0 +1,4 @@ +{ + "extends": "./node_modules/gts", + "root": true +} diff --git a/packages/google-cloud-iot/README.md b/packages/google-cloud-iot/README.md index dcdb7d673ccb..60ef6e8d0fb5 100644 --- a/packages/google-cloud-iot/README.md +++ b/packages/google-cloud-iot/README.md @@ -113,7 +113,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-iot/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`) @@ -123,7 +123,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-iot/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-iot/protos/protos.d.ts b/packages/google-cloud-iot/protos/protos.d.ts index de58f3fa96d3..214af9825b4f 100644 --- a/packages/google-cloud-iot/protos/protos.d.ts +++ b/packages/google-cloud-iot/protos/protos.d.ts @@ -4955,6 +4955,9 @@ export namespace google { /** CommonLanguageSettings destinations */ destinations?: (google.api.ClientLibraryDestination[]|null); + + /** CommonLanguageSettings selectiveGapicGeneration */ + selectiveGapicGeneration?: (google.api.ISelectiveGapicGeneration|null); } /** Represents a CommonLanguageSettings. */ @@ -4972,6 +4975,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 @@ -5672,6 +5678,9 @@ export namespace google { /** PythonSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** PythonSettings experimentalFeatures */ + experimentalFeatures?: (google.api.PythonSettings.IExperimentalFeatures|null); } /** Represents a PythonSettings. */ @@ -5686,6 +5695,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 @@ -5764,6 +5776,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 { @@ -6090,6 +6214,9 @@ export namespace google { /** GoSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** GoSettings renamedServices */ + renamedServices?: ({ [k: string]: string }|null); } /** Represents a GoSettings. */ @@ -6104,6 +6231,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 @@ -6428,6 +6558,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, @@ -6809,6 +7042,7 @@ export namespace google { /** Edition enum. */ enum Edition { EDITION_UNKNOWN = 0, + EDITION_LEGACY = 900, EDITION_PROTO2 = 998, EDITION_PROTO3 = 999, EDITION_2023 = 1000, @@ -6839,6 +7073,9 @@ export namespace google { /** FileDescriptorProto weakDependency */ weakDependency?: (number[]|null); + /** FileDescriptorProto optionDependency */ + optionDependency?: (string[]|null); + /** FileDescriptorProto messageType */ messageType?: (google.protobuf.IDescriptorProto[]|null); @@ -6888,6 +7125,9 @@ export namespace google { /** FileDescriptorProto weakDependency. */ public weakDependency: number[]; + /** FileDescriptorProto optionDependency. */ + public optionDependency: string[]; + /** FileDescriptorProto messageType. */ public messageType: google.protobuf.IDescriptorProto[]; @@ -7022,6 +7262,9 @@ export namespace google { /** DescriptorProto reservedName */ reservedName?: (string[]|null); + + /** DescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents a DescriptorProto. */ @@ -7063,6 +7306,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 @@ -7910,6 +8156,9 @@ export namespace google { /** EnumDescriptorProto reservedName */ reservedName?: (string[]|null); + + /** EnumDescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents an EnumDescriptorProto. */ @@ -7936,6 +8185,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 @@ -8870,6 +9122,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); @@ -8925,6 +9180,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[]; @@ -9145,6 +9403,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. */ @@ -9383,6 +9756,9 @@ export namespace google { /** EnumValueOptions debugRedact */ debugRedact?: (boolean|null); + /** EnumValueOptions featureSupport */ + featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** EnumValueOptions uninterpretedOption */ uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); } @@ -9405,6 +9781,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[]; @@ -9994,6 +10373,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. */ @@ -10023,6 +10408,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 @@ -10145,6 +10536,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. */ @@ -10264,8 +10765,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. */ @@ -10280,8 +10784,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. @@ -10814,6 +11321,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-iot/protos/protos.js b/packages/google-cloud-iot/protos/protos.js index 989a6faa8302..cf732c7919ba 100644 --- a/packages/google-cloud-iot/protos/protos.js +++ b/packages/google-cloud-iot/protos/protos.js @@ -11905,6 +11905,7 @@ * @interface ICommonLanguageSettings * @property {string|null} [referenceDocsUri] CommonLanguageSettings referenceDocsUri * @property {Array.|null} [destinations] CommonLanguageSettings destinations + * @property {google.api.ISelectiveGapicGeneration|null} [selectiveGapicGeneration] CommonLanguageSettings selectiveGapicGeneration */ /** @@ -11939,6 +11940,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 @@ -11971,6 +11980,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; }; @@ -12022,6 +12033,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; @@ -12073,6 +12088,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; }; @@ -12115,6 +12135,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; }; @@ -12133,8 +12158,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) { @@ -12142,6 +12169,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; }; @@ -13964,6 +13993,7 @@ * @memberof google.api * @interface IPythonSettings * @property {google.api.ICommonLanguageSettings|null} [common] PythonSettings common + * @property {google.api.PythonSettings.IExperimentalFeatures|null} [experimentalFeatures] PythonSettings experimentalFeatures */ /** @@ -13989,6 +14019,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 @@ -14015,6 +14053,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; }; @@ -14055,6 +14095,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; @@ -14095,6 +14139,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; }; @@ -14115,6 +14164,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; }; @@ -14131,10 +14185,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; }; @@ -14164,6 +14222,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; })(); @@ -15040,6 +15350,7 @@ * @memberof google.api * @interface IGoSettings * @property {google.api.ICommonLanguageSettings|null} [common] GoSettings common + * @property {Object.|null} [renamedServices] GoSettings renamedServices */ /** @@ -15051,6 +15362,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) @@ -15065,6 +15377,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 @@ -15091,6 +15411,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; }; @@ -15121,7 +15444,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) @@ -15131,6 +15454,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; @@ -15171,6 +15517,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; }; @@ -15191,6 +15545,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; }; @@ -15207,10 +15568,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; }; @@ -15849,30 +16218,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; })(); /** @@ -16834,6 +17448,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 @@ -16848,6 +17463,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; @@ -16872,6 +17488,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 @@ -16894,6 +17511,7 @@ this.dependency = []; this.publicDependency = []; this.weakDependency = []; + this.optionDependency = []; this.messageType = []; this.enumType = []; this.service = []; @@ -16944,6 +17562,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 @@ -17065,6 +17691,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; }; @@ -17137,6 +17766,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 = []; @@ -17239,6 +17874,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"; @@ -17293,6 +17935,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -17345,6 +17988,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"); @@ -17408,6 +18058,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -17473,6 +18127,7 @@ object.extension = []; object.publicDependency = []; object.weakDependency = []; + object.optionDependency = []; } if (options.defaults) { object.name = ""; @@ -17529,6 +18184,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; }; @@ -17577,6 +18237,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 */ /** @@ -17682,6 +18343,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 @@ -17734,6 +18403,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; }; @@ -17826,6 +18497,10 @@ message.reservedName.push(reader.string()); break; } + case 11: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -17939,6 +18614,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; }; @@ -18038,6 +18722,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; }; @@ -18067,6 +18771,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; @@ -18112,6 +18817,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; }; @@ -20156,6 +20863,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 */ /** @@ -20216,6 +20924,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 @@ -20253,6 +20969,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; }; @@ -20315,6 +21033,10 @@ message.reservedName.push(reader.string()); break; } + case 6: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -20383,6 +21105,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; }; @@ -20432,6 +21163,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; }; @@ -20456,6 +21207,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; @@ -20476,6 +21228,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; }; @@ -22794,6 +23548,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 @@ -22914,6 +23669,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 @@ -22988,6 +23751,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(); @@ -23089,6 +23854,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 = []; @@ -23224,6 +23993,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"; @@ -23412,6 +24186,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"); @@ -23509,6 +24288,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")) @@ -23541,6 +24321,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) @@ -23813,6 +24595,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -23854,103 +24637,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; @@ -24545,6 +25814,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 */ @@ -24588,6 +25858,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 @@ -24626,6 +25904,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(); @@ -24677,6 +25957,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 = []; @@ -24729,6 +26013,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"; @@ -24762,6 +26051,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"); @@ -24794,6 +26088,7 @@ object.deprecated = false; object.features = null; object.debugRedact = false; + object.featureSupport = null; } if (message.deprecated != null && message.hasOwnProperty("deprecated")) object.deprecated = message.deprecated; @@ -24801,6 +26096,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) @@ -26240,6 +27537,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 */ /** @@ -26305,6 +27604,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 @@ -26341,6 +27656,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; }; @@ -26401,6 +27720,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; @@ -26491,6 +27818,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; }; @@ -26630,6 +27977,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; }; @@ -26653,6 +28048,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; @@ -26666,6 +28063,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; }; @@ -26793,6 +28194,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; })(); @@ -26977,6 +28591,7 @@ default: return "minimumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -26994,6 +28609,7 @@ default: return "maximumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -27042,6 +28658,10 @@ case 0: message.minimumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.minimumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.minimumEdition = 998; @@ -27094,6 +28714,10 @@ case 0: message.maximumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.maximumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.maximumEdition = 998; @@ -27202,7 +28826,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 */ /** @@ -27229,12 +28854,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. @@ -27260,10 +28893,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; }; @@ -27304,8 +28939,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: @@ -27348,6 +28987,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -27360,10 +29000,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; }; @@ -27391,6 +29036,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -27432,10 +29081,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; }; @@ -27454,13 +29108,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; }; @@ -28675,6 +30332,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-iot/protos/protos.json b/packages/google-cloud-iot/protos/protos.json index f26e23462de8..f58f5aee933d 100644 --- a/packages/google-cloud-iot/protos/protos.json +++ b/packages/google-cloud-iot/protos/protos.json @@ -1209,8 +1209,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": { @@ -1334,6 +1333,10 @@ "rule": "repeated", "type": "ClientLibraryDestination", "id": 2 + }, + "selectiveGapicGeneration": { + "type": "SelectiveGapicGeneration", + "id": 3 } } }, @@ -1474,6 +1477,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 + } + } } } }, @@ -1531,6 +1556,11 @@ "common": { "type": "CommonLanguageSettings", "id": 1 + }, + "renamedServices": { + "keyType": "string", + "type": "string", + "id": 2 } } }, @@ -1592,6 +1622,19 @@ "PACKAGE_MANAGER": 20 } }, + "SelectiveGapicGeneration": { + "fields": { + "methods": { + "rule": "repeated", + "type": "string", + "id": 1 + }, + "generateOmittedAsInternal": { + "type": "bool", + "id": 2 + } + } + }, "LaunchStage": { "values": { "LAUNCH_STAGE_UNSPECIFIED": 0, @@ -1724,12 +1767,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, @@ -1768,6 +1818,11 @@ "type": "int32", "id": 11 }, + "optionDependency": { + "rule": "repeated", + "type": "string", + "id": 15 + }, "messageType": { "rule": "repeated", "type": "DescriptorProto", @@ -1856,6 +1911,10 @@ "rule": "repeated", "type": "string", "id": 10 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 11 } }, "nested": { @@ -2081,6 +2140,10 @@ "rule": "repeated", "type": "string", "id": 5 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 6 } }, "nested": { @@ -2131,7 +2194,14 @@ "type": "ServiceOptions", "id": 3 } - } + }, + "reserved": [ + [ + 4, + 4 + ], + "stream" + ] }, "MethodDescriptorProto": { "edition": "proto2", @@ -2295,6 +2365,7 @@ 42, 42 ], + "php_generic_services", [ 38, 38 @@ -2430,7 +2501,8 @@ "type": "bool", "id": 10, "options": { - "default": false + "default": false, + "deprecated": true } }, "debugRedact": { @@ -2458,6 +2530,10 @@ "type": "FeatureSet", "id": 21 }, + "featureSupport": { + "type": "FeatureSupport", + "id": 22 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -2527,6 +2603,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 + } + } } } }, @@ -2615,6 +2711,10 @@ "default": false } }, + "featureSupport": { + "type": "FieldOptions.FeatureSupport", + "id": 4 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -2757,6 +2857,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_2023", "edition_defaults.value": "EXPLICIT" } @@ -2767,6 +2868,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "OPEN" } @@ -2777,6 +2879,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "PACKED" } @@ -2787,6 +2890,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "VERIFY" } @@ -2797,7 +2901,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" } }, @@ -2807,27 +2912,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, @@ -2872,7 +2988,13 @@ "UTF8_VALIDATION_UNKNOWN": 0, "VERIFY": 2, "NONE": 3 - } + }, + "reserved": [ + [ + 1, + 1 + ] + ] }, "MessageEncoding": { "values": { @@ -2887,6 +3009,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 + } + } + } } } }, @@ -2914,11 +3063,26 @@ "type": "Edition", "id": 3 }, - "features": { + "overridableFeatures": { "type": "FeatureSet", - "id": 2 + "id": 4 + }, + "fixedFeatures": { + "type": "FeatureSet", + "id": 5 } - } + }, + "reserved": [ + [ + 1, + 1 + ], + [ + 2, + 2 + ], + "features" + ] } } }, @@ -2931,6 +3095,12 @@ "id": 1 } }, + "extensions": [ + [ + 536000000, + 536000000 + ] + ], "nested": { "Location": { "fields": { @@ -3016,6 +3186,14 @@ } } }, + "SymbolVisibility": { + "edition": "proto2", + "values": { + "VISIBILITY_UNSET": 0, + "VISIBILITY_LOCAL": 1, + "VISIBILITY_EXPORT": 2 + } + }, "Duration": { "fields": { "seconds": { @@ -3099,13 +3277,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-iot/samples/generated/v1/snippet_metadata_google.cloud.iot.v1.json b/packages/google-cloud-iot/samples/generated/v1/snippet_metadata_google.cloud.iot.v1.json index cf1fdd832d48..30986a775000 100644 --- a/packages/google-cloud-iot/samples/generated/v1/snippet_metadata_google.cloud.iot.v1.json +++ b/packages/google-cloud-iot/samples/generated/v1/snippet_metadata_google.cloud.iot.v1.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-iot", - "version": "5.2.1", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-iot/src/v1/device_manager_client.ts b/packages/google-cloud-iot/src/v1/device_manager_client.ts index c12ea0ba64a2..7ed8d8d3c7e4 100644 --- a/packages/google-cloud-iot/src/v1/device_manager_client.ts +++ b/packages/google-cloud-iot/src/v1/device_manager_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 DeviceManagerClient { 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('iot'); @@ -57,9 +64,9 @@ export class DeviceManagerClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - deviceManagerStub?: Promise<{[name: string]: Function}>; + innerApiCalls: { [name: string]: Function }; + pathTemplates: { [name: string]: gax.PathTemplate }; + deviceManagerStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of DeviceManagerClient. @@ -100,21 +107,42 @@ export class DeviceManagerClient { * const client = new DeviceManagerClient({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 DeviceManagerClient; - 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 = 'cloudiot.' + 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 DeviceManagerClient { 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 DeviceManagerClient { } // 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 DeviceManagerClient { // Create useful helper objects for these. this.pathTemplates = { devicePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/registries/{registry}/devices/{device}' + 'projects/{project}/locations/{location}/registries/{registry}/devices/{device}', ), locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' + 'projects/{project}/locations/{location}', ), registryPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/registries/{registry}' + 'projects/{project}/locations/{location}/registries/{registry}', ), }; @@ -192,16 +217,25 @@ export class DeviceManagerClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listDeviceRegistries: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'deviceRegistries'), - listDevices: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'devices') + listDeviceRegistries: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'deviceRegistries', + ), + listDevices: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'devices', + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.iot.v1.DeviceManager', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.iot.v1.DeviceManager', + 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 +266,60 @@ export class DeviceManagerClient { // Put together the "service stub" for // google.cloud.iot.v1.DeviceManager. this.deviceManagerStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.iot.v1.DeviceManager') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.iot.v1.DeviceManager', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.iot.v1.DeviceManager, - 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 deviceManagerStubMethods = - ['createDeviceRegistry', 'getDeviceRegistry', 'updateDeviceRegistry', 'deleteDeviceRegistry', 'listDeviceRegistries', 'createDevice', 'getDevice', 'updateDevice', 'deleteDevice', 'listDevices', 'modifyCloudToDeviceConfig', 'listDeviceConfigVersions', 'listDeviceStates', 'setIamPolicy', 'getIamPolicy', 'testIamPermissions', 'sendCommandToDevice', 'bindDeviceToGateway', 'unbindDeviceFromGateway']; + const deviceManagerStubMethods = [ + 'createDeviceRegistry', + 'getDeviceRegistry', + 'updateDeviceRegistry', + 'deleteDeviceRegistry', + 'listDeviceRegistries', + 'createDevice', + 'getDevice', + 'updateDevice', + 'deleteDevice', + 'listDevices', + 'modifyCloudToDeviceConfig', + 'listDeviceConfigVersions', + 'listDeviceStates', + 'setIamPolicy', + 'getIamPolicy', + 'testIamPermissions', + 'sendCommandToDevice', + 'bindDeviceToGateway', + 'unbindDeviceFromGateway', + ]; for (const methodName of deviceManagerStubMethods) { const callPromise = this.deviceManagerStub.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 +334,14 @@ export class DeviceManagerClient { * @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 'cloudiot.googleapis.com'; } @@ -289,8 +352,14 @@ export class DeviceManagerClient { * @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 'cloudiot.googleapis.com'; } @@ -323,7 +392,7 @@ export class DeviceManagerClient { static get scopes() { return [ 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/cloudiot' + 'https://www.googleapis.com/auth/cloudiot', ]; } @@ -333,8 +402,9 @@ export class DeviceManagerClient { * 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,1820 +415,2440 @@ export class DeviceManagerClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Creates a device registry that contains devices. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and cloud region where this device registry must be created. - * For example, `projects/example-project/locations/us-central1`. - * @param {google.cloud.iot.v1.DeviceRegistry} request.deviceRegistry - * Required. The device registry. The field `name` must be empty. The server will - * generate that field from the device registry `id` provided and the - * `parent` field. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.iot.v1.DeviceRegistry|DeviceRegistry}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/device_manager.create_device_registry.js - * region_tag:cloudiot_v1_generated_DeviceManager_CreateDeviceRegistry_async - */ + /** + * Creates a device registry that contains devices. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and cloud region where this device registry must be created. + * For example, `projects/example-project/locations/us-central1`. + * @param {google.cloud.iot.v1.DeviceRegistry} request.deviceRegistry + * Required. The device registry. The field `name` must be empty. The server will + * generate that field from the device registry `id` provided and the + * `parent` field. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.iot.v1.DeviceRegistry|DeviceRegistry}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/device_manager.create_device_registry.js + * region_tag:cloudiot_v1_generated_DeviceManager_CreateDeviceRegistry_async + */ createDeviceRegistry( - request?: protos.google.cloud.iot.v1.ICreateDeviceRegistryRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.iot.v1.IDeviceRegistry, - protos.google.cloud.iot.v1.ICreateDeviceRegistryRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.iot.v1.ICreateDeviceRegistryRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.iot.v1.IDeviceRegistry, + protos.google.cloud.iot.v1.ICreateDeviceRegistryRequest | undefined, + {} | undefined, + ] + >; createDeviceRegistry( - request: protos.google.cloud.iot.v1.ICreateDeviceRegistryRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.iot.v1.IDeviceRegistry, - protos.google.cloud.iot.v1.ICreateDeviceRegistryRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.iot.v1.ICreateDeviceRegistryRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.iot.v1.IDeviceRegistry, + | protos.google.cloud.iot.v1.ICreateDeviceRegistryRequest + | null + | undefined, + {} | null | undefined + >, + ): void; createDeviceRegistry( - request: protos.google.cloud.iot.v1.ICreateDeviceRegistryRequest, - callback: Callback< - protos.google.cloud.iot.v1.IDeviceRegistry, - protos.google.cloud.iot.v1.ICreateDeviceRegistryRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.iot.v1.ICreateDeviceRegistryRequest, + callback: Callback< + protos.google.cloud.iot.v1.IDeviceRegistry, + | protos.google.cloud.iot.v1.ICreateDeviceRegistryRequest + | null + | undefined, + {} | null | undefined + >, + ): void; createDeviceRegistry( - request?: protos.google.cloud.iot.v1.ICreateDeviceRegistryRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.iot.v1.IDeviceRegistry, - protos.google.cloud.iot.v1.ICreateDeviceRegistryRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.iot.v1.ICreateDeviceRegistryRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.iot.v1.IDeviceRegistry, - protos.google.cloud.iot.v1.ICreateDeviceRegistryRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.iot.v1.IDeviceRegistry, - protos.google.cloud.iot.v1.ICreateDeviceRegistryRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.iot.v1.ICreateDeviceRegistryRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.iot.v1.IDeviceRegistry, + | protos.google.cloud.iot.v1.ICreateDeviceRegistryRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.iot.v1.IDeviceRegistry, + protos.google.cloud.iot.v1.ICreateDeviceRegistryRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.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('createDeviceRegistry request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.iot.v1.IDeviceRegistry, - protos.google.cloud.iot.v1.ICreateDeviceRegistryRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.iot.v1.IDeviceRegistry, + | protos.google.cloud.iot.v1.ICreateDeviceRegistryRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('createDeviceRegistry response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.createDeviceRegistry(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.iot.v1.IDeviceRegistry, - protos.google.cloud.iot.v1.ICreateDeviceRegistryRequest|undefined, - {}|undefined - ]) => { - this._log.info('createDeviceRegistry response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .createDeviceRegistry(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.iot.v1.IDeviceRegistry, + protos.google.cloud.iot.v1.ICreateDeviceRegistryRequest | undefined, + {} | undefined, + ]) => { + this._log.info('createDeviceRegistry response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 device registry configuration. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the device registry. For example, - * `projects/example-project/locations/us-central1/registries/my-registry`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.iot.v1.DeviceRegistry|DeviceRegistry}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/device_manager.get_device_registry.js - * region_tag:cloudiot_v1_generated_DeviceManager_GetDeviceRegistry_async - */ + /** + * Gets a device registry configuration. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the device registry. For example, + * `projects/example-project/locations/us-central1/registries/my-registry`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.iot.v1.DeviceRegistry|DeviceRegistry}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/device_manager.get_device_registry.js + * region_tag:cloudiot_v1_generated_DeviceManager_GetDeviceRegistry_async + */ getDeviceRegistry( - request?: protos.google.cloud.iot.v1.IGetDeviceRegistryRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.iot.v1.IDeviceRegistry, - protos.google.cloud.iot.v1.IGetDeviceRegistryRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.iot.v1.IGetDeviceRegistryRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.iot.v1.IDeviceRegistry, + protos.google.cloud.iot.v1.IGetDeviceRegistryRequest | undefined, + {} | undefined, + ] + >; getDeviceRegistry( - request: protos.google.cloud.iot.v1.IGetDeviceRegistryRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.iot.v1.IDeviceRegistry, - protos.google.cloud.iot.v1.IGetDeviceRegistryRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.iot.v1.IGetDeviceRegistryRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.iot.v1.IDeviceRegistry, + protos.google.cloud.iot.v1.IGetDeviceRegistryRequest | null | undefined, + {} | null | undefined + >, + ): void; getDeviceRegistry( - request: protos.google.cloud.iot.v1.IGetDeviceRegistryRequest, - callback: Callback< - protos.google.cloud.iot.v1.IDeviceRegistry, - protos.google.cloud.iot.v1.IGetDeviceRegistryRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.iot.v1.IGetDeviceRegistryRequest, + callback: Callback< + protos.google.cloud.iot.v1.IDeviceRegistry, + protos.google.cloud.iot.v1.IGetDeviceRegistryRequest | null | undefined, + {} | null | undefined + >, + ): void; getDeviceRegistry( - request?: protos.google.cloud.iot.v1.IGetDeviceRegistryRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.iot.v1.IDeviceRegistry, - protos.google.cloud.iot.v1.IGetDeviceRegistryRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.iot.v1.IGetDeviceRegistryRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.iot.v1.IDeviceRegistry, - protos.google.cloud.iot.v1.IGetDeviceRegistryRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.iot.v1.IDeviceRegistry, - protos.google.cloud.iot.v1.IGetDeviceRegistryRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.iot.v1.IGetDeviceRegistryRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.iot.v1.IDeviceRegistry, + protos.google.cloud.iot.v1.IGetDeviceRegistryRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.iot.v1.IDeviceRegistry, + protos.google.cloud.iot.v1.IGetDeviceRegistryRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getDeviceRegistry request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.iot.v1.IDeviceRegistry, - protos.google.cloud.iot.v1.IGetDeviceRegistryRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.iot.v1.IDeviceRegistry, + | protos.google.cloud.iot.v1.IGetDeviceRegistryRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getDeviceRegistry response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getDeviceRegistry(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.iot.v1.IDeviceRegistry, - protos.google.cloud.iot.v1.IGetDeviceRegistryRequest|undefined, - {}|undefined - ]) => { - this._log.info('getDeviceRegistry response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getDeviceRegistry(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.iot.v1.IDeviceRegistry, + protos.google.cloud.iot.v1.IGetDeviceRegistryRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getDeviceRegistry response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 device registry configuration. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.iot.v1.DeviceRegistry} request.deviceRegistry - * Required. The new values for the device registry. The `id` field must be empty, and - * the `name` field must indicate the path of the resource. For example, - * `projects/example-project/locations/us-central1/registries/my-registry`. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. Only updates the `device_registry` fields indicated by this mask. - * The field mask must not be empty, and it must not contain fields that - * are immutable or only set by the server. - * Mutable top-level fields: `event_notification_config`, `http_config`, - * `mqtt_config`, and `state_notification_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.iot.v1.DeviceRegistry|DeviceRegistry}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/device_manager.update_device_registry.js - * region_tag:cloudiot_v1_generated_DeviceManager_UpdateDeviceRegistry_async - */ + /** + * Updates a device registry configuration. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.iot.v1.DeviceRegistry} request.deviceRegistry + * Required. The new values for the device registry. The `id` field must be empty, and + * the `name` field must indicate the path of the resource. For example, + * `projects/example-project/locations/us-central1/registries/my-registry`. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. Only updates the `device_registry` fields indicated by this mask. + * The field mask must not be empty, and it must not contain fields that + * are immutable or only set by the server. + * Mutable top-level fields: `event_notification_config`, `http_config`, + * `mqtt_config`, and `state_notification_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.iot.v1.DeviceRegistry|DeviceRegistry}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/device_manager.update_device_registry.js + * region_tag:cloudiot_v1_generated_DeviceManager_UpdateDeviceRegistry_async + */ updateDeviceRegistry( - request?: protos.google.cloud.iot.v1.IUpdateDeviceRegistryRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.iot.v1.IDeviceRegistry, - protos.google.cloud.iot.v1.IUpdateDeviceRegistryRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.iot.v1.IUpdateDeviceRegistryRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.iot.v1.IDeviceRegistry, + protos.google.cloud.iot.v1.IUpdateDeviceRegistryRequest | undefined, + {} | undefined, + ] + >; updateDeviceRegistry( - request: protos.google.cloud.iot.v1.IUpdateDeviceRegistryRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.iot.v1.IDeviceRegistry, - protos.google.cloud.iot.v1.IUpdateDeviceRegistryRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.iot.v1.IUpdateDeviceRegistryRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.iot.v1.IDeviceRegistry, + | protos.google.cloud.iot.v1.IUpdateDeviceRegistryRequest + | null + | undefined, + {} | null | undefined + >, + ): void; updateDeviceRegistry( - request: protos.google.cloud.iot.v1.IUpdateDeviceRegistryRequest, - callback: Callback< - protos.google.cloud.iot.v1.IDeviceRegistry, - protos.google.cloud.iot.v1.IUpdateDeviceRegistryRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.iot.v1.IUpdateDeviceRegistryRequest, + callback: Callback< + protos.google.cloud.iot.v1.IDeviceRegistry, + | protos.google.cloud.iot.v1.IUpdateDeviceRegistryRequest + | null + | undefined, + {} | null | undefined + >, + ): void; updateDeviceRegistry( - request?: protos.google.cloud.iot.v1.IUpdateDeviceRegistryRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.iot.v1.IDeviceRegistry, - protos.google.cloud.iot.v1.IUpdateDeviceRegistryRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.iot.v1.IUpdateDeviceRegistryRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.iot.v1.IDeviceRegistry, - protos.google.cloud.iot.v1.IUpdateDeviceRegistryRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.iot.v1.IDeviceRegistry, - protos.google.cloud.iot.v1.IUpdateDeviceRegistryRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.iot.v1.IUpdateDeviceRegistryRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.iot.v1.IDeviceRegistry, + | protos.google.cloud.iot.v1.IUpdateDeviceRegistryRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.iot.v1.IDeviceRegistry, + protos.google.cloud.iot.v1.IUpdateDeviceRegistryRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'device_registry.name': request.deviceRegistry!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'device_registry.name': request.deviceRegistry!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('updateDeviceRegistry request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.iot.v1.IDeviceRegistry, - protos.google.cloud.iot.v1.IUpdateDeviceRegistryRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.iot.v1.IDeviceRegistry, + | protos.google.cloud.iot.v1.IUpdateDeviceRegistryRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('updateDeviceRegistry response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.updateDeviceRegistry(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.iot.v1.IDeviceRegistry, - protos.google.cloud.iot.v1.IUpdateDeviceRegistryRequest|undefined, - {}|undefined - ]) => { - this._log.info('updateDeviceRegistry response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .updateDeviceRegistry(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.iot.v1.IDeviceRegistry, + protos.google.cloud.iot.v1.IUpdateDeviceRegistryRequest | undefined, + {} | undefined, + ]) => { + this._log.info('updateDeviceRegistry response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 device registry configuration. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the device registry. For example, - * `projects/example-project/locations/us-central1/registries/my-registry`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for 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/device_manager.delete_device_registry.js - * region_tag:cloudiot_v1_generated_DeviceManager_DeleteDeviceRegistry_async - */ + /** + * Deletes a device registry configuration. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the device registry. For example, + * `projects/example-project/locations/us-central1/registries/my-registry`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for 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/device_manager.delete_device_registry.js + * region_tag:cloudiot_v1_generated_DeviceManager_DeleteDeviceRegistry_async + */ deleteDeviceRegistry( - request?: protos.google.cloud.iot.v1.IDeleteDeviceRegistryRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.iot.v1.IDeleteDeviceRegistryRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.iot.v1.IDeleteDeviceRegistryRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.iot.v1.IDeleteDeviceRegistryRequest | undefined, + {} | undefined, + ] + >; deleteDeviceRegistry( - request: protos.google.cloud.iot.v1.IDeleteDeviceRegistryRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.iot.v1.IDeleteDeviceRegistryRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.iot.v1.IDeleteDeviceRegistryRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.iot.v1.IDeleteDeviceRegistryRequest + | null + | undefined, + {} | null | undefined + >, + ): void; deleteDeviceRegistry( - request: protos.google.cloud.iot.v1.IDeleteDeviceRegistryRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.iot.v1.IDeleteDeviceRegistryRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.iot.v1.IDeleteDeviceRegistryRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.iot.v1.IDeleteDeviceRegistryRequest + | null + | undefined, + {} | null | undefined + >, + ): void; deleteDeviceRegistry( - request?: protos.google.cloud.iot.v1.IDeleteDeviceRegistryRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.iot.v1.IDeleteDeviceRegistryRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.iot.v1.IDeleteDeviceRegistryRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.protobuf.IEmpty, - protos.google.cloud.iot.v1.IDeleteDeviceRegistryRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.iot.v1.IDeleteDeviceRegistryRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.iot.v1.IDeleteDeviceRegistryRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.iot.v1.IDeleteDeviceRegistryRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.iot.v1.IDeleteDeviceRegistryRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('deleteDeviceRegistry request %j', request); - const wrappedCallback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.iot.v1.IDeleteDeviceRegistryRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.iot.v1.IDeleteDeviceRegistryRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('deleteDeviceRegistry response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.deleteDeviceRegistry(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.protobuf.IEmpty, - protos.google.cloud.iot.v1.IDeleteDeviceRegistryRequest|undefined, - {}|undefined - ]) => { - this._log.info('deleteDeviceRegistry response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .deleteDeviceRegistry(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + protos.google.cloud.iot.v1.IDeleteDeviceRegistryRequest | undefined, + {} | undefined, + ]) => { + this._log.info('deleteDeviceRegistry response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 device in a device registry. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the device registry where this device should be created. - * For example, - * `projects/example-project/locations/us-central1/registries/my-registry`. - * @param {google.cloud.iot.v1.Device} request.device - * Required. The device registration details. The field `name` must be empty. The server - * generates `name` from the device registry `id` and the - * `parent` field. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.iot.v1.Device|Device}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/device_manager.create_device.js - * region_tag:cloudiot_v1_generated_DeviceManager_CreateDevice_async - */ + /** + * Creates a device in a device registry. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the device registry where this device should be created. + * For example, + * `projects/example-project/locations/us-central1/registries/my-registry`. + * @param {google.cloud.iot.v1.Device} request.device + * Required. The device registration details. The field `name` must be empty. The server + * generates `name` from the device registry `id` and the + * `parent` field. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.iot.v1.Device|Device}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/device_manager.create_device.js + * region_tag:cloudiot_v1_generated_DeviceManager_CreateDevice_async + */ createDevice( - request?: protos.google.cloud.iot.v1.ICreateDeviceRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.iot.v1.IDevice, - protos.google.cloud.iot.v1.ICreateDeviceRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.iot.v1.ICreateDeviceRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.iot.v1.IDevice, + protos.google.cloud.iot.v1.ICreateDeviceRequest | undefined, + {} | undefined, + ] + >; createDevice( - request: protos.google.cloud.iot.v1.ICreateDeviceRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.iot.v1.IDevice, - protos.google.cloud.iot.v1.ICreateDeviceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.iot.v1.ICreateDeviceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.iot.v1.IDevice, + protos.google.cloud.iot.v1.ICreateDeviceRequest | null | undefined, + {} | null | undefined + >, + ): void; createDevice( - request: protos.google.cloud.iot.v1.ICreateDeviceRequest, - callback: Callback< - protos.google.cloud.iot.v1.IDevice, - protos.google.cloud.iot.v1.ICreateDeviceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.iot.v1.ICreateDeviceRequest, + callback: Callback< + protos.google.cloud.iot.v1.IDevice, + protos.google.cloud.iot.v1.ICreateDeviceRequest | null | undefined, + {} | null | undefined + >, + ): void; createDevice( - request?: protos.google.cloud.iot.v1.ICreateDeviceRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.iot.v1.ICreateDeviceRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.iot.v1.IDevice, - protos.google.cloud.iot.v1.ICreateDeviceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.iot.v1.IDevice, - protos.google.cloud.iot.v1.ICreateDeviceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.iot.v1.IDevice, - protos.google.cloud.iot.v1.ICreateDeviceRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.iot.v1.ICreateDeviceRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.iot.v1.IDevice, + protos.google.cloud.iot.v1.ICreateDeviceRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.iot.v1.IDevice, + protos.google.cloud.iot.v1.ICreateDeviceRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.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('createDevice request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.iot.v1.IDevice, - protos.google.cloud.iot.v1.ICreateDeviceRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.iot.v1.IDevice, + protos.google.cloud.iot.v1.ICreateDeviceRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('createDevice response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.createDevice(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.iot.v1.IDevice, - protos.google.cloud.iot.v1.ICreateDeviceRequest|undefined, - {}|undefined - ]) => { - this._log.info('createDevice response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .createDevice(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.iot.v1.IDevice, + protos.google.cloud.iot.v1.ICreateDeviceRequest | undefined, + {} | undefined, + ]) => { + this._log.info('createDevice response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Gets details about a device. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the device. For example, - * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or - * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. - * @param {google.protobuf.FieldMask} request.fieldMask - * The fields of the `Device` resource to be returned in the response. If the - * field mask is unset or empty, all fields are returned. Fields have to be - * provided in snake_case format, for example: `last_heartbeat_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 an object representing {@link protos.google.cloud.iot.v1.Device|Device}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/device_manager.get_device.js - * region_tag:cloudiot_v1_generated_DeviceManager_GetDevice_async - */ + /** + * Gets details about a device. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the device. For example, + * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or + * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. + * @param {google.protobuf.FieldMask} request.fieldMask + * The fields of the `Device` resource to be returned in the response. If the + * field mask is unset or empty, all fields are returned. Fields have to be + * provided in snake_case format, for example: `last_heartbeat_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 an object representing {@link protos.google.cloud.iot.v1.Device|Device}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/device_manager.get_device.js + * region_tag:cloudiot_v1_generated_DeviceManager_GetDevice_async + */ getDevice( - request?: protos.google.cloud.iot.v1.IGetDeviceRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.iot.v1.IDevice, - protos.google.cloud.iot.v1.IGetDeviceRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.iot.v1.IGetDeviceRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.iot.v1.IDevice, + protos.google.cloud.iot.v1.IGetDeviceRequest | undefined, + {} | undefined, + ] + >; getDevice( - request: protos.google.cloud.iot.v1.IGetDeviceRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.iot.v1.IDevice, - protos.google.cloud.iot.v1.IGetDeviceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.iot.v1.IGetDeviceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.iot.v1.IDevice, + protos.google.cloud.iot.v1.IGetDeviceRequest | null | undefined, + {} | null | undefined + >, + ): void; getDevice( - request: protos.google.cloud.iot.v1.IGetDeviceRequest, - callback: Callback< - protos.google.cloud.iot.v1.IDevice, - protos.google.cloud.iot.v1.IGetDeviceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.iot.v1.IGetDeviceRequest, + callback: Callback< + protos.google.cloud.iot.v1.IDevice, + protos.google.cloud.iot.v1.IGetDeviceRequest | null | undefined, + {} | null | undefined + >, + ): void; getDevice( - request?: protos.google.cloud.iot.v1.IGetDeviceRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.iot.v1.IGetDeviceRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.iot.v1.IDevice, - protos.google.cloud.iot.v1.IGetDeviceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.iot.v1.IDevice, - protos.google.cloud.iot.v1.IGetDeviceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.iot.v1.IDevice, - protos.google.cloud.iot.v1.IGetDeviceRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.iot.v1.IGetDeviceRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.iot.v1.IDevice, + protos.google.cloud.iot.v1.IGetDeviceRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.iot.v1.IDevice, + protos.google.cloud.iot.v1.IGetDeviceRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getDevice request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.iot.v1.IDevice, - protos.google.cloud.iot.v1.IGetDeviceRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.iot.v1.IDevice, + protos.google.cloud.iot.v1.IGetDeviceRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getDevice response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getDevice(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.iot.v1.IDevice, - protos.google.cloud.iot.v1.IGetDeviceRequest|undefined, - {}|undefined - ]) => { - this._log.info('getDevice response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getDevice(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.iot.v1.IDevice, + protos.google.cloud.iot.v1.IGetDeviceRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getDevice response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 device. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.iot.v1.Device} request.device - * Required. The new values for the device. The `id` and `num_id` fields must - * be empty, and the field `name` must specify the name path. For example, - * `projects/p0/locations/us-central1/registries/registry0/devices/device0`or - * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. Only updates the `device` fields indicated by this mask. - * The field mask must not be empty, and it must not contain fields that - * are immutable or only set by the server. - * Mutable top-level fields: `credentials`, `blocked`, and `metadata` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.iot.v1.Device|Device}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/device_manager.update_device.js - * region_tag:cloudiot_v1_generated_DeviceManager_UpdateDevice_async - */ + /** + * Updates a device. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.iot.v1.Device} request.device + * Required. The new values for the device. The `id` and `num_id` fields must + * be empty, and the field `name` must specify the name path. For example, + * `projects/p0/locations/us-central1/registries/registry0/devices/device0`or + * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. Only updates the `device` fields indicated by this mask. + * The field mask must not be empty, and it must not contain fields that + * are immutable or only set by the server. + * Mutable top-level fields: `credentials`, `blocked`, and `metadata` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.iot.v1.Device|Device}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/device_manager.update_device.js + * region_tag:cloudiot_v1_generated_DeviceManager_UpdateDevice_async + */ updateDevice( - request?: protos.google.cloud.iot.v1.IUpdateDeviceRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.iot.v1.IDevice, - protos.google.cloud.iot.v1.IUpdateDeviceRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.iot.v1.IUpdateDeviceRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.iot.v1.IDevice, + protos.google.cloud.iot.v1.IUpdateDeviceRequest | undefined, + {} | undefined, + ] + >; updateDevice( - request: protos.google.cloud.iot.v1.IUpdateDeviceRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.iot.v1.IDevice, - protos.google.cloud.iot.v1.IUpdateDeviceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.iot.v1.IUpdateDeviceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.iot.v1.IDevice, + protos.google.cloud.iot.v1.IUpdateDeviceRequest | null | undefined, + {} | null | undefined + >, + ): void; updateDevice( - request: protos.google.cloud.iot.v1.IUpdateDeviceRequest, - callback: Callback< - protos.google.cloud.iot.v1.IDevice, - protos.google.cloud.iot.v1.IUpdateDeviceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.iot.v1.IUpdateDeviceRequest, + callback: Callback< + protos.google.cloud.iot.v1.IDevice, + protos.google.cloud.iot.v1.IUpdateDeviceRequest | null | undefined, + {} | null | undefined + >, + ): void; updateDevice( - request?: protos.google.cloud.iot.v1.IUpdateDeviceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.iot.v1.IDevice, - protos.google.cloud.iot.v1.IUpdateDeviceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.iot.v1.IUpdateDeviceRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.iot.v1.IDevice, - protos.google.cloud.iot.v1.IUpdateDeviceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.iot.v1.IDevice, - protos.google.cloud.iot.v1.IUpdateDeviceRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.iot.v1.IUpdateDeviceRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.iot.v1.IDevice, + protos.google.cloud.iot.v1.IUpdateDeviceRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.iot.v1.IDevice, + protos.google.cloud.iot.v1.IUpdateDeviceRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'device.name': request.device!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'device.name': request.device!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('updateDevice request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.iot.v1.IDevice, - protos.google.cloud.iot.v1.IUpdateDeviceRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.iot.v1.IDevice, + protos.google.cloud.iot.v1.IUpdateDeviceRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('updateDevice response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.updateDevice(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.iot.v1.IDevice, - protos.google.cloud.iot.v1.IUpdateDeviceRequest|undefined, - {}|undefined - ]) => { - this._log.info('updateDevice response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .updateDevice(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.iot.v1.IDevice, + protos.google.cloud.iot.v1.IUpdateDeviceRequest | undefined, + {} | undefined, + ]) => { + this._log.info('updateDevice response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 device. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the device. For example, - * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or - * `projects/p0/locations/us-central1/registries/registry0/devices/{num_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/v1/device_manager.delete_device.js - * region_tag:cloudiot_v1_generated_DeviceManager_DeleteDevice_async - */ + /** + * Deletes a device. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the device. For example, + * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or + * `projects/p0/locations/us-central1/registries/registry0/devices/{num_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/v1/device_manager.delete_device.js + * region_tag:cloudiot_v1_generated_DeviceManager_DeleteDevice_async + */ deleteDevice( - request?: protos.google.cloud.iot.v1.IDeleteDeviceRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.iot.v1.IDeleteDeviceRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.iot.v1.IDeleteDeviceRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.iot.v1.IDeleteDeviceRequest | undefined, + {} | undefined, + ] + >; deleteDevice( - request: protos.google.cloud.iot.v1.IDeleteDeviceRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.iot.v1.IDeleteDeviceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.iot.v1.IDeleteDeviceRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.iot.v1.IDeleteDeviceRequest | null | undefined, + {} | null | undefined + >, + ): void; deleteDevice( - request: protos.google.cloud.iot.v1.IDeleteDeviceRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.iot.v1.IDeleteDeviceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.iot.v1.IDeleteDeviceRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.iot.v1.IDeleteDeviceRequest | null | undefined, + {} | null | undefined + >, + ): void; deleteDevice( - request?: protos.google.cloud.iot.v1.IDeleteDeviceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.iot.v1.IDeleteDeviceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.iot.v1.IDeleteDeviceRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.protobuf.IEmpty, - protos.google.cloud.iot.v1.IDeleteDeviceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.iot.v1.IDeleteDeviceRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.iot.v1.IDeleteDeviceRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.iot.v1.IDeleteDeviceRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.iot.v1.IDeleteDeviceRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('deleteDevice request %j', request); - const wrappedCallback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.iot.v1.IDeleteDeviceRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.iot.v1.IDeleteDeviceRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('deleteDevice response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.deleteDevice(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.protobuf.IEmpty, - protos.google.cloud.iot.v1.IDeleteDeviceRequest|undefined, - {}|undefined - ]) => { - this._log.info('deleteDevice response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .deleteDevice(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + protos.google.cloud.iot.v1.IDeleteDeviceRequest | undefined, + {} | undefined, + ]) => { + this._log.info('deleteDevice response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Modifies the configuration for the device, which is eventually sent from - * the Cloud IoT Core servers. Returns the modified configuration version and - * its metadata. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the device. For example, - * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or - * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. - * @param {number} request.versionToUpdate - * The version number to update. If this value is zero, it will not check the - * version number of the server and will always update the current version; - * otherwise, this update will fail if the version number found on the server - * does not match this version number. This is used to support multiple - * simultaneous updates without losing data. - * @param {Buffer} request.binaryData - * Required. The configuration data for the device. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.iot.v1.DeviceConfig|DeviceConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/device_manager.modify_cloud_to_device_config.js - * region_tag:cloudiot_v1_generated_DeviceManager_ModifyCloudToDeviceConfig_async - */ + /** + * Modifies the configuration for the device, which is eventually sent from + * the Cloud IoT Core servers. Returns the modified configuration version and + * its metadata. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the device. For example, + * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or + * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. + * @param {number} request.versionToUpdate + * The version number to update. If this value is zero, it will not check the + * version number of the server and will always update the current version; + * otherwise, this update will fail if the version number found on the server + * does not match this version number. This is used to support multiple + * simultaneous updates without losing data. + * @param {Buffer} request.binaryData + * Required. The configuration data for the device. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.iot.v1.DeviceConfig|DeviceConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/device_manager.modify_cloud_to_device_config.js + * region_tag:cloudiot_v1_generated_DeviceManager_ModifyCloudToDeviceConfig_async + */ modifyCloudToDeviceConfig( - request?: protos.google.cloud.iot.v1.IModifyCloudToDeviceConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.iot.v1.IDeviceConfig, - protos.google.cloud.iot.v1.IModifyCloudToDeviceConfigRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.iot.v1.IModifyCloudToDeviceConfigRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.iot.v1.IDeviceConfig, + protos.google.cloud.iot.v1.IModifyCloudToDeviceConfigRequest | undefined, + {} | undefined, + ] + >; modifyCloudToDeviceConfig( - request: protos.google.cloud.iot.v1.IModifyCloudToDeviceConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.iot.v1.IDeviceConfig, - protos.google.cloud.iot.v1.IModifyCloudToDeviceConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.iot.v1.IModifyCloudToDeviceConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.iot.v1.IDeviceConfig, + | protos.google.cloud.iot.v1.IModifyCloudToDeviceConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): void; modifyCloudToDeviceConfig( - request: protos.google.cloud.iot.v1.IModifyCloudToDeviceConfigRequest, - callback: Callback< - protos.google.cloud.iot.v1.IDeviceConfig, - protos.google.cloud.iot.v1.IModifyCloudToDeviceConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.iot.v1.IModifyCloudToDeviceConfigRequest, + callback: Callback< + protos.google.cloud.iot.v1.IDeviceConfig, + | protos.google.cloud.iot.v1.IModifyCloudToDeviceConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): void; modifyCloudToDeviceConfig( - request?: protos.google.cloud.iot.v1.IModifyCloudToDeviceConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.iot.v1.IDeviceConfig, - protos.google.cloud.iot.v1.IModifyCloudToDeviceConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.iot.v1.IModifyCloudToDeviceConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.iot.v1.IDeviceConfig, - protos.google.cloud.iot.v1.IModifyCloudToDeviceConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.iot.v1.IDeviceConfig, - protos.google.cloud.iot.v1.IModifyCloudToDeviceConfigRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.iot.v1.IModifyCloudToDeviceConfigRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.iot.v1.IDeviceConfig, + | protos.google.cloud.iot.v1.IModifyCloudToDeviceConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.iot.v1.IDeviceConfig, + protos.google.cloud.iot.v1.IModifyCloudToDeviceConfigRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('modifyCloudToDeviceConfig request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.iot.v1.IDeviceConfig, - protos.google.cloud.iot.v1.IModifyCloudToDeviceConfigRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.iot.v1.IDeviceConfig, + | protos.google.cloud.iot.v1.IModifyCloudToDeviceConfigRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('modifyCloudToDeviceConfig response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.modifyCloudToDeviceConfig(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.iot.v1.IDeviceConfig, - protos.google.cloud.iot.v1.IModifyCloudToDeviceConfigRequest|undefined, - {}|undefined - ]) => { - this._log.info('modifyCloudToDeviceConfig response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .modifyCloudToDeviceConfig(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.iot.v1.IDeviceConfig, + ( + | protos.google.cloud.iot.v1.IModifyCloudToDeviceConfigRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('modifyCloudToDeviceConfig response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 the last few versions of the device configuration in descending - * order (i.e.: newest first). - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the device. For example, - * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or - * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. - * @param {number} request.numVersions - * The number of versions to list. Versions are listed in decreasing order of - * the version number. The maximum number of versions retained is 10. If this - * value is zero, it will return all the versions available. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.iot.v1.ListDeviceConfigVersionsResponse|ListDeviceConfigVersionsResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/device_manager.list_device_config_versions.js - * region_tag:cloudiot_v1_generated_DeviceManager_ListDeviceConfigVersions_async - */ + /** + * Lists the last few versions of the device configuration in descending + * order (i.e.: newest first). + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the device. For example, + * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or + * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. + * @param {number} request.numVersions + * The number of versions to list. Versions are listed in decreasing order of + * the version number. The maximum number of versions retained is 10. If this + * value is zero, it will return all the versions available. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.iot.v1.ListDeviceConfigVersionsResponse|ListDeviceConfigVersionsResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/device_manager.list_device_config_versions.js + * region_tag:cloudiot_v1_generated_DeviceManager_ListDeviceConfigVersions_async + */ listDeviceConfigVersions( - request?: protos.google.cloud.iot.v1.IListDeviceConfigVersionsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.iot.v1.IListDeviceConfigVersionsResponse, - protos.google.cloud.iot.v1.IListDeviceConfigVersionsRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.iot.v1.IListDeviceConfigVersionsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.iot.v1.IListDeviceConfigVersionsResponse, + protos.google.cloud.iot.v1.IListDeviceConfigVersionsRequest | undefined, + {} | undefined, + ] + >; listDeviceConfigVersions( - request: protos.google.cloud.iot.v1.IListDeviceConfigVersionsRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.iot.v1.IListDeviceConfigVersionsResponse, - protos.google.cloud.iot.v1.IListDeviceConfigVersionsRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.iot.v1.IListDeviceConfigVersionsRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.iot.v1.IListDeviceConfigVersionsResponse, + | protos.google.cloud.iot.v1.IListDeviceConfigVersionsRequest + | null + | undefined, + {} | null | undefined + >, + ): void; listDeviceConfigVersions( - request: protos.google.cloud.iot.v1.IListDeviceConfigVersionsRequest, - callback: Callback< - protos.google.cloud.iot.v1.IListDeviceConfigVersionsResponse, - protos.google.cloud.iot.v1.IListDeviceConfigVersionsRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.iot.v1.IListDeviceConfigVersionsRequest, + callback: Callback< + protos.google.cloud.iot.v1.IListDeviceConfigVersionsResponse, + | protos.google.cloud.iot.v1.IListDeviceConfigVersionsRequest + | null + | undefined, + {} | null | undefined + >, + ): void; listDeviceConfigVersions( - request?: protos.google.cloud.iot.v1.IListDeviceConfigVersionsRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.iot.v1.IListDeviceConfigVersionsRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.iot.v1.IListDeviceConfigVersionsResponse, - protos.google.cloud.iot.v1.IListDeviceConfigVersionsRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.iot.v1.IListDeviceConfigVersionsResponse, - protos.google.cloud.iot.v1.IListDeviceConfigVersionsRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.iot.v1.IListDeviceConfigVersionsResponse, - protos.google.cloud.iot.v1.IListDeviceConfigVersionsRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.iot.v1.IListDeviceConfigVersionsRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.iot.v1.IListDeviceConfigVersionsResponse, + | protos.google.cloud.iot.v1.IListDeviceConfigVersionsRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.iot.v1.IListDeviceConfigVersionsResponse, + protos.google.cloud.iot.v1.IListDeviceConfigVersionsRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('listDeviceConfigVersions request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.iot.v1.IListDeviceConfigVersionsResponse, - protos.google.cloud.iot.v1.IListDeviceConfigVersionsRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.iot.v1.IListDeviceConfigVersionsResponse, + | protos.google.cloud.iot.v1.IListDeviceConfigVersionsRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('listDeviceConfigVersions response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.listDeviceConfigVersions(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.iot.v1.IListDeviceConfigVersionsResponse, - protos.google.cloud.iot.v1.IListDeviceConfigVersionsRequest|undefined, - {}|undefined - ]) => { - this._log.info('listDeviceConfigVersions response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .listDeviceConfigVersions(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.iot.v1.IListDeviceConfigVersionsResponse, + ( + | protos.google.cloud.iot.v1.IListDeviceConfigVersionsRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('listDeviceConfigVersions response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 the last few versions of the device state in descending order (i.e.: - * newest first). - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the device. For example, - * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or - * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. - * @param {number} request.numStates - * The number of states to list. States are listed in descending order of - * update time. The maximum number of states retained is 10. If this - * value is zero, it will return all the states available. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.iot.v1.ListDeviceStatesResponse|ListDeviceStatesResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/device_manager.list_device_states.js - * region_tag:cloudiot_v1_generated_DeviceManager_ListDeviceStates_async - */ + /** + * Lists the last few versions of the device state in descending order (i.e.: + * newest first). + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the device. For example, + * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or + * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. + * @param {number} request.numStates + * The number of states to list. States are listed in descending order of + * update time. The maximum number of states retained is 10. If this + * value is zero, it will return all the states available. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.iot.v1.ListDeviceStatesResponse|ListDeviceStatesResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/device_manager.list_device_states.js + * region_tag:cloudiot_v1_generated_DeviceManager_ListDeviceStates_async + */ listDeviceStates( - request?: protos.google.cloud.iot.v1.IListDeviceStatesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.iot.v1.IListDeviceStatesResponse, - protos.google.cloud.iot.v1.IListDeviceStatesRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.iot.v1.IListDeviceStatesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.iot.v1.IListDeviceStatesResponse, + protos.google.cloud.iot.v1.IListDeviceStatesRequest | undefined, + {} | undefined, + ] + >; listDeviceStates( - request: protos.google.cloud.iot.v1.IListDeviceStatesRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.iot.v1.IListDeviceStatesResponse, - protos.google.cloud.iot.v1.IListDeviceStatesRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.iot.v1.IListDeviceStatesRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.iot.v1.IListDeviceStatesResponse, + protos.google.cloud.iot.v1.IListDeviceStatesRequest | null | undefined, + {} | null | undefined + >, + ): void; listDeviceStates( - request: protos.google.cloud.iot.v1.IListDeviceStatesRequest, - callback: Callback< - protos.google.cloud.iot.v1.IListDeviceStatesResponse, - protos.google.cloud.iot.v1.IListDeviceStatesRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.iot.v1.IListDeviceStatesRequest, + callback: Callback< + protos.google.cloud.iot.v1.IListDeviceStatesResponse, + protos.google.cloud.iot.v1.IListDeviceStatesRequest | null | undefined, + {} | null | undefined + >, + ): void; listDeviceStates( - request?: protos.google.cloud.iot.v1.IListDeviceStatesRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.iot.v1.IListDeviceStatesRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.iot.v1.IListDeviceStatesResponse, - protos.google.cloud.iot.v1.IListDeviceStatesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.iot.v1.IListDeviceStatesResponse, - protos.google.cloud.iot.v1.IListDeviceStatesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.iot.v1.IListDeviceStatesResponse, - protos.google.cloud.iot.v1.IListDeviceStatesRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.iot.v1.IListDeviceStatesRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.iot.v1.IListDeviceStatesResponse, + protos.google.cloud.iot.v1.IListDeviceStatesRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.iot.v1.IListDeviceStatesResponse, + protos.google.cloud.iot.v1.IListDeviceStatesRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('listDeviceStates request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.iot.v1.IListDeviceStatesResponse, - protos.google.cloud.iot.v1.IListDeviceStatesRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.iot.v1.IListDeviceStatesResponse, + | protos.google.cloud.iot.v1.IListDeviceStatesRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('listDeviceStates response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.listDeviceStates(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.iot.v1.IListDeviceStatesResponse, - protos.google.cloud.iot.v1.IListDeviceStatesRequest|undefined, - {}|undefined - ]) => { - this._log.info('listDeviceStates response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .listDeviceStates(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.iot.v1.IListDeviceStatesResponse, + protos.google.cloud.iot.v1.IListDeviceStatesRequest | undefined, + {} | undefined, + ]) => { + this._log.info('listDeviceStates response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 on the specified resource. Replaces any - * existing policy. - * - * @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/device_manager.set_iam_policy.js - * region_tag:cloudiot_v1_generated_DeviceManager_SetIamPolicy_async - */ + /** + * Sets the access control policy on the specified resource. Replaces any + * existing policy. + * + * @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/device_manager.set_iam_policy.js + * region_tag:cloudiot_v1_generated_DeviceManager_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< + 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< - 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; }); } -/** - * Gets the access control policy for a resource. - * Returns an empty policy if the resource exists and does not have a policy - * set. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {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/device_manager.get_iam_policy.js - * region_tag:cloudiot_v1_generated_DeviceManager_GetIamPolicy_async - */ + /** + * Gets the access control policy for a resource. + * Returns an empty policy if the resource exists and does not have a policy + * set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {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/device_manager.get_iam_policy.js + * region_tag:cloudiot_v1_generated_DeviceManager_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< + 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< - 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; }); } -/** - * Returns permissions that a caller has on the specified resource. - * If the resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * @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/device_manager.test_iam_permissions.js - * region_tag:cloudiot_v1_generated_DeviceManager_TestIamPermissions_async - */ + /** + * Returns permissions that a caller has on the specified resource. + * If the resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * @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/device_manager.test_iam_permissions.js + * region_tag:cloudiot_v1_generated_DeviceManager_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; }); } -/** - * Sends a command to the specified device. In order for a device to be able - * to receive commands, it must: - * 1) be connected to Cloud IoT Core using the MQTT protocol, and - * 2) be subscribed to the group of MQTT topics specified by - * /devices/{device-id}/commands/#. This subscription will receive commands - * at the top-level topic /devices/{device-id}/commands as well as commands - * for subfolders, like /devices/{device-id}/commands/subfolder. - * Note that subscribing to specific subfolders is not supported. - * If the command could not be delivered to the device, this method will - * return an error; in particular, if the device is not subscribed, this - * method will return FAILED_PRECONDITION. Otherwise, this method will - * return OK. If the subscription is QoS 1, at least once delivery will be - * guaranteed; for QoS 0, no acknowledgment will be expected from the device. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the device. For example, - * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or - * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. - * @param {Buffer} request.binaryData - * Required. The command data to send to the device. - * @param {string} request.subfolder - * Optional subfolder for the command. If empty, the command will be delivered - * to the /devices/{device-id}/commands topic, otherwise it will be delivered - * to the /devices/{device-id}/commands/{subfolder} topic. Multi-level - * subfolders are allowed. This field must not have more than 256 characters, - * and must not contain any MQTT wildcards ("+" or "#") or null characters. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.iot.v1.SendCommandToDeviceResponse|SendCommandToDeviceResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/device_manager.send_command_to_device.js - * region_tag:cloudiot_v1_generated_DeviceManager_SendCommandToDevice_async - */ + /** + * Sends a command to the specified device. In order for a device to be able + * to receive commands, it must: + * 1) be connected to Cloud IoT Core using the MQTT protocol, and + * 2) be subscribed to the group of MQTT topics specified by + * /devices/{device-id}/commands/#. This subscription will receive commands + * at the top-level topic /devices/{device-id}/commands as well as commands + * for subfolders, like /devices/{device-id}/commands/subfolder. + * Note that subscribing to specific subfolders is not supported. + * If the command could not be delivered to the device, this method will + * return an error; in particular, if the device is not subscribed, this + * method will return FAILED_PRECONDITION. Otherwise, this method will + * return OK. If the subscription is QoS 1, at least once delivery will be + * guaranteed; for QoS 0, no acknowledgment will be expected from the device. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the device. For example, + * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or + * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. + * @param {Buffer} request.binaryData + * Required. The command data to send to the device. + * @param {string} request.subfolder + * Optional subfolder for the command. If empty, the command will be delivered + * to the /devices/{device-id}/commands topic, otherwise it will be delivered + * to the /devices/{device-id}/commands/{subfolder} topic. Multi-level + * subfolders are allowed. This field must not have more than 256 characters, + * and must not contain any MQTT wildcards ("+" or "#") or null characters. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.iot.v1.SendCommandToDeviceResponse|SendCommandToDeviceResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/device_manager.send_command_to_device.js + * region_tag:cloudiot_v1_generated_DeviceManager_SendCommandToDevice_async + */ sendCommandToDevice( - request?: protos.google.cloud.iot.v1.ISendCommandToDeviceRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.iot.v1.ISendCommandToDeviceResponse, - protos.google.cloud.iot.v1.ISendCommandToDeviceRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.iot.v1.ISendCommandToDeviceRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.iot.v1.ISendCommandToDeviceResponse, + protos.google.cloud.iot.v1.ISendCommandToDeviceRequest | undefined, + {} | undefined, + ] + >; sendCommandToDevice( - request: protos.google.cloud.iot.v1.ISendCommandToDeviceRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.iot.v1.ISendCommandToDeviceResponse, - protos.google.cloud.iot.v1.ISendCommandToDeviceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.iot.v1.ISendCommandToDeviceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.iot.v1.ISendCommandToDeviceResponse, + protos.google.cloud.iot.v1.ISendCommandToDeviceRequest | null | undefined, + {} | null | undefined + >, + ): void; sendCommandToDevice( - request: protos.google.cloud.iot.v1.ISendCommandToDeviceRequest, - callback: Callback< - protos.google.cloud.iot.v1.ISendCommandToDeviceResponse, - protos.google.cloud.iot.v1.ISendCommandToDeviceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.iot.v1.ISendCommandToDeviceRequest, + callback: Callback< + protos.google.cloud.iot.v1.ISendCommandToDeviceResponse, + protos.google.cloud.iot.v1.ISendCommandToDeviceRequest | null | undefined, + {} | null | undefined + >, + ): void; sendCommandToDevice( - request?: protos.google.cloud.iot.v1.ISendCommandToDeviceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.iot.v1.ISendCommandToDeviceResponse, - protos.google.cloud.iot.v1.ISendCommandToDeviceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.iot.v1.ISendCommandToDeviceRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.iot.v1.ISendCommandToDeviceResponse, - protos.google.cloud.iot.v1.ISendCommandToDeviceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.iot.v1.ISendCommandToDeviceResponse, - protos.google.cloud.iot.v1.ISendCommandToDeviceRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.iot.v1.ISendCommandToDeviceRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.iot.v1.ISendCommandToDeviceResponse, + protos.google.cloud.iot.v1.ISendCommandToDeviceRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.iot.v1.ISendCommandToDeviceResponse, + protos.google.cloud.iot.v1.ISendCommandToDeviceRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('sendCommandToDevice request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.iot.v1.ISendCommandToDeviceResponse, - protos.google.cloud.iot.v1.ISendCommandToDeviceRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.iot.v1.ISendCommandToDeviceResponse, + | protos.google.cloud.iot.v1.ISendCommandToDeviceRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('sendCommandToDevice response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.sendCommandToDevice(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.iot.v1.ISendCommandToDeviceResponse, - protos.google.cloud.iot.v1.ISendCommandToDeviceRequest|undefined, - {}|undefined - ]) => { - this._log.info('sendCommandToDevice response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .sendCommandToDevice(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.iot.v1.ISendCommandToDeviceResponse, + protos.google.cloud.iot.v1.ISendCommandToDeviceRequest | undefined, + {} | undefined, + ]) => { + this._log.info('sendCommandToDevice response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Associates the device with the gateway. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the registry. For example, - * `projects/example-project/locations/us-central1/registries/my-registry`. - * @param {string} request.gatewayId - * Required. The value of `gateway_id` can be either the device numeric ID or the - * user-defined device identifier. - * @param {string} request.deviceId - * Required. The device to associate with the specified gateway. The value of - * `device_id` can be either the device numeric ID or the user-defined device - * identifier. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.iot.v1.BindDeviceToGatewayResponse|BindDeviceToGatewayResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/device_manager.bind_device_to_gateway.js - * region_tag:cloudiot_v1_generated_DeviceManager_BindDeviceToGateway_async - */ + /** + * Associates the device with the gateway. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the registry. For example, + * `projects/example-project/locations/us-central1/registries/my-registry`. + * @param {string} request.gatewayId + * Required. The value of `gateway_id` can be either the device numeric ID or the + * user-defined device identifier. + * @param {string} request.deviceId + * Required. The device to associate with the specified gateway. The value of + * `device_id` can be either the device numeric ID or the user-defined device + * identifier. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.iot.v1.BindDeviceToGatewayResponse|BindDeviceToGatewayResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/device_manager.bind_device_to_gateway.js + * region_tag:cloudiot_v1_generated_DeviceManager_BindDeviceToGateway_async + */ bindDeviceToGateway( - request?: protos.google.cloud.iot.v1.IBindDeviceToGatewayRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.iot.v1.IBindDeviceToGatewayResponse, - protos.google.cloud.iot.v1.IBindDeviceToGatewayRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.iot.v1.IBindDeviceToGatewayRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.iot.v1.IBindDeviceToGatewayResponse, + protos.google.cloud.iot.v1.IBindDeviceToGatewayRequest | undefined, + {} | undefined, + ] + >; bindDeviceToGateway( - request: protos.google.cloud.iot.v1.IBindDeviceToGatewayRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.iot.v1.IBindDeviceToGatewayResponse, - protos.google.cloud.iot.v1.IBindDeviceToGatewayRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.iot.v1.IBindDeviceToGatewayRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.iot.v1.IBindDeviceToGatewayResponse, + protos.google.cloud.iot.v1.IBindDeviceToGatewayRequest | null | undefined, + {} | null | undefined + >, + ): void; bindDeviceToGateway( - request: protos.google.cloud.iot.v1.IBindDeviceToGatewayRequest, - callback: Callback< - protos.google.cloud.iot.v1.IBindDeviceToGatewayResponse, - protos.google.cloud.iot.v1.IBindDeviceToGatewayRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.iot.v1.IBindDeviceToGatewayRequest, + callback: Callback< + protos.google.cloud.iot.v1.IBindDeviceToGatewayResponse, + protos.google.cloud.iot.v1.IBindDeviceToGatewayRequest | null | undefined, + {} | null | undefined + >, + ): void; bindDeviceToGateway( - request?: protos.google.cloud.iot.v1.IBindDeviceToGatewayRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.iot.v1.IBindDeviceToGatewayResponse, - protos.google.cloud.iot.v1.IBindDeviceToGatewayRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.iot.v1.IBindDeviceToGatewayRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.iot.v1.IBindDeviceToGatewayResponse, - protos.google.cloud.iot.v1.IBindDeviceToGatewayRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.iot.v1.IBindDeviceToGatewayResponse, - protos.google.cloud.iot.v1.IBindDeviceToGatewayRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.iot.v1.IBindDeviceToGatewayRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.iot.v1.IBindDeviceToGatewayResponse, + protos.google.cloud.iot.v1.IBindDeviceToGatewayRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.iot.v1.IBindDeviceToGatewayResponse, + protos.google.cloud.iot.v1.IBindDeviceToGatewayRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.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('bindDeviceToGateway request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.iot.v1.IBindDeviceToGatewayResponse, - protos.google.cloud.iot.v1.IBindDeviceToGatewayRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.iot.v1.IBindDeviceToGatewayResponse, + | protos.google.cloud.iot.v1.IBindDeviceToGatewayRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('bindDeviceToGateway response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.bindDeviceToGateway(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.iot.v1.IBindDeviceToGatewayResponse, - protos.google.cloud.iot.v1.IBindDeviceToGatewayRequest|undefined, - {}|undefined - ]) => { - this._log.info('bindDeviceToGateway response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .bindDeviceToGateway(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.iot.v1.IBindDeviceToGatewayResponse, + protos.google.cloud.iot.v1.IBindDeviceToGatewayRequest | undefined, + {} | undefined, + ]) => { + this._log.info('bindDeviceToGateway response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 association between the device and the gateway. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the registry. For example, - * `projects/example-project/locations/us-central1/registries/my-registry`. - * @param {string} request.gatewayId - * Required. The value of `gateway_id` can be either the device numeric ID or the - * user-defined device identifier. - * @param {string} request.deviceId - * Required. The device to disassociate from the specified gateway. The value of - * `device_id` can be either the device numeric ID or the user-defined device - * identifier. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse|UnbindDeviceFromGatewayResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/device_manager.unbind_device_from_gateway.js - * region_tag:cloudiot_v1_generated_DeviceManager_UnbindDeviceFromGateway_async - */ + /** + * Deletes the association between the device and the gateway. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the registry. For example, + * `projects/example-project/locations/us-central1/registries/my-registry`. + * @param {string} request.gatewayId + * Required. The value of `gateway_id` can be either the device numeric ID or the + * user-defined device identifier. + * @param {string} request.deviceId + * Required. The device to disassociate from the specified gateway. The value of + * `device_id` can be either the device numeric ID or the user-defined device + * identifier. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse|UnbindDeviceFromGatewayResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/device_manager.unbind_device_from_gateway.js + * region_tag:cloudiot_v1_generated_DeviceManager_UnbindDeviceFromGateway_async + */ unbindDeviceFromGateway( - request?: protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayResponse, - protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayResponse, + protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayRequest | undefined, + {} | undefined, + ] + >; unbindDeviceFromGateway( - request: protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayResponse, - protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayResponse, + | protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayRequest + | null + | undefined, + {} | null | undefined + >, + ): void; unbindDeviceFromGateway( - request: protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayRequest, - callback: Callback< - protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayResponse, - protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayRequest, + callback: Callback< + protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayResponse, + | protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayRequest + | null + | undefined, + {} | null | undefined + >, + ): void; unbindDeviceFromGateway( - request?: protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayResponse, - protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayResponse, - protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayResponse, - protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayResponse, + | protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayResponse, + protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.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('unbindDeviceFromGateway request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayResponse, - protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayResponse, + | protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('unbindDeviceFromGateway response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.unbindDeviceFromGateway(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayResponse, - protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayRequest|undefined, - {}|undefined - ]) => { - this._log.info('unbindDeviceFromGateway response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .unbindDeviceFromGateway(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayResponse, + ( + | protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('unbindDeviceFromGateway response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 device registries. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and cloud region path. For example, - * `projects/example-project/locations/us-central1`. - * @param {number} request.pageSize - * The maximum number of registries to return in the response. If this value - * is zero, the service will select a default size. A call may return fewer - * objects than requested. A non-empty `next_page_token` in the response - * indicates that more data is available. - * @param {string} request.pageToken - * The value returned by the last `ListDeviceRegistriesResponse`; indicates - * that this is a continuation of a prior `ListDeviceRegistries` call and - * the system should return the next page of data. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link protos.google.cloud.iot.v1.DeviceRegistry|DeviceRegistry}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listDeviceRegistriesAsync()` - * method described below for async iteration which you can stop as 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 device registries. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and cloud region path. For example, + * `projects/example-project/locations/us-central1`. + * @param {number} request.pageSize + * The maximum number of registries to return in the response. If this value + * is zero, the service will select a default size. A call may return fewer + * objects than requested. A non-empty `next_page_token` in the response + * indicates that more data is available. + * @param {string} request.pageToken + * The value returned by the last `ListDeviceRegistriesResponse`; indicates + * that this is a continuation of a prior `ListDeviceRegistries` call and + * the system should return the next page of data. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.iot.v1.DeviceRegistry|DeviceRegistry}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listDeviceRegistriesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listDeviceRegistries( - request?: protos.google.cloud.iot.v1.IListDeviceRegistriesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.iot.v1.IDeviceRegistry[], - protos.google.cloud.iot.v1.IListDeviceRegistriesRequest|null, - protos.google.cloud.iot.v1.IListDeviceRegistriesResponse - ]>; + request?: protos.google.cloud.iot.v1.IListDeviceRegistriesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.iot.v1.IDeviceRegistry[], + protos.google.cloud.iot.v1.IListDeviceRegistriesRequest | null, + protos.google.cloud.iot.v1.IListDeviceRegistriesResponse, + ] + >; listDeviceRegistries( - request: protos.google.cloud.iot.v1.IListDeviceRegistriesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.iot.v1.IListDeviceRegistriesRequest, - protos.google.cloud.iot.v1.IListDeviceRegistriesResponse|null|undefined, - protos.google.cloud.iot.v1.IDeviceRegistry>): void; + request: protos.google.cloud.iot.v1.IListDeviceRegistriesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.iot.v1.IListDeviceRegistriesRequest, + | protos.google.cloud.iot.v1.IListDeviceRegistriesResponse + | null + | undefined, + protos.google.cloud.iot.v1.IDeviceRegistry + >, + ): void; listDeviceRegistries( - request: protos.google.cloud.iot.v1.IListDeviceRegistriesRequest, - callback: PaginationCallback< - protos.google.cloud.iot.v1.IListDeviceRegistriesRequest, - protos.google.cloud.iot.v1.IListDeviceRegistriesResponse|null|undefined, - protos.google.cloud.iot.v1.IDeviceRegistry>): void; + request: protos.google.cloud.iot.v1.IListDeviceRegistriesRequest, + callback: PaginationCallback< + protos.google.cloud.iot.v1.IListDeviceRegistriesRequest, + | protos.google.cloud.iot.v1.IListDeviceRegistriesResponse + | null + | undefined, + protos.google.cloud.iot.v1.IDeviceRegistry + >, + ): void; listDeviceRegistries( - request?: protos.google.cloud.iot.v1.IListDeviceRegistriesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.iot.v1.IListDeviceRegistriesRequest, - protos.google.cloud.iot.v1.IListDeviceRegistriesResponse|null|undefined, - protos.google.cloud.iot.v1.IDeviceRegistry>, - callback?: PaginationCallback< + request?: protos.google.cloud.iot.v1.IListDeviceRegistriesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.iot.v1.IListDeviceRegistriesRequest, - protos.google.cloud.iot.v1.IListDeviceRegistriesResponse|null|undefined, - protos.google.cloud.iot.v1.IDeviceRegistry>): - Promise<[ - protos.google.cloud.iot.v1.IDeviceRegistry[], - protos.google.cloud.iot.v1.IListDeviceRegistriesRequest|null, - protos.google.cloud.iot.v1.IListDeviceRegistriesResponse - ]>|void { + | protos.google.cloud.iot.v1.IListDeviceRegistriesResponse + | null + | undefined, + protos.google.cloud.iot.v1.IDeviceRegistry + >, + callback?: PaginationCallback< + protos.google.cloud.iot.v1.IListDeviceRegistriesRequest, + | protos.google.cloud.iot.v1.IListDeviceRegistriesResponse + | null + | undefined, + protos.google.cloud.iot.v1.IDeviceRegistry + >, + ): Promise< + [ + protos.google.cloud.iot.v1.IDeviceRegistry[], + protos.google.cloud.iot.v1.IListDeviceRegistriesRequest | null, + protos.google.cloud.iot.v1.IListDeviceRegistriesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-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.iot.v1.IListDeviceRegistriesRequest, - protos.google.cloud.iot.v1.IListDeviceRegistriesResponse|null|undefined, - protos.google.cloud.iot.v1.IDeviceRegistry>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.iot.v1.IListDeviceRegistriesRequest, + | protos.google.cloud.iot.v1.IListDeviceRegistriesResponse + | null + | undefined, + protos.google.cloud.iot.v1.IDeviceRegistry + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listDeviceRegistries values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -2167,220 +2857,239 @@ export class DeviceManagerClient { this._log.info('listDeviceRegistries request %j', request); return this.innerApiCalls .listDeviceRegistries(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.iot.v1.IDeviceRegistry[], - protos.google.cloud.iot.v1.IListDeviceRegistriesRequest|null, - protos.google.cloud.iot.v1.IListDeviceRegistriesResponse - ]) => { - this._log.info('listDeviceRegistries values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.iot.v1.IDeviceRegistry[], + protos.google.cloud.iot.v1.IListDeviceRegistriesRequest | null, + protos.google.cloud.iot.v1.IListDeviceRegistriesResponse, + ]) => { + this._log.info('listDeviceRegistries values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listDeviceRegistries`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and cloud region path. For example, - * `projects/example-project/locations/us-central1`. - * @param {number} request.pageSize - * The maximum number of registries to return in the response. If this value - * is zero, the service will select a default size. A call may return fewer - * objects than requested. A non-empty `next_page_token` in the response - * indicates that more data is available. - * @param {string} request.pageToken - * The value returned by the last `ListDeviceRegistriesResponse`; indicates - * that this is a continuation of a prior `ListDeviceRegistries` call and - * the system should return the next page of data. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.iot.v1.DeviceRegistry|DeviceRegistry} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listDeviceRegistriesAsync()` - * method described below for async iteration which you can stop as 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 `listDeviceRegistries`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and cloud region path. For example, + * `projects/example-project/locations/us-central1`. + * @param {number} request.pageSize + * The maximum number of registries to return in the response. If this value + * is zero, the service will select a default size. A call may return fewer + * objects than requested. A non-empty `next_page_token` in the response + * indicates that more data is available. + * @param {string} request.pageToken + * The value returned by the last `ListDeviceRegistriesResponse`; indicates + * that this is a continuation of a prior `ListDeviceRegistries` call and + * the system should return the next page of data. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.iot.v1.DeviceRegistry|DeviceRegistry} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listDeviceRegistriesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listDeviceRegistriesStream( - request?: protos.google.cloud.iot.v1.IListDeviceRegistriesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.iot.v1.IListDeviceRegistriesRequest, + 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['listDeviceRegistries']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listDeviceRegistries stream %j', request); return this.descriptors.page.listDeviceRegistries.createStream( this.innerApiCalls.listDeviceRegistries as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listDeviceRegistries`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used 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 cloud region path. For example, - * `projects/example-project/locations/us-central1`. - * @param {number} request.pageSize - * The maximum number of registries to return in the response. If this value - * is zero, the service will select a default size. A call may return fewer - * objects than requested. A non-empty `next_page_token` in the response - * indicates that more data is available. - * @param {string} request.pageToken - * The value returned by the last `ListDeviceRegistriesResponse`; indicates - * that this is a continuation of a prior `ListDeviceRegistries` call and - * the system should return the next page of data. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.iot.v1.DeviceRegistry|DeviceRegistry}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@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/device_manager.list_device_registries.js - * region_tag:cloudiot_v1_generated_DeviceManager_ListDeviceRegistries_async - */ + /** + * Equivalent to `listDeviceRegistries`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used 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 cloud region path. For example, + * `projects/example-project/locations/us-central1`. + * @param {number} request.pageSize + * The maximum number of registries to return in the response. If this value + * is zero, the service will select a default size. A call may return fewer + * objects than requested. A non-empty `next_page_token` in the response + * indicates that more data is available. + * @param {string} request.pageToken + * The value returned by the last `ListDeviceRegistriesResponse`; indicates + * that this is a continuation of a prior `ListDeviceRegistries` call and + * the system should return the next page of data. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.iot.v1.DeviceRegistry|DeviceRegistry}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@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/device_manager.list_device_registries.js + * region_tag:cloudiot_v1_generated_DeviceManager_ListDeviceRegistries_async + */ listDeviceRegistriesAsync( - request?: protos.google.cloud.iot.v1.IListDeviceRegistriesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.iot.v1.IListDeviceRegistriesRequest, + 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['listDeviceRegistries']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listDeviceRegistries iterate %j', request); return this.descriptors.page.listDeviceRegistries.asyncIterate( this.innerApiCalls['listDeviceRegistries'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * List devices in a device registry. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The device registry path. Required. For example, - * `projects/my-project/locations/us-central1/registries/my-registry`. - * @param {number[]} request.deviceNumIds - * A list of device numeric IDs. If empty, this field is ignored. Maximum - * IDs: 10,000. - * @param {string[]} request.deviceIds - * A list of device string IDs. For example, `['device0', 'device12']`. - * If empty, this field is ignored. Maximum IDs: 10,000 - * @param {google.protobuf.FieldMask} request.fieldMask - * The fields of the `Device` resource to be returned in the response. The - * fields `id` and `num_id` are always returned, along with any - * other fields specified in snake_case format, for example: - * `last_heartbeat_time`. - * @param {google.cloud.iot.v1.GatewayListOptions} request.gatewayListOptions - * Options related to gateways. - * @param {number} request.pageSize - * The maximum number of devices to return in the response. If this value - * is zero, the service will select a default size. A call may return fewer - * objects than requested. A non-empty `next_page_token` in the response - * indicates that more data is available. - * @param {string} request.pageToken - * The value returned by the last `ListDevicesResponse`; indicates - * that this is a continuation of a prior `ListDevices` call and - * the system should return the next page of data. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link protos.google.cloud.iot.v1.Device|Device}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listDevicesAsync()` - * method described below for async iteration which you can stop as 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 devices in a device registry. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The device registry path. Required. For example, + * `projects/my-project/locations/us-central1/registries/my-registry`. + * @param {number[]} request.deviceNumIds + * A list of device numeric IDs. If empty, this field is ignored. Maximum + * IDs: 10,000. + * @param {string[]} request.deviceIds + * A list of device string IDs. For example, `['device0', 'device12']`. + * If empty, this field is ignored. Maximum IDs: 10,000 + * @param {google.protobuf.FieldMask} request.fieldMask + * The fields of the `Device` resource to be returned in the response. The + * fields `id` and `num_id` are always returned, along with any + * other fields specified in snake_case format, for example: + * `last_heartbeat_time`. + * @param {google.cloud.iot.v1.GatewayListOptions} request.gatewayListOptions + * Options related to gateways. + * @param {number} request.pageSize + * The maximum number of devices to return in the response. If this value + * is zero, the service will select a default size. A call may return fewer + * objects than requested. A non-empty `next_page_token` in the response + * indicates that more data is available. + * @param {string} request.pageToken + * The value returned by the last `ListDevicesResponse`; indicates + * that this is a continuation of a prior `ListDevices` call and + * the system should return the next page of data. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.iot.v1.Device|Device}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listDevicesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listDevices( - request?: protos.google.cloud.iot.v1.IListDevicesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.iot.v1.IDevice[], - protos.google.cloud.iot.v1.IListDevicesRequest|null, - protos.google.cloud.iot.v1.IListDevicesResponse - ]>; + request?: protos.google.cloud.iot.v1.IListDevicesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.iot.v1.IDevice[], + protos.google.cloud.iot.v1.IListDevicesRequest | null, + protos.google.cloud.iot.v1.IListDevicesResponse, + ] + >; listDevices( - request: protos.google.cloud.iot.v1.IListDevicesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.iot.v1.IListDevicesRequest, - protos.google.cloud.iot.v1.IListDevicesResponse|null|undefined, - protos.google.cloud.iot.v1.IDevice>): void; + request: protos.google.cloud.iot.v1.IListDevicesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.iot.v1.IListDevicesRequest, + protos.google.cloud.iot.v1.IListDevicesResponse | null | undefined, + protos.google.cloud.iot.v1.IDevice + >, + ): void; listDevices( - request: protos.google.cloud.iot.v1.IListDevicesRequest, - callback: PaginationCallback< - protos.google.cloud.iot.v1.IListDevicesRequest, - protos.google.cloud.iot.v1.IListDevicesResponse|null|undefined, - protos.google.cloud.iot.v1.IDevice>): void; + request: protos.google.cloud.iot.v1.IListDevicesRequest, + callback: PaginationCallback< + protos.google.cloud.iot.v1.IListDevicesRequest, + protos.google.cloud.iot.v1.IListDevicesResponse | null | undefined, + protos.google.cloud.iot.v1.IDevice + >, + ): void; listDevices( - request?: protos.google.cloud.iot.v1.IListDevicesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.iot.v1.IListDevicesRequest, - protos.google.cloud.iot.v1.IListDevicesResponse|null|undefined, - protos.google.cloud.iot.v1.IDevice>, - callback?: PaginationCallback< + request?: protos.google.cloud.iot.v1.IListDevicesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.iot.v1.IListDevicesRequest, - protos.google.cloud.iot.v1.IListDevicesResponse|null|undefined, - protos.google.cloud.iot.v1.IDevice>): - Promise<[ - protos.google.cloud.iot.v1.IDevice[], - protos.google.cloud.iot.v1.IListDevicesRequest|null, - protos.google.cloud.iot.v1.IListDevicesResponse - ]>|void { + protos.google.cloud.iot.v1.IListDevicesResponse | null | undefined, + protos.google.cloud.iot.v1.IDevice + >, + callback?: PaginationCallback< + protos.google.cloud.iot.v1.IListDevicesRequest, + protos.google.cloud.iot.v1.IListDevicesResponse | null | undefined, + protos.google.cloud.iot.v1.IDevice + >, + ): Promise< + [ + protos.google.cloud.iot.v1.IDevice[], + protos.google.cloud.iot.v1.IListDevicesRequest | null, + protos.google.cloud.iot.v1.IListDevicesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-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.iot.v1.IListDevicesRequest, - protos.google.cloud.iot.v1.IListDevicesResponse|null|undefined, - protos.google.cloud.iot.v1.IDevice>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.iot.v1.IListDevicesRequest, + protos.google.cloud.iot.v1.IListDevicesResponse | null | undefined, + protos.google.cloud.iot.v1.IDevice + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listDevices values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -2389,144 +3098,148 @@ export class DeviceManagerClient { this._log.info('listDevices request %j', request); return this.innerApiCalls .listDevices(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.iot.v1.IDevice[], - protos.google.cloud.iot.v1.IListDevicesRequest|null, - protos.google.cloud.iot.v1.IListDevicesResponse - ]) => { - this._log.info('listDevices values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.iot.v1.IDevice[], + protos.google.cloud.iot.v1.IListDevicesRequest | null, + protos.google.cloud.iot.v1.IListDevicesResponse, + ]) => { + this._log.info('listDevices values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listDevices`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The device registry path. Required. For example, - * `projects/my-project/locations/us-central1/registries/my-registry`. - * @param {number[]} request.deviceNumIds - * A list of device numeric IDs. If empty, this field is ignored. Maximum - * IDs: 10,000. - * @param {string[]} request.deviceIds - * A list of device string IDs. For example, `['device0', 'device12']`. - * If empty, this field is ignored. Maximum IDs: 10,000 - * @param {google.protobuf.FieldMask} request.fieldMask - * The fields of the `Device` resource to be returned in the response. The - * fields `id` and `num_id` are always returned, along with any - * other fields specified in snake_case format, for example: - * `last_heartbeat_time`. - * @param {google.cloud.iot.v1.GatewayListOptions} request.gatewayListOptions - * Options related to gateways. - * @param {number} request.pageSize - * The maximum number of devices to return in the response. If this value - * is zero, the service will select a default size. A call may return fewer - * objects than requested. A non-empty `next_page_token` in the response - * indicates that more data is available. - * @param {string} request.pageToken - * The value returned by the last `ListDevicesResponse`; indicates - * that this is a continuation of a prior `ListDevices` call and - * the system should return the next page of data. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.iot.v1.Device|Device} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listDevicesAsync()` - * method described below for async iteration which you can stop as 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 `listDevices`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The device registry path. Required. For example, + * `projects/my-project/locations/us-central1/registries/my-registry`. + * @param {number[]} request.deviceNumIds + * A list of device numeric IDs. If empty, this field is ignored. Maximum + * IDs: 10,000. + * @param {string[]} request.deviceIds + * A list of device string IDs. For example, `['device0', 'device12']`. + * If empty, this field is ignored. Maximum IDs: 10,000 + * @param {google.protobuf.FieldMask} request.fieldMask + * The fields of the `Device` resource to be returned in the response. The + * fields `id` and `num_id` are always returned, along with any + * other fields specified in snake_case format, for example: + * `last_heartbeat_time`. + * @param {google.cloud.iot.v1.GatewayListOptions} request.gatewayListOptions + * Options related to gateways. + * @param {number} request.pageSize + * The maximum number of devices to return in the response. If this value + * is zero, the service will select a default size. A call may return fewer + * objects than requested. A non-empty `next_page_token` in the response + * indicates that more data is available. + * @param {string} request.pageToken + * The value returned by the last `ListDevicesResponse`; indicates + * that this is a continuation of a prior `ListDevices` call and + * the system should return the next page of data. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.iot.v1.Device|Device} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listDevicesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listDevicesStream( - request?: protos.google.cloud.iot.v1.IListDevicesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.iot.v1.IListDevicesRequest, + 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['listDevices']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listDevices stream %j', request); return this.descriptors.page.listDevices.createStream( this.innerApiCalls.listDevices as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listDevices`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used 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 device registry path. Required. For example, - * `projects/my-project/locations/us-central1/registries/my-registry`. - * @param {number[]} request.deviceNumIds - * A list of device numeric IDs. If empty, this field is ignored. Maximum - * IDs: 10,000. - * @param {string[]} request.deviceIds - * A list of device string IDs. For example, `['device0', 'device12']`. - * If empty, this field is ignored. Maximum IDs: 10,000 - * @param {google.protobuf.FieldMask} request.fieldMask - * The fields of the `Device` resource to be returned in the response. The - * fields `id` and `num_id` are always returned, along with any - * other fields specified in snake_case format, for example: - * `last_heartbeat_time`. - * @param {google.cloud.iot.v1.GatewayListOptions} request.gatewayListOptions - * Options related to gateways. - * @param {number} request.pageSize - * The maximum number of devices to return in the response. If this value - * is zero, the service will select a default size. A call may return fewer - * objects than requested. A non-empty `next_page_token` in the response - * indicates that more data is available. - * @param {string} request.pageToken - * The value returned by the last `ListDevicesResponse`; indicates - * that this is a continuation of a prior `ListDevices` call and - * the system should return the next page of data. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.iot.v1.Device|Device}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@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/device_manager.list_devices.js - * region_tag:cloudiot_v1_generated_DeviceManager_ListDevices_async - */ + /** + * Equivalent to `listDevices`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used 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 device registry path. Required. For example, + * `projects/my-project/locations/us-central1/registries/my-registry`. + * @param {number[]} request.deviceNumIds + * A list of device numeric IDs. If empty, this field is ignored. Maximum + * IDs: 10,000. + * @param {string[]} request.deviceIds + * A list of device string IDs. For example, `['device0', 'device12']`. + * If empty, this field is ignored. Maximum IDs: 10,000 + * @param {google.protobuf.FieldMask} request.fieldMask + * The fields of the `Device` resource to be returned in the response. The + * fields `id` and `num_id` are always returned, along with any + * other fields specified in snake_case format, for example: + * `last_heartbeat_time`. + * @param {google.cloud.iot.v1.GatewayListOptions} request.gatewayListOptions + * Options related to gateways. + * @param {number} request.pageSize + * The maximum number of devices to return in the response. If this value + * is zero, the service will select a default size. A call may return fewer + * objects than requested. A non-empty `next_page_token` in the response + * indicates that more data is available. + * @param {string} request.pageToken + * The value returned by the last `ListDevicesResponse`; indicates + * that this is a continuation of a prior `ListDevices` call and + * the system should return the next page of data. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.iot.v1.Device|Device}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@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/device_manager.list_devices.js + * region_tag:cloudiot_v1_generated_DeviceManager_ListDevices_async + */ listDevicesAsync( - request?: protos.google.cloud.iot.v1.IListDevicesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.iot.v1.IListDevicesRequest, + 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['listDevices']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listDevices iterate %j', request); return this.descriptors.page.listDevices.asyncIterate( this.innerApiCalls['listDevices'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } // -------------------- @@ -2542,7 +3255,12 @@ export class DeviceManagerClient { * @param {string} device * @returns {string} Resource name string. */ - devicePath(project:string,location:string,registry:string,device:string) { + devicePath( + project: string, + location: string, + registry: string, + device: string, + ) { return this.pathTemplates.devicePathTemplate.render({ project: project, location: location, @@ -2602,7 +3320,7 @@ export class DeviceManagerClient { * @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, @@ -2639,7 +3357,7 @@ export class DeviceManagerClient { * @param {string} registry * @returns {string} Resource name string. */ - registryPath(project:string,location:string,registry:string) { + registryPath(project: string, location: string, registry: string) { return this.pathTemplates.registryPathTemplate.render({ project: project, location: location, @@ -2688,7 +3406,7 @@ export class DeviceManagerClient { */ close(): Promise { if (this.deviceManagerStub && !this._terminated) { - return this.deviceManagerStub.then(stub => { + return this.deviceManagerStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); @@ -2696,4 +3414,4 @@ export class DeviceManagerClient { } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-iot/src/v1/index.ts b/packages/google-cloud-iot/src/v1/index.ts index 12546c95c6d0..02a3f0b2fa75 100644 --- a/packages/google-cloud-iot/src/v1/index.ts +++ b/packages/google-cloud-iot/src/v1/index.ts @@ -16,4 +16,4 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {DeviceManagerClient} from './device_manager_client'; +export { DeviceManagerClient } from './device_manager_client'; diff --git a/packages/google-cloud-iot/system-test/fixtures/sample/src/index.ts b/packages/google-cloud-iot/system-test/fixtures/sample/src/index.ts index 9d289084b40d..7e20cedc2df2 100644 --- a/packages/google-cloud-iot/system-test/fixtures/sample/src/index.ts +++ b/packages/google-cloud-iot/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 {DeviceManagerClient} from '@google-cloud/iot'; +import { DeviceManagerClient } from '@google-cloud/iot'; // check that the client class type name can be used function doStuffWithDeviceManagerClient(client: DeviceManagerClient) { diff --git a/packages/google-cloud-iot/system-test/install.ts b/packages/google-cloud-iot/system-test/install.ts index f66069aa3940..ccf167042d2e 100644 --- a/packages/google-cloud-iot/system-test/install.ts +++ b/packages/google-cloud-iot/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-iot/test/gapic_device_manager_v1.ts b/packages/google-cloud-iot/test/gapic_device_manager_v1.ts index d3f59251dfed..c3665036d93b 100644 --- a/packages/google-cloud-iot/test/gapic_device_manager_v1.ts +++ b/packages/google-cloud-iot/test/gapic_device_manager_v1.ts @@ -19,2718 +19,3369 @@ 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 devicemanagerModule 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.DeviceManagerClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new devicemanagerModule.v1.DeviceManagerClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'cloudiot.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new devicemanagerModule.v1.DeviceManagerClient(); - 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 = devicemanagerModule.v1.DeviceManagerClient.servicePath; - assert.strictEqual(servicePath, 'cloudiot.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = devicemanagerModule.v1.DeviceManagerClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'cloudiot.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudiot.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudiot.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 devicemanagerModule.v1.DeviceManagerClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudiot.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 devicemanagerModule.v1.DeviceManagerClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudiot.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 devicemanagerModule.v1.DeviceManagerClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); - - it('has port', () => { - const port = devicemanagerModule.v1.DeviceManagerClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new devicemanagerModule.v1.DeviceManagerClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.deviceManagerStub, undefined); - await client.initialize(); - assert(client.deviceManagerStub); - }); - - it('has close method for the initialized client', done => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.deviceManagerStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); - - it('has close method for the non-initialized client', done => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.deviceManagerStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new devicemanagerModule.v1.DeviceManagerClient({ - 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 devicemanagerModule.v1.DeviceManagerClient({ - 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 devicemanagerModule.v1.DeviceManagerClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'cloudiot.googleapis.com'); }); - describe('createDeviceRegistry', () => { - it('invokes createDeviceRegistry without error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.CreateDeviceRegistryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.CreateDeviceRegistryRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.iot.v1.DeviceRegistry() - ); - client.innerApiCalls.createDeviceRegistry = stubSimpleCall(expectedResponse); - const [response] = await client.createDeviceRegistry(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createDeviceRegistry as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDeviceRegistry as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createDeviceRegistry without error using callback', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.CreateDeviceRegistryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.CreateDeviceRegistryRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.iot.v1.DeviceRegistry() - ); - client.innerApiCalls.createDeviceRegistry = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createDeviceRegistry( - request, - (err?: Error|null, result?: protos.google.cloud.iot.v1.IDeviceRegistry|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createDeviceRegistry as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDeviceRegistry as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createDeviceRegistry with error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.CreateDeviceRegistryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.CreateDeviceRegistryRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createDeviceRegistry = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createDeviceRegistry(request), expectedError); - const actualRequest = (client.innerApiCalls.createDeviceRegistry as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDeviceRegistry as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createDeviceRegistry with closed client', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.CreateDeviceRegistryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.CreateDeviceRegistryRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.createDeviceRegistry(request), expectedError); - }); + it('has universeDomain', () => { + const client = new devicemanagerModule.v1.DeviceManagerClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); }); - describe('getDeviceRegistry', () => { - it('invokes getDeviceRegistry without error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.GetDeviceRegistryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.GetDeviceRegistryRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.iot.v1.DeviceRegistry() - ); - client.innerApiCalls.getDeviceRegistry = stubSimpleCall(expectedResponse); - const [response] = await client.getDeviceRegistry(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getDeviceRegistry as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDeviceRegistry as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getDeviceRegistry without error using callback', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.GetDeviceRegistryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.GetDeviceRegistryRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.iot.v1.DeviceRegistry() - ); - client.innerApiCalls.getDeviceRegistry = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getDeviceRegistry( - request, - (err?: Error|null, result?: protos.google.cloud.iot.v1.IDeviceRegistry|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getDeviceRegistry as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDeviceRegistry 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 = + devicemanagerModule.v1.DeviceManagerClient.servicePath; + assert.strictEqual(servicePath, 'cloudiot.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + devicemanagerModule.v1.DeviceManagerClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'cloudiot.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudiot.example.com'); + }); - it('invokes getDeviceRegistry with error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.GetDeviceRegistryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.GetDeviceRegistryRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getDeviceRegistry = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getDeviceRegistry(request), expectedError); - const actualRequest = (client.innerApiCalls.getDeviceRegistry as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDeviceRegistry 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 devicemanagerModule.v1.DeviceManagerClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudiot.example.com'); + }); - it('invokes getDeviceRegistry with closed client', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.GetDeviceRegistryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.GetDeviceRegistryRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getDeviceRegistry(request), expectedError); + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new devicemanagerModule.v1.DeviceManagerClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudiot.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 devicemanagerModule.v1.DeviceManagerClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudiot.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 devicemanagerModule.v1.DeviceManagerClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); }); - describe('updateDeviceRegistry', () => { - it('invokes updateDeviceRegistry without error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.UpdateDeviceRegistryRequest() - ); - request.deviceRegistry ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.UpdateDeviceRegistryRequest', ['deviceRegistry', 'name']); - request.deviceRegistry.name = defaultValue1; - const expectedHeaderRequestParams = `device_registry.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.iot.v1.DeviceRegistry() - ); - client.innerApiCalls.updateDeviceRegistry = stubSimpleCall(expectedResponse); - const [response] = await client.updateDeviceRegistry(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateDeviceRegistry as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateDeviceRegistry as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has port', () => { + const port = devicemanagerModule.v1.DeviceManagerClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('invokes updateDeviceRegistry without error using callback', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.UpdateDeviceRegistryRequest() - ); - request.deviceRegistry ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.UpdateDeviceRegistryRequest', ['deviceRegistry', 'name']); - request.deviceRegistry.name = defaultValue1; - const expectedHeaderRequestParams = `device_registry.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.iot.v1.DeviceRegistry() - ); - client.innerApiCalls.updateDeviceRegistry = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateDeviceRegistry( - request, - (err?: Error|null, result?: protos.google.cloud.iot.v1.IDeviceRegistry|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateDeviceRegistry as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateDeviceRegistry 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 devicemanagerModule.v1.DeviceManagerClient(); + assert(client); + }); - it('invokes updateDeviceRegistry with error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.UpdateDeviceRegistryRequest() - ); - request.deviceRegistry ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.UpdateDeviceRegistryRequest', ['deviceRegistry', 'name']); - request.deviceRegistry.name = defaultValue1; - const expectedHeaderRequestParams = `device_registry.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateDeviceRegistry = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateDeviceRegistry(request), expectedError); - const actualRequest = (client.innerApiCalls.updateDeviceRegistry as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateDeviceRegistry 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 devicemanagerModule.v1.DeviceManagerClient({ + fallback: true, + }); + assert(client); + }); - it('invokes updateDeviceRegistry with closed client', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.UpdateDeviceRegistryRequest() - ); - request.deviceRegistry ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.UpdateDeviceRegistryRequest', ['deviceRegistry', 'name']); - request.deviceRegistry.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.updateDeviceRegistry(request), expectedError); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.deviceManagerStub, undefined); + await client.initialize(); + assert(client.deviceManagerStub); }); - describe('deleteDeviceRegistry', () => { - it('invokes deleteDeviceRegistry without error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.DeleteDeviceRegistryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.DeleteDeviceRegistryRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteDeviceRegistry = stubSimpleCall(expectedResponse); - const [response] = await client.deleteDeviceRegistry(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteDeviceRegistry as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteDeviceRegistry 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 devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.deviceManagerStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes deleteDeviceRegistry without error using callback', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.DeleteDeviceRegistryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.DeleteDeviceRegistryRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteDeviceRegistry = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteDeviceRegistry( - 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.deleteDeviceRegistry as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteDeviceRegistry 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 devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.deviceManagerStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes deleteDeviceRegistry with error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.DeleteDeviceRegistryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.DeleteDeviceRegistryRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteDeviceRegistry = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteDeviceRegistry(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteDeviceRegistry as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteDeviceRegistry 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 devicemanagerModule.v1.DeviceManagerClient({ + 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 deleteDeviceRegistry with closed client', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.DeleteDeviceRegistryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.DeleteDeviceRegistryRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.deleteDeviceRegistry(request), expectedError); - }); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new devicemanagerModule.v1.DeviceManagerClient({ + 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('createDeviceRegistry', () => { + it('invokes createDeviceRegistry without error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.CreateDeviceRegistryRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.CreateDeviceRegistryRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.iot.v1.DeviceRegistry(), + ); + client.innerApiCalls.createDeviceRegistry = + stubSimpleCall(expectedResponse); + const [response] = await client.createDeviceRegistry(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createDeviceRegistry as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createDeviceRegistry as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createDevice', () => { - it('invokes createDevice without error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.CreateDeviceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.CreateDeviceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.iot.v1.Device() - ); - client.innerApiCalls.createDevice = stubSimpleCall(expectedResponse); - const [response] = await client.createDevice(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createDevice as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDevice as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createDeviceRegistry without error using callback', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.CreateDeviceRegistryRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.CreateDeviceRegistryRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.iot.v1.DeviceRegistry(), + ); + client.innerApiCalls.createDeviceRegistry = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createDeviceRegistry( + request, + ( + err?: Error | null, + result?: protos.google.cloud.iot.v1.IDeviceRegistry | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createDeviceRegistry as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createDeviceRegistry as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createDevice without error using callback', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.CreateDeviceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.CreateDeviceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.iot.v1.Device() - ); - client.innerApiCalls.createDevice = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createDevice( - request, - (err?: Error|null, result?: protos.google.cloud.iot.v1.IDevice|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createDevice as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDevice as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createDeviceRegistry with error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.CreateDeviceRegistryRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.CreateDeviceRegistryRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createDeviceRegistry = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.createDeviceRegistry(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createDeviceRegistry as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createDeviceRegistry as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createDevice with error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.CreateDeviceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.CreateDeviceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createDevice = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createDevice(request), expectedError); - const actualRequest = (client.innerApiCalls.createDevice as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDevice as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createDeviceRegistry with closed client', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.CreateDeviceRegistryRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.CreateDeviceRegistryRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.createDeviceRegistry(request), expectedError); + }); + }); + + describe('getDeviceRegistry', () => { + it('invokes getDeviceRegistry without error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.GetDeviceRegistryRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.GetDeviceRegistryRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.iot.v1.DeviceRegistry(), + ); + client.innerApiCalls.getDeviceRegistry = stubSimpleCall(expectedResponse); + const [response] = await client.getDeviceRegistry(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getDeviceRegistry as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDeviceRegistry as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createDevice with closed client', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.CreateDeviceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.CreateDeviceRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.createDevice(request), expectedError); - }); + it('invokes getDeviceRegistry without error using callback', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.GetDeviceRegistryRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.GetDeviceRegistryRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.iot.v1.DeviceRegistry(), + ); + client.innerApiCalls.getDeviceRegistry = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getDeviceRegistry( + request, + ( + err?: Error | null, + result?: protos.google.cloud.iot.v1.IDeviceRegistry | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getDeviceRegistry as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDeviceRegistry as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getDevice', () => { - it('invokes getDevice without error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.GetDeviceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.GetDeviceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.iot.v1.Device() - ); - client.innerApiCalls.getDevice = stubSimpleCall(expectedResponse); - const [response] = await client.getDevice(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getDevice as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDevice as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getDeviceRegistry with error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.GetDeviceRegistryRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.GetDeviceRegistryRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getDeviceRegistry = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getDeviceRegistry(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getDeviceRegistry as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDeviceRegistry as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getDevice without error using callback', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.GetDeviceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.GetDeviceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.iot.v1.Device() - ); - client.innerApiCalls.getDevice = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getDevice( - request, - (err?: Error|null, result?: protos.google.cloud.iot.v1.IDevice|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getDevice as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDevice as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getDeviceRegistry with closed client', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.GetDeviceRegistryRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.GetDeviceRegistryRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getDeviceRegistry(request), expectedError); + }); + }); + + describe('updateDeviceRegistry', () => { + it('invokes updateDeviceRegistry without error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.UpdateDeviceRegistryRequest(), + ); + request.deviceRegistry ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.UpdateDeviceRegistryRequest', + ['deviceRegistry', 'name'], + ); + request.deviceRegistry.name = defaultValue1; + const expectedHeaderRequestParams = `device_registry.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.iot.v1.DeviceRegistry(), + ); + client.innerApiCalls.updateDeviceRegistry = + stubSimpleCall(expectedResponse); + const [response] = await client.updateDeviceRegistry(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateDeviceRegistry as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateDeviceRegistry as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getDevice with error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.GetDeviceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.GetDeviceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getDevice = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getDevice(request), expectedError); - const actualRequest = (client.innerApiCalls.getDevice as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDevice as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateDeviceRegistry without error using callback', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.UpdateDeviceRegistryRequest(), + ); + request.deviceRegistry ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.UpdateDeviceRegistryRequest', + ['deviceRegistry', 'name'], + ); + request.deviceRegistry.name = defaultValue1; + const expectedHeaderRequestParams = `device_registry.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.iot.v1.DeviceRegistry(), + ); + client.innerApiCalls.updateDeviceRegistry = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateDeviceRegistry( + request, + ( + err?: Error | null, + result?: protos.google.cloud.iot.v1.IDeviceRegistry | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateDeviceRegistry as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateDeviceRegistry as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getDevice with closed client', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.GetDeviceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.GetDeviceRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getDevice(request), expectedError); - }); + it('invokes updateDeviceRegistry with error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.UpdateDeviceRegistryRequest(), + ); + request.deviceRegistry ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.UpdateDeviceRegistryRequest', + ['deviceRegistry', 'name'], + ); + request.deviceRegistry.name = defaultValue1; + const expectedHeaderRequestParams = `device_registry.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateDeviceRegistry = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateDeviceRegistry(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateDeviceRegistry as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateDeviceRegistry as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateDevice', () => { - it('invokes updateDevice without error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.UpdateDeviceRequest() - ); - request.device ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.UpdateDeviceRequest', ['device', 'name']); - request.device.name = defaultValue1; - const expectedHeaderRequestParams = `device.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.iot.v1.Device() - ); - client.innerApiCalls.updateDevice = stubSimpleCall(expectedResponse); - const [response] = await client.updateDevice(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateDevice as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateDevice as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateDeviceRegistry with closed client', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.UpdateDeviceRegistryRequest(), + ); + request.deviceRegistry ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.UpdateDeviceRegistryRequest', + ['deviceRegistry', 'name'], + ); + request.deviceRegistry.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.updateDeviceRegistry(request), expectedError); + }); + }); + + describe('deleteDeviceRegistry', () => { + it('invokes deleteDeviceRegistry without error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.DeleteDeviceRegistryRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.DeleteDeviceRegistryRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteDeviceRegistry = + stubSimpleCall(expectedResponse); + const [response] = await client.deleteDeviceRegistry(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteDeviceRegistry as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteDeviceRegistry as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateDevice without error using callback', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.UpdateDeviceRequest() - ); - request.device ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.UpdateDeviceRequest', ['device', 'name']); - request.device.name = defaultValue1; - const expectedHeaderRequestParams = `device.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.iot.v1.Device() - ); - client.innerApiCalls.updateDevice = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateDevice( - request, - (err?: Error|null, result?: protos.google.cloud.iot.v1.IDevice|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateDevice as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateDevice as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteDeviceRegistry without error using callback', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.DeleteDeviceRegistryRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.DeleteDeviceRegistryRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteDeviceRegistry = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteDeviceRegistry( + 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.deleteDeviceRegistry as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteDeviceRegistry as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateDevice with error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.UpdateDeviceRequest() - ); - request.device ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.UpdateDeviceRequest', ['device', 'name']); - request.device.name = defaultValue1; - const expectedHeaderRequestParams = `device.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateDevice = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateDevice(request), expectedError); - const actualRequest = (client.innerApiCalls.updateDevice as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateDevice as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteDeviceRegistry with error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.DeleteDeviceRegistryRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.DeleteDeviceRegistryRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteDeviceRegistry = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteDeviceRegistry(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteDeviceRegistry as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteDeviceRegistry as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateDevice with closed client', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.UpdateDeviceRequest() - ); - request.device ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.UpdateDeviceRequest', ['device', 'name']); - request.device.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.updateDevice(request), expectedError); - }); + it('invokes deleteDeviceRegistry with closed client', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.DeleteDeviceRegistryRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.DeleteDeviceRegistryRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.deleteDeviceRegistry(request), expectedError); + }); + }); + + describe('createDevice', () => { + it('invokes createDevice without error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.CreateDeviceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.CreateDeviceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.iot.v1.Device(), + ); + client.innerApiCalls.createDevice = stubSimpleCall(expectedResponse); + const [response] = await client.createDevice(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createDevice as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createDevice as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteDevice', () => { - it('invokes deleteDevice without error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.DeleteDeviceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.DeleteDeviceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteDevice = stubSimpleCall(expectedResponse); - const [response] = await client.deleteDevice(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteDevice as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteDevice as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createDevice without error using callback', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.CreateDeviceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.CreateDeviceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.iot.v1.Device(), + ); + client.innerApiCalls.createDevice = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createDevice( + request, + ( + err?: Error | null, + result?: protos.google.cloud.iot.v1.IDevice | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createDevice as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createDevice as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteDevice without error using callback', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.DeleteDeviceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.DeleteDeviceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteDevice = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteDevice( - 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.deleteDevice as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteDevice as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createDevice with error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.CreateDeviceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.CreateDeviceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createDevice = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.createDevice(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createDevice as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createDevice as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteDevice with error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.DeleteDeviceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.DeleteDeviceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteDevice = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteDevice(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteDevice as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteDevice as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createDevice with closed client', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.CreateDeviceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.CreateDeviceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.createDevice(request), expectedError); + }); + }); + + describe('getDevice', () => { + it('invokes getDevice without error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.GetDeviceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.GetDeviceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.iot.v1.Device(), + ); + client.innerApiCalls.getDevice = stubSimpleCall(expectedResponse); + const [response] = await client.getDevice(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getDevice as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDevice as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteDevice with closed client', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.DeleteDeviceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.DeleteDeviceRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.deleteDevice(request), expectedError); - }); + it('invokes getDevice without error using callback', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.GetDeviceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.GetDeviceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.iot.v1.Device(), + ); + client.innerApiCalls.getDevice = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getDevice( + request, + ( + err?: Error | null, + result?: protos.google.cloud.iot.v1.IDevice | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getDevice as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDevice as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('modifyCloudToDeviceConfig', () => { - it('invokes modifyCloudToDeviceConfig without error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.iot.v1.DeviceConfig() - ); - client.innerApiCalls.modifyCloudToDeviceConfig = stubSimpleCall(expectedResponse); - const [response] = await client.modifyCloudToDeviceConfig(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.modifyCloudToDeviceConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.modifyCloudToDeviceConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getDevice with error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.GetDeviceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.GetDeviceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getDevice = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getDevice(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getDevice as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDevice as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes modifyCloudToDeviceConfig without error using callback', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.iot.v1.DeviceConfig() - ); - client.innerApiCalls.modifyCloudToDeviceConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.modifyCloudToDeviceConfig( - request, - (err?: Error|null, result?: protos.google.cloud.iot.v1.IDeviceConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.modifyCloudToDeviceConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.modifyCloudToDeviceConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getDevice with closed client', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.GetDeviceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.GetDeviceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getDevice(request), expectedError); + }); + }); + + describe('updateDevice', () => { + it('invokes updateDevice without error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.UpdateDeviceRequest(), + ); + request.device ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.UpdateDeviceRequest', + ['device', 'name'], + ); + request.device.name = defaultValue1; + const expectedHeaderRequestParams = `device.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.iot.v1.Device(), + ); + client.innerApiCalls.updateDevice = stubSimpleCall(expectedResponse); + const [response] = await client.updateDevice(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateDevice as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateDevice as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes modifyCloudToDeviceConfig with error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.modifyCloudToDeviceConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.modifyCloudToDeviceConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.modifyCloudToDeviceConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.modifyCloudToDeviceConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateDevice without error using callback', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.UpdateDeviceRequest(), + ); + request.device ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.UpdateDeviceRequest', + ['device', 'name'], + ); + request.device.name = defaultValue1; + const expectedHeaderRequestParams = `device.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.iot.v1.Device(), + ); + client.innerApiCalls.updateDevice = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateDevice( + request, + ( + err?: Error | null, + result?: protos.google.cloud.iot.v1.IDevice | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateDevice as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateDevice as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes modifyCloudToDeviceConfig with closed client', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.modifyCloudToDeviceConfig(request), expectedError); - }); + it('invokes updateDevice with error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.UpdateDeviceRequest(), + ); + request.device ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.UpdateDeviceRequest', + ['device', 'name'], + ); + request.device.name = defaultValue1; + const expectedHeaderRequestParams = `device.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateDevice = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateDevice(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateDevice as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateDevice as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listDeviceConfigVersions', () => { - it('invokes listDeviceConfigVersions without error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.ListDeviceConfigVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.ListDeviceConfigVersionsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.iot.v1.ListDeviceConfigVersionsResponse() - ); - client.innerApiCalls.listDeviceConfigVersions = stubSimpleCall(expectedResponse); - const [response] = await client.listDeviceConfigVersions(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listDeviceConfigVersions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDeviceConfigVersions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateDevice with closed client', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.UpdateDeviceRequest(), + ); + request.device ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.UpdateDeviceRequest', + ['device', 'name'], + ); + request.device.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.updateDevice(request), expectedError); + }); + }); + + describe('deleteDevice', () => { + it('invokes deleteDevice without error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.DeleteDeviceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.DeleteDeviceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteDevice = stubSimpleCall(expectedResponse); + const [response] = await client.deleteDevice(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteDevice as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteDevice as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listDeviceConfigVersions without error using callback', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.ListDeviceConfigVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.ListDeviceConfigVersionsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.iot.v1.ListDeviceConfigVersionsResponse() - ); - client.innerApiCalls.listDeviceConfigVersions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listDeviceConfigVersions( - request, - (err?: Error|null, result?: protos.google.cloud.iot.v1.IListDeviceConfigVersionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listDeviceConfigVersions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDeviceConfigVersions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteDevice without error using callback', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.DeleteDeviceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.DeleteDeviceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteDevice = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteDevice( + 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.deleteDevice as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteDevice as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listDeviceConfigVersions with error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.ListDeviceConfigVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.ListDeviceConfigVersionsRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listDeviceConfigVersions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listDeviceConfigVersions(request), expectedError); - const actualRequest = (client.innerApiCalls.listDeviceConfigVersions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDeviceConfigVersions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteDevice with error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.DeleteDeviceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.DeleteDeviceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteDevice = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteDevice(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteDevice as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteDevice as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listDeviceConfigVersions with closed client', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.ListDeviceConfigVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.ListDeviceConfigVersionsRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.listDeviceConfigVersions(request), expectedError); - }); + it('invokes deleteDevice with closed client', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.DeleteDeviceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.DeleteDeviceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.deleteDevice(request), expectedError); + }); + }); + + describe('modifyCloudToDeviceConfig', () => { + it('invokes modifyCloudToDeviceConfig without error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.iot.v1.DeviceConfig(), + ); + client.innerApiCalls.modifyCloudToDeviceConfig = + stubSimpleCall(expectedResponse); + const [response] = await client.modifyCloudToDeviceConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.modifyCloudToDeviceConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.modifyCloudToDeviceConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listDeviceStates', () => { - it('invokes listDeviceStates without error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.ListDeviceStatesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.ListDeviceStatesRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.iot.v1.ListDeviceStatesResponse() - ); - client.innerApiCalls.listDeviceStates = stubSimpleCall(expectedResponse); - const [response] = await client.listDeviceStates(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listDeviceStates as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDeviceStates as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes modifyCloudToDeviceConfig without error using callback', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.iot.v1.DeviceConfig(), + ); + client.innerApiCalls.modifyCloudToDeviceConfig = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.modifyCloudToDeviceConfig( + request, + ( + err?: Error | null, + result?: protos.google.cloud.iot.v1.IDeviceConfig | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.modifyCloudToDeviceConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.modifyCloudToDeviceConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listDeviceStates without error using callback', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.ListDeviceStatesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.ListDeviceStatesRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.iot.v1.ListDeviceStatesResponse() - ); - client.innerApiCalls.listDeviceStates = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listDeviceStates( - request, - (err?: Error|null, result?: protos.google.cloud.iot.v1.IListDeviceStatesResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listDeviceStates as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDeviceStates as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes modifyCloudToDeviceConfig with error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.modifyCloudToDeviceConfig = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.modifyCloudToDeviceConfig(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.modifyCloudToDeviceConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.modifyCloudToDeviceConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listDeviceStates with error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.ListDeviceStatesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.ListDeviceStatesRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listDeviceStates = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listDeviceStates(request), expectedError); - const actualRequest = (client.innerApiCalls.listDeviceStates as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDeviceStates as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes modifyCloudToDeviceConfig with closed client', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.modifyCloudToDeviceConfig(request), + expectedError, + ); + }); + }); + + describe('listDeviceConfigVersions', () => { + it('invokes listDeviceConfigVersions without error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.ListDeviceConfigVersionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.ListDeviceConfigVersionsRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.iot.v1.ListDeviceConfigVersionsResponse(), + ); + client.innerApiCalls.listDeviceConfigVersions = + stubSimpleCall(expectedResponse); + const [response] = await client.listDeviceConfigVersions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listDeviceConfigVersions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDeviceConfigVersions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listDeviceStates with closed client', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.ListDeviceStatesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.ListDeviceStatesRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.listDeviceStates(request), expectedError); - }); + it('invokes listDeviceConfigVersions without error using callback', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.ListDeviceConfigVersionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.ListDeviceConfigVersionsRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.iot.v1.ListDeviceConfigVersionsResponse(), + ); + client.innerApiCalls.listDeviceConfigVersions = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listDeviceConfigVersions( + request, + ( + err?: Error | null, + result?: protos.google.cloud.iot.v1.IListDeviceConfigVersionsResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listDeviceConfigVersions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDeviceConfigVersions 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 devicemanagerModule.v1.DeviceManagerClient({ - 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 listDeviceConfigVersions with error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.ListDeviceConfigVersionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.ListDeviceConfigVersionsRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listDeviceConfigVersions = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.listDeviceConfigVersions(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.listDeviceConfigVersions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDeviceConfigVersions 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 devicemanagerModule.v1.DeviceManagerClient({ - 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 listDeviceConfigVersions with closed client', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.ListDeviceConfigVersionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.ListDeviceConfigVersionsRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.listDeviceConfigVersions(request), + expectedError, + ); + }); + }); + + describe('listDeviceStates', () => { + it('invokes listDeviceStates without error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.ListDeviceStatesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.ListDeviceStatesRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.iot.v1.ListDeviceStatesResponse(), + ); + client.innerApiCalls.listDeviceStates = stubSimpleCall(expectedResponse); + const [response] = await client.listDeviceStates(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listDeviceStates as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDeviceStates 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 devicemanagerModule.v1.DeviceManagerClient({ - 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 listDeviceStates without error using callback', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.ListDeviceStatesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.ListDeviceStatesRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.iot.v1.ListDeviceStatesResponse(), + ); + client.innerApiCalls.listDeviceStates = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listDeviceStates( + request, + ( + err?: Error | null, + result?: protos.google.cloud.iot.v1.IListDeviceStatesResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listDeviceStates as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDeviceStates 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 devicemanagerModule.v1.DeviceManagerClient({ - 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 listDeviceStates with error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.ListDeviceStatesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.ListDeviceStatesRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listDeviceStates = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listDeviceStates(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listDeviceStates as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDeviceStates 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 devicemanagerModule.v1.DeviceManagerClient({ - 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 listDeviceStates with closed client', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.ListDeviceStatesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.ListDeviceStatesRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.listDeviceStates(request), expectedError); + }); + }); + + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + 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 without error using callback', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - 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 without error using callback', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + 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 getIamPolicy with error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - 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 setIamPolicy with error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + 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 with closed client', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - 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 setIamPolicy with closed client', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + 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('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + 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)); }); - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - 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 without error using callback', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + 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 without error using callback', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - 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 getIamPolicy with error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + 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 testIamPermissions with error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - 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 with closed client', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + 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('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + 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 with closed client', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - 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 testIamPermissions without error using callback', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + 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)); }); - describe('sendCommandToDevice', () => { - it('invokes sendCommandToDevice without error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.SendCommandToDeviceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.SendCommandToDeviceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.iot.v1.SendCommandToDeviceResponse() - ); - client.innerApiCalls.sendCommandToDevice = stubSimpleCall(expectedResponse); - const [response] = await client.sendCommandToDevice(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.sendCommandToDevice as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.sendCommandToDevice 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 devicemanagerModule.v1.DeviceManagerClient({ + 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 sendCommandToDevice without error using callback', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.SendCommandToDeviceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.SendCommandToDeviceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.iot.v1.SendCommandToDeviceResponse() - ); - client.innerApiCalls.sendCommandToDevice = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.sendCommandToDevice( - request, - (err?: Error|null, result?: protos.google.cloud.iot.v1.ISendCommandToDeviceResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.sendCommandToDevice as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.sendCommandToDevice 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 devicemanagerModule.v1.DeviceManagerClient({ + 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('sendCommandToDevice', () => { + it('invokes sendCommandToDevice without error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.SendCommandToDeviceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.SendCommandToDeviceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.iot.v1.SendCommandToDeviceResponse(), + ); + client.innerApiCalls.sendCommandToDevice = + stubSimpleCall(expectedResponse); + const [response] = await client.sendCommandToDevice(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.sendCommandToDevice as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.sendCommandToDevice as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes sendCommandToDevice with error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.SendCommandToDeviceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.SendCommandToDeviceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.sendCommandToDevice = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.sendCommandToDevice(request), expectedError); - const actualRequest = (client.innerApiCalls.sendCommandToDevice as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.sendCommandToDevice as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes sendCommandToDevice without error using callback', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.SendCommandToDeviceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.SendCommandToDeviceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.iot.v1.SendCommandToDeviceResponse(), + ); + client.innerApiCalls.sendCommandToDevice = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.sendCommandToDevice( + request, + ( + err?: Error | null, + result?: protos.google.cloud.iot.v1.ISendCommandToDeviceResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.sendCommandToDevice as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.sendCommandToDevice as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes sendCommandToDevice with closed client', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.SendCommandToDeviceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.SendCommandToDeviceRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.sendCommandToDevice(request), expectedError); - }); + it('invokes sendCommandToDevice with error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.SendCommandToDeviceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.SendCommandToDeviceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.sendCommandToDevice = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.sendCommandToDevice(request), expectedError); + const actualRequest = ( + client.innerApiCalls.sendCommandToDevice as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.sendCommandToDevice as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('bindDeviceToGateway', () => { - it('invokes bindDeviceToGateway without error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.BindDeviceToGatewayRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.BindDeviceToGatewayRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.iot.v1.BindDeviceToGatewayResponse() - ); - client.innerApiCalls.bindDeviceToGateway = stubSimpleCall(expectedResponse); - const [response] = await client.bindDeviceToGateway(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.bindDeviceToGateway as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.bindDeviceToGateway as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes sendCommandToDevice with closed client', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.SendCommandToDeviceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.SendCommandToDeviceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.sendCommandToDevice(request), expectedError); + }); + }); + + describe('bindDeviceToGateway', () => { + it('invokes bindDeviceToGateway without error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.BindDeviceToGatewayRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.BindDeviceToGatewayRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.iot.v1.BindDeviceToGatewayResponse(), + ); + client.innerApiCalls.bindDeviceToGateway = + stubSimpleCall(expectedResponse); + const [response] = await client.bindDeviceToGateway(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.bindDeviceToGateway as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.bindDeviceToGateway as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes bindDeviceToGateway without error using callback', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.BindDeviceToGatewayRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.BindDeviceToGatewayRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.iot.v1.BindDeviceToGatewayResponse() - ); - client.innerApiCalls.bindDeviceToGateway = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.bindDeviceToGateway( - request, - (err?: Error|null, result?: protos.google.cloud.iot.v1.IBindDeviceToGatewayResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.bindDeviceToGateway as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.bindDeviceToGateway as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes bindDeviceToGateway without error using callback', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.BindDeviceToGatewayRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.BindDeviceToGatewayRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.iot.v1.BindDeviceToGatewayResponse(), + ); + client.innerApiCalls.bindDeviceToGateway = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.bindDeviceToGateway( + request, + ( + err?: Error | null, + result?: protos.google.cloud.iot.v1.IBindDeviceToGatewayResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.bindDeviceToGateway as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.bindDeviceToGateway as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes bindDeviceToGateway with error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.BindDeviceToGatewayRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.BindDeviceToGatewayRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.bindDeviceToGateway = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.bindDeviceToGateway(request), expectedError); - const actualRequest = (client.innerApiCalls.bindDeviceToGateway as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.bindDeviceToGateway as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes bindDeviceToGateway with error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.BindDeviceToGatewayRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.BindDeviceToGatewayRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.bindDeviceToGateway = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.bindDeviceToGateway(request), expectedError); + const actualRequest = ( + client.innerApiCalls.bindDeviceToGateway as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.bindDeviceToGateway as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes bindDeviceToGateway with closed client', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.BindDeviceToGatewayRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.BindDeviceToGatewayRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.bindDeviceToGateway(request), expectedError); - }); + it('invokes bindDeviceToGateway with closed client', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.BindDeviceToGatewayRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.BindDeviceToGatewayRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.bindDeviceToGateway(request), expectedError); + }); + }); + + describe('unbindDeviceFromGateway', () => { + it('invokes unbindDeviceFromGateway without error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse(), + ); + client.innerApiCalls.unbindDeviceFromGateway = + stubSimpleCall(expectedResponse); + const [response] = await client.unbindDeviceFromGateway(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.unbindDeviceFromGateway as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.unbindDeviceFromGateway as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('unbindDeviceFromGateway', () => { - it('invokes unbindDeviceFromGateway without error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse() - ); - client.innerApiCalls.unbindDeviceFromGateway = stubSimpleCall(expectedResponse); - const [response] = await client.unbindDeviceFromGateway(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.unbindDeviceFromGateway as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.unbindDeviceFromGateway as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes unbindDeviceFromGateway without error using callback', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse(), + ); + client.innerApiCalls.unbindDeviceFromGateway = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.unbindDeviceFromGateway( + request, + ( + err?: Error | null, + result?: protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.unbindDeviceFromGateway as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.unbindDeviceFromGateway as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes unbindDeviceFromGateway without error using callback', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse() - ); - client.innerApiCalls.unbindDeviceFromGateway = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.unbindDeviceFromGateway( - request, - (err?: Error|null, result?: protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.unbindDeviceFromGateway as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.unbindDeviceFromGateway as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes unbindDeviceFromGateway with error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.unbindDeviceFromGateway = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.unbindDeviceFromGateway(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.unbindDeviceFromGateway as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.unbindDeviceFromGateway as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes unbindDeviceFromGateway with error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.unbindDeviceFromGateway = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.unbindDeviceFromGateway(request), expectedError); - const actualRequest = (client.innerApiCalls.unbindDeviceFromGateway as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.unbindDeviceFromGateway as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes unbindDeviceFromGateway with closed client', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.unbindDeviceFromGateway(request), + expectedError, + ); + }); + }); + + describe('listDeviceRegistries', () => { + it('invokes listDeviceRegistries without error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.ListDeviceRegistriesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.ListDeviceRegistriesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()), + generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()), + generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()), + ]; + client.innerApiCalls.listDeviceRegistries = + stubSimpleCall(expectedResponse); + const [response] = await client.listDeviceRegistries(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listDeviceRegistries as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDeviceRegistries as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes unbindDeviceFromGateway with closed client', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.unbindDeviceFromGateway(request), expectedError); - }); + it('invokes listDeviceRegistries without error using callback', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.ListDeviceRegistriesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.ListDeviceRegistriesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()), + generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()), + generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()), + ]; + client.innerApiCalls.listDeviceRegistries = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listDeviceRegistries( + request, + ( + err?: Error | null, + result?: protos.google.cloud.iot.v1.IDeviceRegistry[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listDeviceRegistries as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDeviceRegistries as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listDeviceRegistries', () => { - it('invokes listDeviceRegistries without error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.ListDeviceRegistriesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.ListDeviceRegistriesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()), - generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()), - generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()), - ]; - client.innerApiCalls.listDeviceRegistries = stubSimpleCall(expectedResponse); - const [response] = await client.listDeviceRegistries(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listDeviceRegistries as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDeviceRegistries as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listDeviceRegistries with error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.ListDeviceRegistriesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.ListDeviceRegistriesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listDeviceRegistries = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listDeviceRegistries(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listDeviceRegistries as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDeviceRegistries as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listDeviceRegistries without error using callback', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.ListDeviceRegistriesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.ListDeviceRegistriesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()), - generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()), - generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()), - ]; - client.innerApiCalls.listDeviceRegistries = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listDeviceRegistries( - request, - (err?: Error|null, result?: protos.google.cloud.iot.v1.IDeviceRegistry[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listDeviceRegistries as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDeviceRegistries as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listDeviceRegistriesStream without error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.ListDeviceRegistriesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.ListDeviceRegistriesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()), + generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()), + generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()), + ]; + client.descriptors.page.listDeviceRegistries.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listDeviceRegistriesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.iot.v1.DeviceRegistry[] = []; + stream.on( + 'data', + (response: protos.google.cloud.iot.v1.DeviceRegistry) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listDeviceRegistries.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listDeviceRegistries, request), + ); + assert( + (client.descriptors.page.listDeviceRegistries.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listDeviceRegistries with error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.ListDeviceRegistriesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.ListDeviceRegistriesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listDeviceRegistries = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listDeviceRegistries(request), expectedError); - const actualRequest = (client.innerApiCalls.listDeviceRegistries as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDeviceRegistries as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listDeviceRegistriesStream with error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.ListDeviceRegistriesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.ListDeviceRegistriesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listDeviceRegistries.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listDeviceRegistriesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.iot.v1.DeviceRegistry[] = []; + stream.on( + 'data', + (response: protos.google.cloud.iot.v1.DeviceRegistry) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listDeviceRegistries.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listDeviceRegistries, request), + ); + assert( + (client.descriptors.page.listDeviceRegistries.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listDeviceRegistriesStream without error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.ListDeviceRegistriesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.ListDeviceRegistriesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()), - generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()), - generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()), - ]; - client.descriptors.page.listDeviceRegistries.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listDeviceRegistriesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.iot.v1.DeviceRegistry[] = []; - stream.on('data', (response: protos.google.cloud.iot.v1.DeviceRegistry) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listDeviceRegistries.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listDeviceRegistries, request)); - assert( - (client.descriptors.page.listDeviceRegistries.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listDeviceRegistries without error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.ListDeviceRegistriesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.ListDeviceRegistriesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()), + generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()), + generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()), + ]; + client.descriptors.page.listDeviceRegistries.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.iot.v1.IDeviceRegistry[] = []; + const iterable = client.listDeviceRegistriesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listDeviceRegistries.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listDeviceRegistries.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listDeviceRegistriesStream with error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.ListDeviceRegistriesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.ListDeviceRegistriesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listDeviceRegistries.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listDeviceRegistriesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.iot.v1.DeviceRegistry[] = []; - stream.on('data', (response: protos.google.cloud.iot.v1.DeviceRegistry) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listDeviceRegistries.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listDeviceRegistries, request)); - assert( - (client.descriptors.page.listDeviceRegistries.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listDeviceRegistries with error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.ListDeviceRegistriesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.ListDeviceRegistriesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listDeviceRegistries.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listDeviceRegistriesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.iot.v1.IDeviceRegistry[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listDeviceRegistries.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listDeviceRegistries.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listDevices', () => { + it('invokes listDevices without error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.ListDevicesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.ListDevicesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.iot.v1.Device()), + generateSampleMessage(new protos.google.cloud.iot.v1.Device()), + generateSampleMessage(new protos.google.cloud.iot.v1.Device()), + ]; + client.innerApiCalls.listDevices = stubSimpleCall(expectedResponse); + const [response] = await client.listDevices(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listDevices as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDevices as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listDeviceRegistries without error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.ListDeviceRegistriesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.ListDeviceRegistriesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()), - generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()), - generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()), - ]; - client.descriptors.page.listDeviceRegistries.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.iot.v1.IDeviceRegistry[] = []; - const iterable = client.listDeviceRegistriesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listDevices without error using callback', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.ListDevicesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.ListDevicesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.iot.v1.Device()), + generateSampleMessage(new protos.google.cloud.iot.v1.Device()), + generateSampleMessage(new protos.google.cloud.iot.v1.Device()), + ]; + client.innerApiCalls.listDevices = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listDevices( + request, + ( + err?: Error | null, + result?: protos.google.cloud.iot.v1.IDevice[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listDeviceRegistries.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listDeviceRegistries.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listDeviceRegistries with error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.ListDeviceRegistriesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.ListDeviceRegistriesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listDeviceRegistries.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listDeviceRegistriesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.iot.v1.IDeviceRegistry[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listDeviceRegistries.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listDeviceRegistries.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.listDevices as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDevices as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listDevices', () => { - it('invokes listDevices without error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.ListDevicesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.ListDevicesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.iot.v1.Device()), - generateSampleMessage(new protos.google.cloud.iot.v1.Device()), - generateSampleMessage(new protos.google.cloud.iot.v1.Device()), - ]; - client.innerApiCalls.listDevices = stubSimpleCall(expectedResponse); - const [response] = await client.listDevices(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listDevices as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDevices as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listDevices without error using callback', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.ListDevicesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.ListDevicesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.iot.v1.Device()), - generateSampleMessage(new protos.google.cloud.iot.v1.Device()), - generateSampleMessage(new protos.google.cloud.iot.v1.Device()), - ]; - client.innerApiCalls.listDevices = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listDevices( - request, - (err?: Error|null, result?: protos.google.cloud.iot.v1.IDevice[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listDevices as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDevices as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listDevices with error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.ListDevicesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.ListDevicesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listDevices = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listDevices(request), expectedError); - const actualRequest = (client.innerApiCalls.listDevices as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDevices as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listDevicesStream without error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.ListDevicesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.ListDevicesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.iot.v1.Device()), - generateSampleMessage(new protos.google.cloud.iot.v1.Device()), - generateSampleMessage(new protos.google.cloud.iot.v1.Device()), - ]; - client.descriptors.page.listDevices.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listDevicesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.iot.v1.Device[] = []; - stream.on('data', (response: protos.google.cloud.iot.v1.Device) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listDevices.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listDevices, request)); - assert( - (client.descriptors.page.listDevices.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listDevices with error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.ListDevicesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.ListDevicesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listDevices = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listDevices(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listDevices as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDevices as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listDevicesStream with error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.ListDevicesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.ListDevicesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listDevices.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listDevicesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.iot.v1.Device[] = []; - stream.on('data', (response: protos.google.cloud.iot.v1.Device) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listDevices.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listDevices, request)); - assert( - (client.descriptors.page.listDevices.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listDevicesStream without error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.ListDevicesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.ListDevicesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.iot.v1.Device()), + generateSampleMessage(new protos.google.cloud.iot.v1.Device()), + generateSampleMessage(new protos.google.cloud.iot.v1.Device()), + ]; + client.descriptors.page.listDevices.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listDevicesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.iot.v1.Device[] = []; + stream.on('data', (response: protos.google.cloud.iot.v1.Device) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listDevices.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listDevices, request), + ); + assert( + (client.descriptors.page.listDevices.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listDevices without error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.ListDevicesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.ListDevicesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.iot.v1.Device()), - generateSampleMessage(new protos.google.cloud.iot.v1.Device()), - generateSampleMessage(new protos.google.cloud.iot.v1.Device()), - ]; - client.descriptors.page.listDevices.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.iot.v1.IDevice[] = []; - const iterable = client.listDevicesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listDevices.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listDevices.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listDevicesStream with error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.ListDevicesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.ListDevicesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listDevices.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listDevicesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.iot.v1.Device[] = []; + stream.on('data', (response: protos.google.cloud.iot.v1.Device) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listDevices.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listDevices, request), + ); + assert( + (client.descriptors.page.listDevices.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listDevices with error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.iot.v1.ListDevicesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.iot.v1.ListDevicesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listDevices.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listDevicesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.iot.v1.IDevice[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listDevices.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listDevices.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listDevices without error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.ListDevicesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.ListDevicesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.iot.v1.Device()), + generateSampleMessage(new protos.google.cloud.iot.v1.Device()), + generateSampleMessage(new protos.google.cloud.iot.v1.Device()), + ]; + client.descriptors.page.listDevices.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.iot.v1.IDevice[] = []; + const iterable = client.listDevicesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listDevices.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.listDevices.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); }); - describe('Path templates', () => { - - describe('device', async () => { - const fakePath = "/rendered/path/device"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - registry: "registryValue", - device: "deviceValue", - }; - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.devicePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.devicePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('devicePath', () => { - const result = client.devicePath("projectValue", "locationValue", "registryValue", "deviceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.devicePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromDeviceName', () => { - const result = client.matchProjectFromDeviceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.devicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromDeviceName', () => { - const result = client.matchLocationFromDeviceName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.devicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRegistryFromDeviceName', () => { - const result = client.matchRegistryFromDeviceName(fakePath); - assert.strictEqual(result, "registryValue"); - assert((client.pathTemplates.devicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDeviceFromDeviceName', () => { - const result = client.matchDeviceFromDeviceName(fakePath); - assert.strictEqual(result, "deviceValue"); - assert((client.pathTemplates.devicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('uses async iteration with listDevices with error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.iot.v1.ListDevicesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.iot.v1.ListDevicesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listDevices.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError, + ); + const iterable = client.listDevicesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.iot.v1.IDevice[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listDevices.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.listDevices.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('Path templates', () => { + describe('device', async () => { + const fakePath = '/rendered/path/device'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + registry: 'registryValue', + device: 'deviceValue', + }; + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.devicePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.devicePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('devicePath', () => { + const result = client.devicePath( + 'projectValue', + 'locationValue', + 'registryValue', + 'deviceValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.devicePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromDeviceName', () => { + const result = client.matchProjectFromDeviceName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.devicePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromDeviceName', () => { + const result = client.matchLocationFromDeviceName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.devicePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRegistryFromDeviceName', () => { + const result = client.matchRegistryFromDeviceName(fakePath); + assert.strictEqual(result, 'registryValue'); + assert( + (client.pathTemplates.devicePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchDeviceFromDeviceName', () => { + const result = client.matchDeviceFromDeviceName(fakePath); + assert.strictEqual(result, 'deviceValue'); + assert( + (client.pathTemplates.devicePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('location', async () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new devicemanagerModule.v1.DeviceManagerClient({ - 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 devicemanagerModule.v1.DeviceManagerClient({ + 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('registry', async () => { - const fakePath = "/rendered/path/registry"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - registry: "registryValue", - }; - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.registryPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.registryPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('registryPath', () => { - const result = client.registryPath("projectValue", "locationValue", "registryValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.registryPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromRegistryName', () => { - const result = client.matchProjectFromRegistryName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.registryPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromRegistryName', () => { - const result = client.matchLocationFromRegistryName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.registryPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRegistryFromRegistryName', () => { - const result = client.matchRegistryFromRegistryName(fakePath); - assert.strictEqual(result, "registryValue"); - assert((client.pathTemplates.registryPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('registry', async () => { + const fakePath = '/rendered/path/registry'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + registry: 'registryValue', + }; + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.registryPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.registryPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('registryPath', () => { + const result = client.registryPath( + 'projectValue', + 'locationValue', + 'registryValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.registryPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromRegistryName', () => { + const result = client.matchProjectFromRegistryName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.registryPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromRegistryName', () => { + const result = client.matchLocationFromRegistryName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.registryPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRegistryFromRegistryName', () => { + const result = client.matchRegistryFromRegistryName(fakePath); + assert.strictEqual(result, 'registryValue'); + assert( + (client.pathTemplates.registryPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-iot/webpack.config.js b/packages/google-cloud-iot/webpack.config.js index 4f658ccbc3fb..7f6d8159f34a 100644 --- a/packages/google-cloud-iot/webpack.config.js +++ b/packages/google-cloud-iot/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-kms-inventory/.eslintignore b/packages/google-cloud-kms-inventory/.eslintignore new file mode 100644 index 000000000000..cfc348ec4d11 --- /dev/null +++ b/packages/google-cloud-kms-inventory/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/packages/google-cloud-kms-inventory/.eslintrc.json b/packages/google-cloud-kms-inventory/.eslintrc.json new file mode 100644 index 000000000000..3e8d97ccb390 --- /dev/null +++ b/packages/google-cloud-kms-inventory/.eslintrc.json @@ -0,0 +1,4 @@ +{ + "extends": "./node_modules/gts", + "root": true +} diff --git a/packages/google-cloud-kms-inventory/README.md b/packages/google-cloud-kms-inventory/README.md index 804614417b7c..2098ed9fdf44 100644 --- a/packages/google-cloud-kms-inventory/README.md +++ b/packages/google-cloud-kms-inventory/README.md @@ -94,7 +94,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-kms-inventory/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`) @@ -104,7 +104,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-kms-inventory/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-kms-inventory/protos/protos.d.ts b/packages/google-cloud-kms-inventory/protos/protos.d.ts index cef946500170..cfcaa2820a97 100644 --- a/packages/google-cloud-kms-inventory/protos/protos.d.ts +++ b/packages/google-cloud-kms-inventory/protos/protos.d.ts @@ -3203,6 +3203,9 @@ export namespace google { /** CommonLanguageSettings destinations */ destinations?: (google.api.ClientLibraryDestination[]|null); + + /** CommonLanguageSettings selectiveGapicGeneration */ + selectiveGapicGeneration?: (google.api.ISelectiveGapicGeneration|null); } /** Represents a CommonLanguageSettings. */ @@ -3220,6 +3223,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 @@ -3920,6 +3926,9 @@ export namespace google { /** PythonSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** PythonSettings experimentalFeatures */ + experimentalFeatures?: (google.api.PythonSettings.IExperimentalFeatures|null); } /** Represents a PythonSettings. */ @@ -3934,6 +3943,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 @@ -4012,6 +4024,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 { @@ -4338,6 +4462,9 @@ export namespace google { /** GoSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** GoSettings renamedServices */ + renamedServices?: ({ [k: string]: string }|null); } /** Represents a GoSettings. */ @@ -4352,6 +4479,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 @@ -4676,6 +4806,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, @@ -5057,6 +5290,7 @@ export namespace google { /** Edition enum. */ enum Edition { EDITION_UNKNOWN = 0, + EDITION_LEGACY = 900, EDITION_PROTO2 = 998, EDITION_PROTO3 = 999, EDITION_2023 = 1000, @@ -5087,6 +5321,9 @@ export namespace google { /** FileDescriptorProto weakDependency */ weakDependency?: (number[]|null); + /** FileDescriptorProto optionDependency */ + optionDependency?: (string[]|null); + /** FileDescriptorProto messageType */ messageType?: (google.protobuf.IDescriptorProto[]|null); @@ -5136,6 +5373,9 @@ export namespace google { /** FileDescriptorProto weakDependency. */ public weakDependency: number[]; + /** FileDescriptorProto optionDependency. */ + public optionDependency: string[]; + /** FileDescriptorProto messageType. */ public messageType: google.protobuf.IDescriptorProto[]; @@ -5270,6 +5510,9 @@ export namespace google { /** DescriptorProto reservedName */ reservedName?: (string[]|null); + + /** DescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents a DescriptorProto. */ @@ -5311,6 +5554,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 @@ -6158,6 +6404,9 @@ export namespace google { /** EnumDescriptorProto reservedName */ reservedName?: (string[]|null); + + /** EnumDescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents an EnumDescriptorProto. */ @@ -6184,6 +6433,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 @@ -7118,6 +7370,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); @@ -7173,6 +7428,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[]; @@ -7393,6 +7651,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. */ @@ -7631,6 +8004,9 @@ export namespace google { /** EnumValueOptions debugRedact */ debugRedact?: (boolean|null); + /** EnumValueOptions featureSupport */ + featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** EnumValueOptions uninterpretedOption */ uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); } @@ -7653,6 +8029,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[]; @@ -8242,6 +8621,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. */ @@ -8271,6 +8656,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 @@ -8393,6 +8784,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. */ @@ -8512,8 +9013,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. */ @@ -8528,8 +9032,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. @@ -9062,6 +9569,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-kms-inventory/protos/protos.js b/packages/google-cloud-kms-inventory/protos/protos.js index d3391599265e..02de1c27e339 100644 --- a/packages/google-cloud-kms-inventory/protos/protos.js +++ b/packages/google-cloud-kms-inventory/protos/protos.js @@ -9520,6 +9520,7 @@ * @interface ICommonLanguageSettings * @property {string|null} [referenceDocsUri] CommonLanguageSettings referenceDocsUri * @property {Array.|null} [destinations] CommonLanguageSettings destinations + * @property {google.api.ISelectiveGapicGeneration|null} [selectiveGapicGeneration] CommonLanguageSettings selectiveGapicGeneration */ /** @@ -9554,6 +9555,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 @@ -9586,6 +9595,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; }; @@ -9637,6 +9648,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; @@ -9688,6 +9703,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; }; @@ -9730,6 +9750,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; }; @@ -9748,8 +9773,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) { @@ -9757,6 +9784,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; }; @@ -11579,6 +11608,7 @@ * @memberof google.api * @interface IPythonSettings * @property {google.api.ICommonLanguageSettings|null} [common] PythonSettings common + * @property {google.api.PythonSettings.IExperimentalFeatures|null} [experimentalFeatures] PythonSettings experimentalFeatures */ /** @@ -11604,6 +11634,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 @@ -11630,6 +11668,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; }; @@ -11670,6 +11710,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; @@ -11710,6 +11754,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; }; @@ -11730,6 +11779,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; }; @@ -11746,10 +11800,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; }; @@ -11779,6 +11837,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; })(); @@ -12655,6 +12965,7 @@ * @memberof google.api * @interface IGoSettings * @property {google.api.ICommonLanguageSettings|null} [common] GoSettings common + * @property {Object.|null} [renamedServices] GoSettings renamedServices */ /** @@ -12666,6 +12977,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) @@ -12680,6 +12992,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 @@ -12706,6 +13026,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; }; @@ -12736,7 +13059,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) @@ -12746,6 +13069,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; @@ -12786,6 +13132,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; }; @@ -12806,6 +13160,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; }; @@ -12822,10 +13183,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; }; @@ -13464,29 +13833,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; })(); @@ -14449,6 +15063,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 @@ -14463,6 +15078,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; @@ -14487,6 +15103,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 @@ -14509,6 +15126,7 @@ this.dependency = []; this.publicDependency = []; this.weakDependency = []; + this.optionDependency = []; this.messageType = []; this.enumType = []; this.service = []; @@ -14559,6 +15177,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 @@ -14680,6 +15306,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; }; @@ -14752,6 +15381,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 = []; @@ -14854,6 +15489,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"; @@ -14908,6 +15550,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -14960,6 +15603,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"); @@ -15023,6 +15673,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -15088,6 +15742,7 @@ object.extension = []; object.publicDependency = []; object.weakDependency = []; + object.optionDependency = []; } if (options.defaults) { object.name = ""; @@ -15144,6 +15799,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; }; @@ -15192,6 +15852,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 */ /** @@ -15297,6 +15958,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 @@ -15349,6 +16018,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; }; @@ -15441,6 +16112,10 @@ message.reservedName.push(reader.string()); break; } + case 11: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -15554,6 +16229,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; }; @@ -15653,6 +16337,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; }; @@ -15682,6 +16386,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; @@ -15727,6 +16432,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; }; @@ -17771,6 +18478,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 */ /** @@ -17831,6 +18539,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 @@ -17868,6 +18584,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; }; @@ -17930,6 +18648,10 @@ message.reservedName.push(reader.string()); break; } + case 6: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -17998,6 +18720,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; }; @@ -18047,6 +18778,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; }; @@ -18071,6 +18822,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; @@ -18091,6 +18843,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; }; @@ -20409,6 +21163,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 @@ -20529,6 +21284,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 @@ -20603,6 +21366,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(); @@ -20704,6 +21469,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 = []; @@ -20839,6 +21608,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"; @@ -21027,6 +21801,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"); @@ -21124,6 +21903,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")) @@ -21156,6 +21936,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) @@ -21428,6 +22210,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -21469,103 +22252,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; @@ -22160,6 +23429,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 */ @@ -22203,6 +23473,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 @@ -22241,6 +23519,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(); @@ -22292,6 +23572,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 = []; @@ -22344,6 +23628,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"; @@ -22377,6 +23666,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"); @@ -22409,6 +23703,7 @@ object.deprecated = false; object.features = null; object.debugRedact = false; + object.featureSupport = null; } if (message.deprecated != null && message.hasOwnProperty("deprecated")) object.deprecated = message.deprecated; @@ -22416,6 +23711,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) @@ -23855,6 +25152,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 */ /** @@ -23920,6 +25219,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 @@ -23956,6 +25271,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; }; @@ -24016,6 +25335,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; @@ -24106,6 +25433,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; }; @@ -24245,6 +25592,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; }; @@ -24268,6 +25663,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; @@ -24281,6 +25678,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; }; @@ -24408,6 +25809,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; })(); @@ -24592,6 +26206,7 @@ default: return "minimumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -24609,6 +26224,7 @@ default: return "maximumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -24657,6 +26273,10 @@ case 0: message.minimumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.minimumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.minimumEdition = 998; @@ -24709,6 +26329,10 @@ case 0: message.maximumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.maximumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.maximumEdition = 998; @@ -24817,7 +26441,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 */ /** @@ -24844,12 +26469,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. @@ -24875,10 +26508,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; }; @@ -24919,8 +26554,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: @@ -24963,6 +26602,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -24975,10 +26615,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; }; @@ -25006,6 +26651,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -25047,10 +26696,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; }; @@ -25069,13 +26723,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; }; @@ -26290,6 +27947,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-kms-inventory/protos/protos.json b/packages/google-cloud-kms-inventory/protos/protos.json index a8cfc837d0cc..ffb530d8b34c 100644 --- a/packages/google-cloud-kms-inventory/protos/protos.json +++ b/packages/google-cloud-kms-inventory/protos/protos.json @@ -1001,8 +1001,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": { @@ -1126,6 +1125,10 @@ "rule": "repeated", "type": "ClientLibraryDestination", "id": 2 + }, + "selectiveGapicGeneration": { + "type": "SelectiveGapicGeneration", + "id": 3 } } }, @@ -1266,6 +1269,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 + } + } } } }, @@ -1323,6 +1348,11 @@ "common": { "type": "CommonLanguageSettings", "id": 1 + }, + "renamedServices": { + "keyType": "string", + "type": "string", + "id": 2 } } }, @@ -1384,6 +1414,19 @@ "PACKAGE_MANAGER": 20 } }, + "SelectiveGapicGeneration": { + "fields": { + "methods": { + "rule": "repeated", + "type": "string", + "id": 1 + }, + "generateOmittedAsInternal": { + "type": "bool", + "id": 2 + } + } + }, "LaunchStage": { "values": { "LAUNCH_STAGE_UNSPECIFIED": 0, @@ -1516,12 +1559,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, @@ -1560,6 +1610,11 @@ "type": "int32", "id": 11 }, + "optionDependency": { + "rule": "repeated", + "type": "string", + "id": 15 + }, "messageType": { "rule": "repeated", "type": "DescriptorProto", @@ -1648,6 +1703,10 @@ "rule": "repeated", "type": "string", "id": 10 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 11 } }, "nested": { @@ -1873,6 +1932,10 @@ "rule": "repeated", "type": "string", "id": 5 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 6 } }, "nested": { @@ -1923,7 +1986,14 @@ "type": "ServiceOptions", "id": 3 } - } + }, + "reserved": [ + [ + 4, + 4 + ], + "stream" + ] }, "MethodDescriptorProto": { "edition": "proto2", @@ -2087,6 +2157,7 @@ 42, 42 ], + "php_generic_services", [ 38, 38 @@ -2222,7 +2293,8 @@ "type": "bool", "id": 10, "options": { - "default": false + "default": false, + "deprecated": true } }, "debugRedact": { @@ -2250,6 +2322,10 @@ "type": "FeatureSet", "id": 21 }, + "featureSupport": { + "type": "FeatureSupport", + "id": 22 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -2319,6 +2395,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 + } + } } } }, @@ -2407,6 +2503,10 @@ "default": false } }, + "featureSupport": { + "type": "FieldOptions.FeatureSupport", + "id": 4 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -2549,6 +2649,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_2023", "edition_defaults.value": "EXPLICIT" } @@ -2559,6 +2660,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "OPEN" } @@ -2569,6 +2671,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "PACKED" } @@ -2579,6 +2682,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "VERIFY" } @@ -2589,7 +2693,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" } }, @@ -2599,27 +2704,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, @@ -2664,7 +2780,13 @@ "UTF8_VALIDATION_UNKNOWN": 0, "VERIFY": 2, "NONE": 3 - } + }, + "reserved": [ + [ + 1, + 1 + ] + ] }, "MessageEncoding": { "values": { @@ -2679,6 +2801,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 + } + } + } } } }, @@ -2706,11 +2855,26 @@ "type": "Edition", "id": 3 }, - "features": { + "overridableFeatures": { "type": "FeatureSet", - "id": 2 + "id": 4 + }, + "fixedFeatures": { + "type": "FeatureSet", + "id": 5 } - } + }, + "reserved": [ + [ + 1, + 1 + ], + [ + 2, + 2 + ], + "features" + ] } } }, @@ -2723,6 +2887,12 @@ "id": 1 } }, + "extensions": [ + [ + 536000000, + 536000000 + ] + ], "nested": { "Location": { "fields": { @@ -2808,6 +2978,14 @@ } } }, + "SymbolVisibility": { + "edition": "proto2", + "values": { + "VISIBILITY_UNSET": 0, + "VISIBILITY_LOCAL": 1, + "VISIBILITY_EXPORT": 2 + } + }, "Duration": { "fields": { "seconds": { diff --git a/packages/google-cloud-kms-inventory/samples/generated/v1/snippet_metadata_google.cloud.kms.inventory.v1.json b/packages/google-cloud-kms-inventory/samples/generated/v1/snippet_metadata_google.cloud.kms.inventory.v1.json index 83dde952987b..bf36f705b491 100644 --- a/packages/google-cloud-kms-inventory/samples/generated/v1/snippet_metadata_google.cloud.kms.inventory.v1.json +++ b/packages/google-cloud-kms-inventory/samples/generated/v1/snippet_metadata_google.cloud.kms.inventory.v1.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-inventory", - "version": "2.6.0", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-kms-inventory/src/v1/index.ts b/packages/google-cloud-kms-inventory/src/v1/index.ts index e48e5dd14314..3df2c7962e26 100644 --- a/packages/google-cloud-kms-inventory/src/v1/index.ts +++ b/packages/google-cloud-kms-inventory/src/v1/index.ts @@ -16,5 +16,5 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {KeyDashboardServiceClient} from './key_dashboard_service_client'; -export {KeyTrackingServiceClient} from './key_tracking_service_client'; +export { KeyDashboardServiceClient } from './key_dashboard_service_client'; +export { KeyTrackingServiceClient } from './key_tracking_service_client'; diff --git a/packages/google-cloud-kms-inventory/src/v1/key_dashboard_service_client.ts b/packages/google-cloud-kms-inventory/src/v1/key_dashboard_service_client.ts index f57dea0a789b..6d884d122eb9 100644 --- a/packages/google-cloud-kms-inventory/src/v1/key_dashboard_service_client.ts +++ b/packages/google-cloud-kms-inventory/src/v1/key_dashboard_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 KeyDashboardServiceClient { 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('kms-inventory'); @@ -57,9 +64,9 @@ export class KeyDashboardServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - keyDashboardServiceStub?: Promise<{[name: string]: Function}>; + innerApiCalls: { [name: string]: Function }; + pathTemplates: { [name: string]: gax.PathTemplate }; + keyDashboardServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of KeyDashboardServiceClient. @@ -100,21 +107,42 @@ export class KeyDashboardServiceClient { * const client = new KeyDashboardServiceClient({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 KeyDashboardServiceClient; - 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 = 'kmsinventory.' + 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 KeyDashboardServiceClient { 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 KeyDashboardServiceClient { } // 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 KeyDashboardServiceClient { // Create useful helper objects for these. this.pathTemplates = { 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}', ), importJobPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/keyRings/{key_ring}/importJobs/{import_job}' + 'projects/{project}/locations/{location}/keyRings/{key_ring}/importJobs/{import_job}', ), keyRingPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/keyRings/{key_ring}' + 'projects/{project}/locations/{location}/keyRings/{key_ring}', ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' - ), - projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}/protectedResourcesSummary' - ), - projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/protectedResourcesSummary' + 'projects/{project}', ), + projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate: + new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}/protectedResourcesSummary', + ), + projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPathTemplate: + new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/protectedResourcesSummary', + ), publicKeyPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}/publicKey' + 'projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}/publicKey', ), retiredResourcePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/retiredResources/{retired_resource}' + 'projects/{project}/locations/{location}/retiredResources/{retired_resource}', ), }; @@ -210,14 +237,20 @@ export class KeyDashboardServiceClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listCryptoKeys: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'cryptoKeys') + listCryptoKeys: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'cryptoKeys', + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.kms.inventory.v1.KeyDashboardService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.kms.inventory.v1.KeyDashboardService', + 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 @@ -248,37 +281,41 @@ export class KeyDashboardServiceClient { // Put together the "service stub" for // google.cloud.kms.inventory.v1.KeyDashboardService. this.keyDashboardServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.kms.inventory.v1.KeyDashboardService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.kms.inventory.v1.KeyDashboardService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.kms.inventory.v1.KeyDashboardService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.kms.inventory.v1 + .KeyDashboardService, + 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 keyDashboardServiceStubMethods = - ['listCryptoKeys']; + const keyDashboardServiceStubMethods = ['listCryptoKeys']; for (const methodName of keyDashboardServiceStubMethods) { const callPromise = this.keyDashboardServiceStub.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; @@ -293,8 +330,14 @@ export class KeyDashboardServiceClient { * @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 'kmsinventory.googleapis.com'; } @@ -305,8 +348,14 @@ export class KeyDashboardServiceClient { * @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 'kmsinventory.googleapis.com'; } @@ -337,9 +386,7 @@ export class KeyDashboardServiceClient { * @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; @@ -348,8 +395,9 @@ export class KeyDashboardServiceClient { * 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; @@ -361,93 +409,118 @@ export class KeyDashboardServiceClient { // -- Service calls -- // ------------------- - /** - * Returns cryptographic keys managed by Cloud KMS in a given Cloud project. - * Note that this data is sourced from snapshots, meaning it may not - * completely reflect the actual state of key metadata at call time. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The Google Cloud project for which to retrieve key metadata, in - * the format `projects/*` - * @param {number} [request.pageSize] - * Optional. The maximum number of keys to return. The service may return - * fewer than this value. If unspecified, at most 1000 keys will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} [request.pageToken] - * Optional. Pass this into a subsequent request in order to receive the next - * page of 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.kms.v1.CryptoKey|CryptoKey}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listCryptoKeysAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Returns cryptographic keys managed by Cloud KMS in a given Cloud project. + * Note that this data is sourced from snapshots, meaning it may not + * completely reflect the actual state of key metadata at call time. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The Google Cloud project for which to retrieve key metadata, in + * the format `projects/*` + * @param {number} [request.pageSize] + * Optional. The maximum number of keys to return. The service may return + * fewer than this value. If unspecified, at most 1000 keys will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. Pass this into a subsequent request in order to receive the next + * page of 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.kms.v1.CryptoKey|CryptoKey}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listCryptoKeysAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listCryptoKeys( - request?: protos.google.cloud.kms.inventory.v1.IListCryptoKeysRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.kms.v1.ICryptoKey[], - protos.google.cloud.kms.inventory.v1.IListCryptoKeysRequest|null, - protos.google.cloud.kms.inventory.v1.IListCryptoKeysResponse - ]>; + request?: protos.google.cloud.kms.inventory.v1.IListCryptoKeysRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.kms.v1.ICryptoKey[], + protos.google.cloud.kms.inventory.v1.IListCryptoKeysRequest | null, + protos.google.cloud.kms.inventory.v1.IListCryptoKeysResponse, + ] + >; listCryptoKeys( - request: protos.google.cloud.kms.inventory.v1.IListCryptoKeysRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.kms.inventory.v1.IListCryptoKeysRequest, - protos.google.cloud.kms.inventory.v1.IListCryptoKeysResponse|null|undefined, - protos.google.cloud.kms.v1.ICryptoKey>): void; + request: protos.google.cloud.kms.inventory.v1.IListCryptoKeysRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.kms.inventory.v1.IListCryptoKeysRequest, + | protos.google.cloud.kms.inventory.v1.IListCryptoKeysResponse + | null + | undefined, + protos.google.cloud.kms.v1.ICryptoKey + >, + ): void; listCryptoKeys( - request: protos.google.cloud.kms.inventory.v1.IListCryptoKeysRequest, - callback: PaginationCallback< - protos.google.cloud.kms.inventory.v1.IListCryptoKeysRequest, - protos.google.cloud.kms.inventory.v1.IListCryptoKeysResponse|null|undefined, - protos.google.cloud.kms.v1.ICryptoKey>): void; + request: protos.google.cloud.kms.inventory.v1.IListCryptoKeysRequest, + callback: PaginationCallback< + protos.google.cloud.kms.inventory.v1.IListCryptoKeysRequest, + | protos.google.cloud.kms.inventory.v1.IListCryptoKeysResponse + | null + | undefined, + protos.google.cloud.kms.v1.ICryptoKey + >, + ): void; listCryptoKeys( - request?: protos.google.cloud.kms.inventory.v1.IListCryptoKeysRequest, - optionsOrCallback?: CallOptions|PaginationCallback< + request?: protos.google.cloud.kms.inventory.v1.IListCryptoKeysRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.kms.inventory.v1.IListCryptoKeysRequest, - protos.google.cloud.kms.inventory.v1.IListCryptoKeysResponse|null|undefined, - protos.google.cloud.kms.v1.ICryptoKey>, - callback?: PaginationCallback< - protos.google.cloud.kms.inventory.v1.IListCryptoKeysRequest, - protos.google.cloud.kms.inventory.v1.IListCryptoKeysResponse|null|undefined, - protos.google.cloud.kms.v1.ICryptoKey>): - Promise<[ - protos.google.cloud.kms.v1.ICryptoKey[], - protos.google.cloud.kms.inventory.v1.IListCryptoKeysRequest|null, - protos.google.cloud.kms.inventory.v1.IListCryptoKeysResponse - ]>|void { + | protos.google.cloud.kms.inventory.v1.IListCryptoKeysResponse + | null + | undefined, + protos.google.cloud.kms.v1.ICryptoKey + >, + callback?: PaginationCallback< + protos.google.cloud.kms.inventory.v1.IListCryptoKeysRequest, + | protos.google.cloud.kms.inventory.v1.IListCryptoKeysResponse + | null + | undefined, + protos.google.cloud.kms.v1.ICryptoKey + >, + ): Promise< + [ + protos.google.cloud.kms.v1.ICryptoKey[], + protos.google.cloud.kms.inventory.v1.IListCryptoKeysRequest | null, + protos.google.cloud.kms.inventory.v1.IListCryptoKeysResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-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.kms.inventory.v1.IListCryptoKeysRequest, - protos.google.cloud.kms.inventory.v1.IListCryptoKeysResponse|null|undefined, - protos.google.cloud.kms.v1.ICryptoKey>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.kms.inventory.v1.IListCryptoKeysRequest, + | protos.google.cloud.kms.inventory.v1.IListCryptoKeysResponse + | null + | undefined, + protos.google.cloud.kms.v1.ICryptoKey + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listCryptoKeys values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -456,114 +529,118 @@ export class KeyDashboardServiceClient { this._log.info('listCryptoKeys request %j', request); return this.innerApiCalls .listCryptoKeys(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.kms.v1.ICryptoKey[], - protos.google.cloud.kms.inventory.v1.IListCryptoKeysRequest|null, - protos.google.cloud.kms.inventory.v1.IListCryptoKeysResponse - ]) => { - this._log.info('listCryptoKeys values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.kms.v1.ICryptoKey[], + protos.google.cloud.kms.inventory.v1.IListCryptoKeysRequest | null, + protos.google.cloud.kms.inventory.v1.IListCryptoKeysResponse, + ]) => { + this._log.info('listCryptoKeys values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listCryptoKeys`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The Google Cloud project for which to retrieve key metadata, in - * the format `projects/*` - * @param {number} [request.pageSize] - * Optional. The maximum number of keys to return. The service may return - * fewer than this value. If unspecified, at most 1000 keys will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} [request.pageToken] - * Optional. Pass this into a subsequent request in order to receive the next - * page of 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.kms.v1.CryptoKey|CryptoKey} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listCryptoKeysAsync()` - * method described below for async iteration which you can stop as 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 `listCryptoKeys`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The Google Cloud project for which to retrieve key metadata, in + * the format `projects/*` + * @param {number} [request.pageSize] + * Optional. The maximum number of keys to return. The service may return + * fewer than this value. If unspecified, at most 1000 keys will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. Pass this into a subsequent request in order to receive the next + * page of 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.kms.v1.CryptoKey|CryptoKey} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listCryptoKeysAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listCryptoKeysStream( - request?: protos.google.cloud.kms.inventory.v1.IListCryptoKeysRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.kms.inventory.v1.IListCryptoKeysRequest, + 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['listCryptoKeys']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listCryptoKeys stream %j', request); return this.descriptors.page.listCryptoKeys.createStream( this.innerApiCalls.listCryptoKeys as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listCryptoKeys`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used 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 Google Cloud project for which to retrieve key metadata, in - * the format `projects/*` - * @param {number} [request.pageSize] - * Optional. The maximum number of keys to return. The service may return - * fewer than this value. If unspecified, at most 1000 keys will be returned. - * The maximum value is 1000; values above 1000 will be coerced to 1000. - * @param {string} [request.pageToken] - * Optional. Pass this into a subsequent request in order to receive the next - * page of 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.kms.v1.CryptoKey|CryptoKey}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@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/key_dashboard_service.list_crypto_keys.js - * region_tag:kmsinventory_v1_generated_KeyDashboardService_ListCryptoKeys_async - */ + /** + * Equivalent to `listCryptoKeys`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used 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 Google Cloud project for which to retrieve key metadata, in + * the format `projects/*` + * @param {number} [request.pageSize] + * Optional. The maximum number of keys to return. The service may return + * fewer than this value. If unspecified, at most 1000 keys will be returned. + * The maximum value is 1000; values above 1000 will be coerced to 1000. + * @param {string} [request.pageToken] + * Optional. Pass this into a subsequent request in order to receive the next + * page of 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.kms.v1.CryptoKey|CryptoKey}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@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/key_dashboard_service.list_crypto_keys.js + * region_tag:kmsinventory_v1_generated_KeyDashboardService_ListCryptoKeys_async + */ listCryptoKeysAsync( - request?: protos.google.cloud.kms.inventory.v1.IListCryptoKeysRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.kms.inventory.v1.IListCryptoKeysRequest, + 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['listCryptoKeys']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listCryptoKeys iterate %j', request); return this.descriptors.page.listCryptoKeys.asyncIterate( this.innerApiCalls['listCryptoKeys'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } // -------------------- @@ -579,7 +656,12 @@ export class KeyDashboardServiceClient { * @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, @@ -596,7 +678,8 @@ export class KeyDashboardServiceClient { * @returns {string} A string representing the project. */ matchProjectFromCryptoKeyName(cryptoKeyName: string) { - return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName).project; + return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName) + .project; } /** @@ -607,7 +690,8 @@ export class KeyDashboardServiceClient { * @returns {string} A string representing the location. */ matchLocationFromCryptoKeyName(cryptoKeyName: string) { - return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName).location; + return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName) + .location; } /** @@ -618,7 +702,8 @@ export class KeyDashboardServiceClient { * @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; } /** @@ -629,7 +714,8 @@ export class KeyDashboardServiceClient { * @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; } /** @@ -642,7 +728,13 @@ export class KeyDashboardServiceClient { * @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, @@ -660,7 +752,9 @@ export class KeyDashboardServiceClient { * @returns {string} A string representing the project. */ matchProjectFromCryptoKeyVersionName(cryptoKeyVersionName: string) { - return this.pathTemplates.cryptoKeyVersionPathTemplate.match(cryptoKeyVersionName).project; + return this.pathTemplates.cryptoKeyVersionPathTemplate.match( + cryptoKeyVersionName, + ).project; } /** @@ -671,7 +765,9 @@ export class KeyDashboardServiceClient { * @returns {string} A string representing the location. */ matchLocationFromCryptoKeyVersionName(cryptoKeyVersionName: string) { - return this.pathTemplates.cryptoKeyVersionPathTemplate.match(cryptoKeyVersionName).location; + return this.pathTemplates.cryptoKeyVersionPathTemplate.match( + cryptoKeyVersionName, + ).location; } /** @@ -682,7 +778,9 @@ export class KeyDashboardServiceClient { * @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; } /** @@ -693,7 +791,9 @@ export class KeyDashboardServiceClient { * @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; } /** @@ -704,7 +804,9 @@ export class KeyDashboardServiceClient { * @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; } /** @@ -716,7 +818,12 @@ export class KeyDashboardServiceClient { * @param {string} import_job * @returns {string} Resource name string. */ - importJobPath(project:string,location:string,keyRing:string,importJob:string) { + importJobPath( + project: string, + location: string, + keyRing: string, + importJob: string, + ) { return this.pathTemplates.importJobPathTemplate.render({ project: project, location: location, @@ -733,7 +840,8 @@ export class KeyDashboardServiceClient { * @returns {string} A string representing the project. */ matchProjectFromImportJobName(importJobName: string) { - return this.pathTemplates.importJobPathTemplate.match(importJobName).project; + return this.pathTemplates.importJobPathTemplate.match(importJobName) + .project; } /** @@ -744,7 +852,8 @@ export class KeyDashboardServiceClient { * @returns {string} A string representing the location. */ matchLocationFromImportJobName(importJobName: string) { - return this.pathTemplates.importJobPathTemplate.match(importJobName).location; + return this.pathTemplates.importJobPathTemplate.match(importJobName) + .location; } /** @@ -755,7 +864,8 @@ export class KeyDashboardServiceClient { * @returns {string} A string representing the key_ring. */ matchKeyRingFromImportJobName(importJobName: string) { - return this.pathTemplates.importJobPathTemplate.match(importJobName).key_ring; + return this.pathTemplates.importJobPathTemplate.match(importJobName) + .key_ring; } /** @@ -766,7 +876,8 @@ export class KeyDashboardServiceClient { * @returns {string} A string representing the import_job. */ matchImportJobFromImportJobName(importJobName: string) { - return this.pathTemplates.importJobPathTemplate.match(importJobName).import_job; + return this.pathTemplates.importJobPathTemplate.match(importJobName) + .import_job; } /** @@ -777,7 +888,7 @@ export class KeyDashboardServiceClient { * @param {string} key_ring * @returns {string} Resource name string. */ - keyRingPath(project:string,location:string,keyRing:string) { + keyRingPath(project: string, location: string, keyRing: string) { return this.pathTemplates.keyRingPathTemplate.render({ project: project, location: location, @@ -824,7 +935,7 @@ export class KeyDashboardServiceClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -851,14 +962,22 @@ export class KeyDashboardServiceClient { * @param {string} crypto_key_version * @returns {string} Resource name string. */ - projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPath(project:string,location:string,keyRing:string,cryptoKey:string,cryptoKeyVersion:string) { - return this.pathTemplates.projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate.render({ - project: project, - location: location, - key_ring: keyRing, - crypto_key: cryptoKey, - crypto_key_version: cryptoKeyVersion, - }); + projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPath( + project: string, + location: string, + keyRing: string, + cryptoKey: string, + cryptoKeyVersion: string, + ) { + return this.pathTemplates.projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate.render( + { + project: project, + location: location, + key_ring: keyRing, + crypto_key: cryptoKey, + crypto_key_version: cryptoKeyVersion, + }, + ); } /** @@ -868,8 +987,12 @@ export class KeyDashboardServiceClient { * A fully-qualified path representing project_location_key_ring_crypto_key_crypto_key_version_protectedResourcesSummary resource. * @returns {string} A string representing the project. */ - matchProjectFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName(projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName: string) { - return this.pathTemplates.projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate.match(projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName).project; + matchProjectFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName( + projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName: string, + ) { + return this.pathTemplates.projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate.match( + projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName, + ).project; } /** @@ -879,8 +1002,12 @@ export class KeyDashboardServiceClient { * A fully-qualified path representing project_location_key_ring_crypto_key_crypto_key_version_protectedResourcesSummary resource. * @returns {string} A string representing the location. */ - matchLocationFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName(projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName: string) { - return this.pathTemplates.projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate.match(projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName).location; + matchLocationFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName( + projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName: string, + ) { + return this.pathTemplates.projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate.match( + projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName, + ).location; } /** @@ -890,8 +1017,12 @@ export class KeyDashboardServiceClient { * A fully-qualified path representing project_location_key_ring_crypto_key_crypto_key_version_protectedResourcesSummary resource. * @returns {string} A string representing the key_ring. */ - matchKeyRingFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName(projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName: string) { - return this.pathTemplates.projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate.match(projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName).key_ring; + matchKeyRingFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName( + projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName: string, + ) { + return this.pathTemplates.projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate.match( + projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName, + ).key_ring; } /** @@ -901,8 +1032,12 @@ export class KeyDashboardServiceClient { * A fully-qualified path representing project_location_key_ring_crypto_key_crypto_key_version_protectedResourcesSummary resource. * @returns {string} A string representing the crypto_key. */ - matchCryptoKeyFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName(projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName: string) { - return this.pathTemplates.projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate.match(projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName).crypto_key; + matchCryptoKeyFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName( + projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName: string, + ) { + return this.pathTemplates.projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate.match( + projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName, + ).crypto_key; } /** @@ -912,8 +1047,12 @@ export class KeyDashboardServiceClient { * A fully-qualified path representing project_location_key_ring_crypto_key_crypto_key_version_protectedResourcesSummary resource. * @returns {string} A string representing the crypto_key_version. */ - matchCryptoKeyVersionFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName(projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName: string) { - return this.pathTemplates.projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate.match(projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName).crypto_key_version; + matchCryptoKeyVersionFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName( + projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName: string, + ) { + return this.pathTemplates.projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate.match( + projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName, + ).crypto_key_version; } /** @@ -925,13 +1064,20 @@ export class KeyDashboardServiceClient { * @param {string} crypto_key * @returns {string} Resource name string. */ - projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPath(project:string,location:string,keyRing:string,cryptoKey:string) { - return this.pathTemplates.projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPathTemplate.render({ - project: project, - location: location, - key_ring: keyRing, - crypto_key: cryptoKey, - }); + projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPath( + project: string, + location: string, + keyRing: string, + cryptoKey: string, + ) { + return this.pathTemplates.projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPathTemplate.render( + { + project: project, + location: location, + key_ring: keyRing, + crypto_key: cryptoKey, + }, + ); } /** @@ -941,8 +1087,12 @@ export class KeyDashboardServiceClient { * A fully-qualified path representing project_location_key_ring_crypto_key_protectedResourcesSummary resource. * @returns {string} A string representing the project. */ - matchProjectFromProjectLocationKeyRingCryptoKeyProtectedResourcesSummaryName(projectLocationKeyRingCryptoKeyProtectedResourcesSummaryName: string) { - return this.pathTemplates.projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPathTemplate.match(projectLocationKeyRingCryptoKeyProtectedResourcesSummaryName).project; + matchProjectFromProjectLocationKeyRingCryptoKeyProtectedResourcesSummaryName( + projectLocationKeyRingCryptoKeyProtectedResourcesSummaryName: string, + ) { + return this.pathTemplates.projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPathTemplate.match( + projectLocationKeyRingCryptoKeyProtectedResourcesSummaryName, + ).project; } /** @@ -952,8 +1102,12 @@ export class KeyDashboardServiceClient { * A fully-qualified path representing project_location_key_ring_crypto_key_protectedResourcesSummary resource. * @returns {string} A string representing the location. */ - matchLocationFromProjectLocationKeyRingCryptoKeyProtectedResourcesSummaryName(projectLocationKeyRingCryptoKeyProtectedResourcesSummaryName: string) { - return this.pathTemplates.projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPathTemplate.match(projectLocationKeyRingCryptoKeyProtectedResourcesSummaryName).location; + matchLocationFromProjectLocationKeyRingCryptoKeyProtectedResourcesSummaryName( + projectLocationKeyRingCryptoKeyProtectedResourcesSummaryName: string, + ) { + return this.pathTemplates.projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPathTemplate.match( + projectLocationKeyRingCryptoKeyProtectedResourcesSummaryName, + ).location; } /** @@ -963,8 +1117,12 @@ export class KeyDashboardServiceClient { * A fully-qualified path representing project_location_key_ring_crypto_key_protectedResourcesSummary resource. * @returns {string} A string representing the key_ring. */ - matchKeyRingFromProjectLocationKeyRingCryptoKeyProtectedResourcesSummaryName(projectLocationKeyRingCryptoKeyProtectedResourcesSummaryName: string) { - return this.pathTemplates.projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPathTemplate.match(projectLocationKeyRingCryptoKeyProtectedResourcesSummaryName).key_ring; + matchKeyRingFromProjectLocationKeyRingCryptoKeyProtectedResourcesSummaryName( + projectLocationKeyRingCryptoKeyProtectedResourcesSummaryName: string, + ) { + return this.pathTemplates.projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPathTemplate.match( + projectLocationKeyRingCryptoKeyProtectedResourcesSummaryName, + ).key_ring; } /** @@ -974,8 +1132,12 @@ export class KeyDashboardServiceClient { * A fully-qualified path representing project_location_key_ring_crypto_key_protectedResourcesSummary resource. * @returns {string} A string representing the crypto_key. */ - matchCryptoKeyFromProjectLocationKeyRingCryptoKeyProtectedResourcesSummaryName(projectLocationKeyRingCryptoKeyProtectedResourcesSummaryName: string) { - return this.pathTemplates.projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPathTemplate.match(projectLocationKeyRingCryptoKeyProtectedResourcesSummaryName).crypto_key; + matchCryptoKeyFromProjectLocationKeyRingCryptoKeyProtectedResourcesSummaryName( + projectLocationKeyRingCryptoKeyProtectedResourcesSummaryName: string, + ) { + return this.pathTemplates.projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPathTemplate.match( + projectLocationKeyRingCryptoKeyProtectedResourcesSummaryName, + ).crypto_key; } /** @@ -988,7 +1150,13 @@ export class KeyDashboardServiceClient { * @param {string} crypto_key_version * @returns {string} Resource name string. */ - publicKeyPath(project:string,location:string,keyRing:string,cryptoKey:string,cryptoKeyVersion:string) { + publicKeyPath( + project: string, + location: string, + keyRing: string, + cryptoKey: string, + cryptoKeyVersion: string, + ) { return this.pathTemplates.publicKeyPathTemplate.render({ project: project, location: location, @@ -1006,7 +1174,8 @@ export class KeyDashboardServiceClient { * @returns {string} A string representing the project. */ matchProjectFromPublicKeyName(publicKeyName: string) { - return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName).project; + return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName) + .project; } /** @@ -1017,7 +1186,8 @@ export class KeyDashboardServiceClient { * @returns {string} A string representing the location. */ matchLocationFromPublicKeyName(publicKeyName: string) { - return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName).location; + return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName) + .location; } /** @@ -1028,7 +1198,8 @@ export class KeyDashboardServiceClient { * @returns {string} A string representing the key_ring. */ matchKeyRingFromPublicKeyName(publicKeyName: string) { - return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName).key_ring; + return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName) + .key_ring; } /** @@ -1039,7 +1210,8 @@ export class KeyDashboardServiceClient { * @returns {string} A string representing the crypto_key. */ matchCryptoKeyFromPublicKeyName(publicKeyName: string) { - return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName).crypto_key; + return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName) + .crypto_key; } /** @@ -1050,7 +1222,8 @@ export class KeyDashboardServiceClient { * @returns {string} A string representing the crypto_key_version. */ matchCryptoKeyVersionFromPublicKeyName(publicKeyName: string) { - return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName).crypto_key_version; + return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName) + .crypto_key_version; } /** @@ -1061,7 +1234,11 @@ export class KeyDashboardServiceClient { * @param {string} retired_resource * @returns {string} Resource name string. */ - retiredResourcePath(project:string,location:string,retiredResource:string) { + retiredResourcePath( + project: string, + location: string, + retiredResource: string, + ) { return this.pathTemplates.retiredResourcePathTemplate.render({ project: project, location: location, @@ -1077,7 +1254,9 @@ export class KeyDashboardServiceClient { * @returns {string} A string representing the project. */ matchProjectFromRetiredResourceName(retiredResourceName: string) { - return this.pathTemplates.retiredResourcePathTemplate.match(retiredResourceName).project; + return this.pathTemplates.retiredResourcePathTemplate.match( + retiredResourceName, + ).project; } /** @@ -1088,7 +1267,9 @@ export class KeyDashboardServiceClient { * @returns {string} A string representing the location. */ matchLocationFromRetiredResourceName(retiredResourceName: string) { - return this.pathTemplates.retiredResourcePathTemplate.match(retiredResourceName).location; + return this.pathTemplates.retiredResourcePathTemplate.match( + retiredResourceName, + ).location; } /** @@ -1099,7 +1280,9 @@ export class KeyDashboardServiceClient { * @returns {string} A string representing the retired_resource. */ matchRetiredResourceFromRetiredResourceName(retiredResourceName: string) { - return this.pathTemplates.retiredResourcePathTemplate.match(retiredResourceName).retired_resource; + return this.pathTemplates.retiredResourcePathTemplate.match( + retiredResourceName, + ).retired_resource; } /** @@ -1110,7 +1293,7 @@ export class KeyDashboardServiceClient { */ close(): Promise { if (this.keyDashboardServiceStub && !this._terminated) { - return this.keyDashboardServiceStub.then(stub => { + return this.keyDashboardServiceStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); @@ -1118,4 +1301,4 @@ export class KeyDashboardServiceClient { } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-kms-inventory/src/v1/key_tracking_service_client.ts b/packages/google-cloud-kms-inventory/src/v1/key_tracking_service_client.ts index 6abd35a14bc4..8f16ae6bd6c8 100644 --- a/packages/google-cloud-kms-inventory/src/v1/key_tracking_service_client.ts +++ b/packages/google-cloud-kms-inventory/src/v1/key_tracking_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 @@ -45,7 +52,7 @@ export class KeyTrackingServiceClient { 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('kms-inventory'); @@ -58,9 +65,9 @@ export class KeyTrackingServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - keyTrackingServiceStub?: Promise<{[name: string]: Function}>; + innerApiCalls: { [name: string]: Function }; + pathTemplates: { [name: string]: gax.PathTemplate }; + keyTrackingServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of KeyTrackingServiceClient. @@ -101,21 +108,42 @@ export class KeyTrackingServiceClient { * const client = new KeyTrackingServiceClient({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 KeyTrackingServiceClient; - 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 = 'kmsinventory.' + 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 KeyTrackingServiceClient { 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 KeyTrackingServiceClient { } // 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,34 +204,37 @@ export class KeyTrackingServiceClient { // Create useful helper objects for these. this.pathTemplates = { 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}', ), importJobPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/keyRings/{key_ring}/importJobs/{import_job}' + 'projects/{project}/locations/{location}/keyRings/{key_ring}/importJobs/{import_job}', ), keyRingPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/keyRings/{key_ring}' + 'projects/{project}/locations/{location}/keyRings/{key_ring}', ), organizationPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}' - ), - organizationProtectedResourceScopePathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/protectedResourceScope' - ), - projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}/protectedResourcesSummary' - ), - projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/protectedResourcesSummary' + 'organizations/{organization}', ), + organizationProtectedResourceScopePathTemplate: + new this._gaxModule.PathTemplate( + 'organizations/{organization}/protectedResourceScope', + ), + projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate: + new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}/protectedResourcesSummary', + ), + projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPathTemplate: + new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/protectedResourcesSummary', + ), publicKeyPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}/publicKey' + 'projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}/publicKey', ), retiredResourcePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/retiredResources/{retired_resource}' + 'projects/{project}/locations/{location}/retiredResources/{retired_resource}', ), }; @@ -214,14 +242,20 @@ export class KeyTrackingServiceClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - searchProtectedResources: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'protectedResources') + searchProtectedResources: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'protectedResources', + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.kms.inventory.v1.KeyTrackingService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.kms.inventory.v1.KeyTrackingService', + 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 +286,44 @@ export class KeyTrackingServiceClient { // Put together the "service stub" for // google.cloud.kms.inventory.v1.KeyTrackingService. this.keyTrackingServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.kms.inventory.v1.KeyTrackingService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.kms.inventory.v1.KeyTrackingService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.kms.inventory.v1.KeyTrackingService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.kms.inventory.v1 + .KeyTrackingService, + 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 keyTrackingServiceStubMethods = - ['getProtectedResourcesSummary', 'searchProtectedResources']; + const keyTrackingServiceStubMethods = [ + 'getProtectedResourcesSummary', + 'searchProtectedResources', + ]; for (const methodName of keyTrackingServiceStubMethods) { const callPromise = this.keyTrackingServiceStub.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 +338,14 @@ export class KeyTrackingServiceClient { * @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 'kmsinventory.googleapis.com'; } @@ -309,8 +356,14 @@ export class KeyTrackingServiceClient { * @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 'kmsinventory.googleapis.com'; } @@ -341,9 +394,7 @@ export class KeyTrackingServiceClient { * @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 +403,9 @@ export class KeyTrackingServiceClient { * 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,232 +416,306 @@ export class KeyTrackingServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Returns aggregate information about the resources protected by the given - * Cloud KMS {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey}. By default, - * summary of resources within the same Cloud organization as the key will be - * returned, which requires the KMS organization service account to be - * configured(refer - * https://docs.cloud.google.com/kms/docs/view-key-usage#required-roles). - * If the KMS organization service account is not configured or key's project - * is not part of an organization, set - * {@link protos.google.cloud.kms.inventory.v1.GetProtectedResourcesSummaryRequest.fallback_scope|fallback_scope} - * to `FALLBACK_SCOPE_PROJECT` to retrieve a summary of protected resources - * within the key's project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the - * {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey}. - * @param {google.cloud.kms.inventory.v1.FallbackScope} [request.fallbackScope] - * Optional. The scope to use if the kms organization service account is not - * configured. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.kms.inventory.v1.ProtectedResourcesSummary|ProtectedResourcesSummary}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/key_tracking_service.get_protected_resources_summary.js - * region_tag:kmsinventory_v1_generated_KeyTrackingService_GetProtectedResourcesSummary_async - */ + /** + * Returns aggregate information about the resources protected by the given + * Cloud KMS {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey}. By default, + * summary of resources within the same Cloud organization as the key will be + * returned, which requires the KMS organization service account to be + * configured(refer + * https://docs.cloud.google.com/kms/docs/view-key-usage#required-roles). + * If the KMS organization service account is not configured or key's project + * is not part of an organization, set + * {@link protos.google.cloud.kms.inventory.v1.GetProtectedResourcesSummaryRequest.fallback_scope|fallback_scope} + * to `FALLBACK_SCOPE_PROJECT` to retrieve a summary of protected resources + * within the key's project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the + * {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey}. + * @param {google.cloud.kms.inventory.v1.FallbackScope} [request.fallbackScope] + * Optional. The scope to use if the kms organization service account is not + * configured. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.kms.inventory.v1.ProtectedResourcesSummary|ProtectedResourcesSummary}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/key_tracking_service.get_protected_resources_summary.js + * region_tag:kmsinventory_v1_generated_KeyTrackingService_GetProtectedResourcesSummary_async + */ getProtectedResourcesSummary( - request?: protos.google.cloud.kms.inventory.v1.IGetProtectedResourcesSummaryRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.kms.inventory.v1.IProtectedResourcesSummary, - protos.google.cloud.kms.inventory.v1.IGetProtectedResourcesSummaryRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.kms.inventory.v1.IGetProtectedResourcesSummaryRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.kms.inventory.v1.IProtectedResourcesSummary, + ( + | protos.google.cloud.kms.inventory.v1.IGetProtectedResourcesSummaryRequest + | undefined + ), + {} | undefined, + ] + >; getProtectedResourcesSummary( - request: protos.google.cloud.kms.inventory.v1.IGetProtectedResourcesSummaryRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.kms.inventory.v1.IProtectedResourcesSummary, - protos.google.cloud.kms.inventory.v1.IGetProtectedResourcesSummaryRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.inventory.v1.IGetProtectedResourcesSummaryRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.kms.inventory.v1.IProtectedResourcesSummary, + | protos.google.cloud.kms.inventory.v1.IGetProtectedResourcesSummaryRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getProtectedResourcesSummary( - request: protos.google.cloud.kms.inventory.v1.IGetProtectedResourcesSummaryRequest, - callback: Callback< - protos.google.cloud.kms.inventory.v1.IProtectedResourcesSummary, - protos.google.cloud.kms.inventory.v1.IGetProtectedResourcesSummaryRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.inventory.v1.IGetProtectedResourcesSummaryRequest, + callback: Callback< + protos.google.cloud.kms.inventory.v1.IProtectedResourcesSummary, + | protos.google.cloud.kms.inventory.v1.IGetProtectedResourcesSummaryRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getProtectedResourcesSummary( - request?: protos.google.cloud.kms.inventory.v1.IGetProtectedResourcesSummaryRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.kms.inventory.v1.IProtectedResourcesSummary, - protos.google.cloud.kms.inventory.v1.IGetProtectedResourcesSummaryRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.kms.inventory.v1.IGetProtectedResourcesSummaryRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.kms.inventory.v1.IProtectedResourcesSummary, - protos.google.cloud.kms.inventory.v1.IGetProtectedResourcesSummaryRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.kms.inventory.v1.IProtectedResourcesSummary, - protos.google.cloud.kms.inventory.v1.IGetProtectedResourcesSummaryRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.kms.inventory.v1.IGetProtectedResourcesSummaryRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.kms.inventory.v1.IProtectedResourcesSummary, + | protos.google.cloud.kms.inventory.v1.IGetProtectedResourcesSummaryRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.kms.inventory.v1.IProtectedResourcesSummary, + ( + | protos.google.cloud.kms.inventory.v1.IGetProtectedResourcesSummaryRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getProtectedResourcesSummary request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.kms.inventory.v1.IProtectedResourcesSummary, - protos.google.cloud.kms.inventory.v1.IGetProtectedResourcesSummaryRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.kms.inventory.v1.IProtectedResourcesSummary, + | protos.google.cloud.kms.inventory.v1.IGetProtectedResourcesSummaryRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getProtectedResourcesSummary response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getProtectedResourcesSummary(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.kms.inventory.v1.IProtectedResourcesSummary, - protos.google.cloud.kms.inventory.v1.IGetProtectedResourcesSummaryRequest|undefined, - {}|undefined - ]) => { - this._log.info('getProtectedResourcesSummary response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getProtectedResourcesSummary(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.kms.inventory.v1.IProtectedResourcesSummary, + ( + | protos.google.cloud.kms.inventory.v1.IGetProtectedResourcesSummaryRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getProtectedResourcesSummary response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 metadata about the resources protected by the given Cloud KMS - * {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey} in the given Cloud - * organization/project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.scope - * Required. A scope can be an organization or a project. Resources protected - * by the crypto key in provided scope will be returned. - * - * The following values are allowed: - * - * * organizations/{ORGANIZATION_NUMBER} (e.g., "organizations/12345678") - * * projects/{PROJECT_ID} (e.g., "projects/foo-bar") - * * projects/{PROJECT_NUMBER} (e.g., "projects/12345678") - * @param {string} request.cryptoKey - * Required. The resource name of the - * {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey}. - * @param {number} request.pageSize - * The maximum number of resources to return. The service may return fewer - * than this value. - * If unspecified, at most 500 resources will be returned. - * The maximum value is 500; values above 500 will be coerced to 500. - * @param {string} request.pageToken - * A page token, received from a previous - * {@link protos.google.cloud.kms.inventory.v1.KeyTrackingService.SearchProtectedResources|KeyTrackingService.SearchProtectedResources} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link protos.google.cloud.kms.inventory.v1.KeyTrackingService.SearchProtectedResources|KeyTrackingService.SearchProtectedResources} - * must match the call that provided the page token. - * @param {string[]} [request.resourceTypes] - * Optional. A list of resource types that this request searches for. If - * empty, it will search all the [trackable resource - * types](https://cloud.google.com/kms/docs/view-key-usage#tracked-resource-types). - * - * Regular expressions are also supported. For example: - * - * * `compute.googleapis.com.*` snapshots resources whose type starts - * with `compute.googleapis.com`. - * * `.*Image` snapshots resources whose type ends with `Image`. - * * `.*Image.*` snapshots resources whose type contains `Image`. - * - * See [RE2](https://github.com/google/re2/wiki/Syntax) for all supported - * regular expression syntax. If the regular expression does not match any - * supported resource type, an INVALID_ARGUMENT 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 Array of {@link protos.google.cloud.kms.inventory.v1.ProtectedResource|ProtectedResource}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `searchProtectedResourcesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Returns metadata about the resources protected by the given Cloud KMS + * {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey} in the given Cloud + * organization/project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.scope + * Required. A scope can be an organization or a project. Resources protected + * by the crypto key in provided scope will be returned. + * + * The following values are allowed: + * + * * organizations/{ORGANIZATION_NUMBER} (e.g., "organizations/12345678") + * * projects/{PROJECT_ID} (e.g., "projects/foo-bar") + * * projects/{PROJECT_NUMBER} (e.g., "projects/12345678") + * @param {string} request.cryptoKey + * Required. The resource name of the + * {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey}. + * @param {number} request.pageSize + * The maximum number of resources to return. The service may return fewer + * than this value. + * If unspecified, at most 500 resources will be returned. + * The maximum value is 500; values above 500 will be coerced to 500. + * @param {string} request.pageToken + * A page token, received from a previous + * {@link protos.google.cloud.kms.inventory.v1.KeyTrackingService.SearchProtectedResources|KeyTrackingService.SearchProtectedResources} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link protos.google.cloud.kms.inventory.v1.KeyTrackingService.SearchProtectedResources|KeyTrackingService.SearchProtectedResources} + * must match the call that provided the page token. + * @param {string[]} [request.resourceTypes] + * Optional. A list of resource types that this request searches for. If + * empty, it will search all the [trackable resource + * types](https://cloud.google.com/kms/docs/view-key-usage#tracked-resource-types). + * + * Regular expressions are also supported. For example: + * + * * `compute.googleapis.com.*` snapshots resources whose type starts + * with `compute.googleapis.com`. + * * `.*Image` snapshots resources whose type ends with `Image`. + * * `.*Image.*` snapshots resources whose type contains `Image`. + * + * See [RE2](https://github.com/google/re2/wiki/Syntax) for all supported + * regular expression syntax. If the regular expression does not match any + * supported resource type, an INVALID_ARGUMENT 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 Array of {@link protos.google.cloud.kms.inventory.v1.ProtectedResource|ProtectedResource}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `searchProtectedResourcesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ searchProtectedResources( - request?: protos.google.cloud.kms.inventory.v1.ISearchProtectedResourcesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.kms.inventory.v1.IProtectedResource[], - protos.google.cloud.kms.inventory.v1.ISearchProtectedResourcesRequest|null, - protos.google.cloud.kms.inventory.v1.ISearchProtectedResourcesResponse - ]>; + request?: protos.google.cloud.kms.inventory.v1.ISearchProtectedResourcesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.kms.inventory.v1.IProtectedResource[], + protos.google.cloud.kms.inventory.v1.ISearchProtectedResourcesRequest | null, + protos.google.cloud.kms.inventory.v1.ISearchProtectedResourcesResponse, + ] + >; searchProtectedResources( - request: protos.google.cloud.kms.inventory.v1.ISearchProtectedResourcesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.kms.inventory.v1.ISearchProtectedResourcesRequest, - protos.google.cloud.kms.inventory.v1.ISearchProtectedResourcesResponse|null|undefined, - protos.google.cloud.kms.inventory.v1.IProtectedResource>): void; + request: protos.google.cloud.kms.inventory.v1.ISearchProtectedResourcesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.kms.inventory.v1.ISearchProtectedResourcesRequest, + | protos.google.cloud.kms.inventory.v1.ISearchProtectedResourcesResponse + | null + | undefined, + protos.google.cloud.kms.inventory.v1.IProtectedResource + >, + ): void; searchProtectedResources( - request: protos.google.cloud.kms.inventory.v1.ISearchProtectedResourcesRequest, - callback: PaginationCallback< - protos.google.cloud.kms.inventory.v1.ISearchProtectedResourcesRequest, - protos.google.cloud.kms.inventory.v1.ISearchProtectedResourcesResponse|null|undefined, - protos.google.cloud.kms.inventory.v1.IProtectedResource>): void; + request: protos.google.cloud.kms.inventory.v1.ISearchProtectedResourcesRequest, + callback: PaginationCallback< + protos.google.cloud.kms.inventory.v1.ISearchProtectedResourcesRequest, + | protos.google.cloud.kms.inventory.v1.ISearchProtectedResourcesResponse + | null + | undefined, + protos.google.cloud.kms.inventory.v1.IProtectedResource + >, + ): void; searchProtectedResources( - request?: protos.google.cloud.kms.inventory.v1.ISearchProtectedResourcesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< + request?: protos.google.cloud.kms.inventory.v1.ISearchProtectedResourcesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.kms.inventory.v1.ISearchProtectedResourcesRequest, - protos.google.cloud.kms.inventory.v1.ISearchProtectedResourcesResponse|null|undefined, - protos.google.cloud.kms.inventory.v1.IProtectedResource>, - callback?: PaginationCallback< - protos.google.cloud.kms.inventory.v1.ISearchProtectedResourcesRequest, - protos.google.cloud.kms.inventory.v1.ISearchProtectedResourcesResponse|null|undefined, - protos.google.cloud.kms.inventory.v1.IProtectedResource>): - Promise<[ - protos.google.cloud.kms.inventory.v1.IProtectedResource[], - protos.google.cloud.kms.inventory.v1.ISearchProtectedResourcesRequest|null, - protos.google.cloud.kms.inventory.v1.ISearchProtectedResourcesResponse - ]>|void { + | protos.google.cloud.kms.inventory.v1.ISearchProtectedResourcesResponse + | null + | undefined, + protos.google.cloud.kms.inventory.v1.IProtectedResource + >, + callback?: PaginationCallback< + protos.google.cloud.kms.inventory.v1.ISearchProtectedResourcesRequest, + | protos.google.cloud.kms.inventory.v1.ISearchProtectedResourcesResponse + | null + | undefined, + protos.google.cloud.kms.inventory.v1.IProtectedResource + >, + ): Promise< + [ + protos.google.cloud.kms.inventory.v1.IProtectedResource[], + protos.google.cloud.kms.inventory.v1.ISearchProtectedResourcesRequest | null, + protos.google.cloud.kms.inventory.v1.ISearchProtectedResourcesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'scope': request.scope ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + scope: request.scope ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.kms.inventory.v1.ISearchProtectedResourcesRequest, - protos.google.cloud.kms.inventory.v1.ISearchProtectedResourcesResponse|null|undefined, - protos.google.cloud.kms.inventory.v1.IProtectedResource>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.kms.inventory.v1.ISearchProtectedResourcesRequest, + | protos.google.cloud.kms.inventory.v1.ISearchProtectedResourcesResponse + | null + | undefined, + protos.google.cloud.kms.inventory.v1.IProtectedResource + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('searchProtectedResources values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -598,174 +724,178 @@ export class KeyTrackingServiceClient { this._log.info('searchProtectedResources request %j', request); return this.innerApiCalls .searchProtectedResources(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.kms.inventory.v1.IProtectedResource[], - protos.google.cloud.kms.inventory.v1.ISearchProtectedResourcesRequest|null, - protos.google.cloud.kms.inventory.v1.ISearchProtectedResourcesResponse - ]) => { - this._log.info('searchProtectedResources values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.kms.inventory.v1.IProtectedResource[], + protos.google.cloud.kms.inventory.v1.ISearchProtectedResourcesRequest | null, + protos.google.cloud.kms.inventory.v1.ISearchProtectedResourcesResponse, + ]) => { + this._log.info('searchProtectedResources values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `searchProtectedResources`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.scope - * Required. A scope can be an organization or a project. Resources protected - * by the crypto key in provided scope will be returned. - * - * The following values are allowed: - * - * * organizations/{ORGANIZATION_NUMBER} (e.g., "organizations/12345678") - * * projects/{PROJECT_ID} (e.g., "projects/foo-bar") - * * projects/{PROJECT_NUMBER} (e.g., "projects/12345678") - * @param {string} request.cryptoKey - * Required. The resource name of the - * {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey}. - * @param {number} request.pageSize - * The maximum number of resources to return. The service may return fewer - * than this value. - * If unspecified, at most 500 resources will be returned. - * The maximum value is 500; values above 500 will be coerced to 500. - * @param {string} request.pageToken - * A page token, received from a previous - * {@link protos.google.cloud.kms.inventory.v1.KeyTrackingService.SearchProtectedResources|KeyTrackingService.SearchProtectedResources} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link protos.google.cloud.kms.inventory.v1.KeyTrackingService.SearchProtectedResources|KeyTrackingService.SearchProtectedResources} - * must match the call that provided the page token. - * @param {string[]} [request.resourceTypes] - * Optional. A list of resource types that this request searches for. If - * empty, it will search all the [trackable resource - * types](https://cloud.google.com/kms/docs/view-key-usage#tracked-resource-types). - * - * Regular expressions are also supported. For example: - * - * * `compute.googleapis.com.*` snapshots resources whose type starts - * with `compute.googleapis.com`. - * * `.*Image` snapshots resources whose type ends with `Image`. - * * `.*Image.*` snapshots resources whose type contains `Image`. - * - * See [RE2](https://github.com/google/re2/wiki/Syntax) for all supported - * regular expression syntax. If the regular expression does not match any - * supported resource type, an INVALID_ARGUMENT 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 {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.kms.inventory.v1.ProtectedResource|ProtectedResource} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `searchProtectedResourcesAsync()` - * method described below for async iteration which you can stop as 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 `searchProtectedResources`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.scope + * Required. A scope can be an organization or a project. Resources protected + * by the crypto key in provided scope will be returned. + * + * The following values are allowed: + * + * * organizations/{ORGANIZATION_NUMBER} (e.g., "organizations/12345678") + * * projects/{PROJECT_ID} (e.g., "projects/foo-bar") + * * projects/{PROJECT_NUMBER} (e.g., "projects/12345678") + * @param {string} request.cryptoKey + * Required. The resource name of the + * {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey}. + * @param {number} request.pageSize + * The maximum number of resources to return. The service may return fewer + * than this value. + * If unspecified, at most 500 resources will be returned. + * The maximum value is 500; values above 500 will be coerced to 500. + * @param {string} request.pageToken + * A page token, received from a previous + * {@link protos.google.cloud.kms.inventory.v1.KeyTrackingService.SearchProtectedResources|KeyTrackingService.SearchProtectedResources} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link protos.google.cloud.kms.inventory.v1.KeyTrackingService.SearchProtectedResources|KeyTrackingService.SearchProtectedResources} + * must match the call that provided the page token. + * @param {string[]} [request.resourceTypes] + * Optional. A list of resource types that this request searches for. If + * empty, it will search all the [trackable resource + * types](https://cloud.google.com/kms/docs/view-key-usage#tracked-resource-types). + * + * Regular expressions are also supported. For example: + * + * * `compute.googleapis.com.*` snapshots resources whose type starts + * with `compute.googleapis.com`. + * * `.*Image` snapshots resources whose type ends with `Image`. + * * `.*Image.*` snapshots resources whose type contains `Image`. + * + * See [RE2](https://github.com/google/re2/wiki/Syntax) for all supported + * regular expression syntax. If the regular expression does not match any + * supported resource type, an INVALID_ARGUMENT 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 {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.kms.inventory.v1.ProtectedResource|ProtectedResource} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `searchProtectedResourcesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ searchProtectedResourcesStream( - request?: protos.google.cloud.kms.inventory.v1.ISearchProtectedResourcesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.kms.inventory.v1.ISearchProtectedResourcesRequest, + 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({ - 'scope': request.scope ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + scope: request.scope ?? '', + }); const defaultCallSettings = this._defaults['searchProtectedResources']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('searchProtectedResources stream %j', request); return this.descriptors.page.searchProtectedResources.createStream( this.innerApiCalls.searchProtectedResources as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `searchProtectedResources`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.scope - * Required. A scope can be an organization or a project. Resources protected - * by the crypto key in provided scope will be returned. - * - * The following values are allowed: - * - * * organizations/{ORGANIZATION_NUMBER} (e.g., "organizations/12345678") - * * projects/{PROJECT_ID} (e.g., "projects/foo-bar") - * * projects/{PROJECT_NUMBER} (e.g., "projects/12345678") - * @param {string} request.cryptoKey - * Required. The resource name of the - * {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey}. - * @param {number} request.pageSize - * The maximum number of resources to return. The service may return fewer - * than this value. - * If unspecified, at most 500 resources will be returned. - * The maximum value is 500; values above 500 will be coerced to 500. - * @param {string} request.pageToken - * A page token, received from a previous - * {@link protos.google.cloud.kms.inventory.v1.KeyTrackingService.SearchProtectedResources|KeyTrackingService.SearchProtectedResources} - * call. Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link protos.google.cloud.kms.inventory.v1.KeyTrackingService.SearchProtectedResources|KeyTrackingService.SearchProtectedResources} - * must match the call that provided the page token. - * @param {string[]} [request.resourceTypes] - * Optional. A list of resource types that this request searches for. If - * empty, it will search all the [trackable resource - * types](https://cloud.google.com/kms/docs/view-key-usage#tracked-resource-types). - * - * Regular expressions are also supported. For example: - * - * * `compute.googleapis.com.*` snapshots resources whose type starts - * with `compute.googleapis.com`. - * * `.*Image` snapshots resources whose type ends with `Image`. - * * `.*Image.*` snapshots resources whose type contains `Image`. - * - * See [RE2](https://github.com/google/re2/wiki/Syntax) for all supported - * regular expression syntax. If the regular expression does not match any - * supported resource type, an INVALID_ARGUMENT 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 {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.kms.inventory.v1.ProtectedResource|ProtectedResource}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@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/key_tracking_service.search_protected_resources.js - * region_tag:kmsinventory_v1_generated_KeyTrackingService_SearchProtectedResources_async - */ + /** + * Equivalent to `searchProtectedResources`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.scope + * Required. A scope can be an organization or a project. Resources protected + * by the crypto key in provided scope will be returned. + * + * The following values are allowed: + * + * * organizations/{ORGANIZATION_NUMBER} (e.g., "organizations/12345678") + * * projects/{PROJECT_ID} (e.g., "projects/foo-bar") + * * projects/{PROJECT_NUMBER} (e.g., "projects/12345678") + * @param {string} request.cryptoKey + * Required. The resource name of the + * {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey}. + * @param {number} request.pageSize + * The maximum number of resources to return. The service may return fewer + * than this value. + * If unspecified, at most 500 resources will be returned. + * The maximum value is 500; values above 500 will be coerced to 500. + * @param {string} request.pageToken + * A page token, received from a previous + * {@link protos.google.cloud.kms.inventory.v1.KeyTrackingService.SearchProtectedResources|KeyTrackingService.SearchProtectedResources} + * call. Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link protos.google.cloud.kms.inventory.v1.KeyTrackingService.SearchProtectedResources|KeyTrackingService.SearchProtectedResources} + * must match the call that provided the page token. + * @param {string[]} [request.resourceTypes] + * Optional. A list of resource types that this request searches for. If + * empty, it will search all the [trackable resource + * types](https://cloud.google.com/kms/docs/view-key-usage#tracked-resource-types). + * + * Regular expressions are also supported. For example: + * + * * `compute.googleapis.com.*` snapshots resources whose type starts + * with `compute.googleapis.com`. + * * `.*Image` snapshots resources whose type ends with `Image`. + * * `.*Image.*` snapshots resources whose type contains `Image`. + * + * See [RE2](https://github.com/google/re2/wiki/Syntax) for all supported + * regular expression syntax. If the regular expression does not match any + * supported resource type, an INVALID_ARGUMENT 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 {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.kms.inventory.v1.ProtectedResource|ProtectedResource}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@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/key_tracking_service.search_protected_resources.js + * region_tag:kmsinventory_v1_generated_KeyTrackingService_SearchProtectedResources_async + */ searchProtectedResourcesAsync( - request?: protos.google.cloud.kms.inventory.v1.ISearchProtectedResourcesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.kms.inventory.v1.ISearchProtectedResourcesRequest, + 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({ - 'scope': request.scope ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + scope: request.scope ?? '', + }); const defaultCallSettings = this._defaults['searchProtectedResources']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('searchProtectedResources iterate %j', request); return this.descriptors.page.searchProtectedResources.asyncIterate( this.innerApiCalls['searchProtectedResources'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } // -------------------- @@ -781,7 +911,12 @@ export class KeyTrackingServiceClient { * @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, @@ -798,7 +933,8 @@ export class KeyTrackingServiceClient { * @returns {string} A string representing the project. */ matchProjectFromCryptoKeyName(cryptoKeyName: string) { - return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName).project; + return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName) + .project; } /** @@ -809,7 +945,8 @@ export class KeyTrackingServiceClient { * @returns {string} A string representing the location. */ matchLocationFromCryptoKeyName(cryptoKeyName: string) { - return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName).location; + return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName) + .location; } /** @@ -820,7 +957,8 @@ export class KeyTrackingServiceClient { * @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; } /** @@ -831,7 +969,8 @@ export class KeyTrackingServiceClient { * @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; } /** @@ -844,7 +983,13 @@ export class KeyTrackingServiceClient { * @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, @@ -862,7 +1007,9 @@ export class KeyTrackingServiceClient { * @returns {string} A string representing the project. */ matchProjectFromCryptoKeyVersionName(cryptoKeyVersionName: string) { - return this.pathTemplates.cryptoKeyVersionPathTemplate.match(cryptoKeyVersionName).project; + return this.pathTemplates.cryptoKeyVersionPathTemplate.match( + cryptoKeyVersionName, + ).project; } /** @@ -873,7 +1020,9 @@ export class KeyTrackingServiceClient { * @returns {string} A string representing the location. */ matchLocationFromCryptoKeyVersionName(cryptoKeyVersionName: string) { - return this.pathTemplates.cryptoKeyVersionPathTemplate.match(cryptoKeyVersionName).location; + return this.pathTemplates.cryptoKeyVersionPathTemplate.match( + cryptoKeyVersionName, + ).location; } /** @@ -884,7 +1033,9 @@ export class KeyTrackingServiceClient { * @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; } /** @@ -895,7 +1046,9 @@ export class KeyTrackingServiceClient { * @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; } /** @@ -906,7 +1059,9 @@ export class KeyTrackingServiceClient { * @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; } /** @@ -918,7 +1073,12 @@ export class KeyTrackingServiceClient { * @param {string} import_job * @returns {string} Resource name string. */ - importJobPath(project:string,location:string,keyRing:string,importJob:string) { + importJobPath( + project: string, + location: string, + keyRing: string, + importJob: string, + ) { return this.pathTemplates.importJobPathTemplate.render({ project: project, location: location, @@ -935,7 +1095,8 @@ export class KeyTrackingServiceClient { * @returns {string} A string representing the project. */ matchProjectFromImportJobName(importJobName: string) { - return this.pathTemplates.importJobPathTemplate.match(importJobName).project; + return this.pathTemplates.importJobPathTemplate.match(importJobName) + .project; } /** @@ -946,7 +1107,8 @@ export class KeyTrackingServiceClient { * @returns {string} A string representing the location. */ matchLocationFromImportJobName(importJobName: string) { - return this.pathTemplates.importJobPathTemplate.match(importJobName).location; + return this.pathTemplates.importJobPathTemplate.match(importJobName) + .location; } /** @@ -957,7 +1119,8 @@ export class KeyTrackingServiceClient { * @returns {string} A string representing the key_ring. */ matchKeyRingFromImportJobName(importJobName: string) { - return this.pathTemplates.importJobPathTemplate.match(importJobName).key_ring; + return this.pathTemplates.importJobPathTemplate.match(importJobName) + .key_ring; } /** @@ -968,7 +1131,8 @@ export class KeyTrackingServiceClient { * @returns {string} A string representing the import_job. */ matchImportJobFromImportJobName(importJobName: string) { - return this.pathTemplates.importJobPathTemplate.match(importJobName).import_job; + return this.pathTemplates.importJobPathTemplate.match(importJobName) + .import_job; } /** @@ -979,7 +1143,7 @@ export class KeyTrackingServiceClient { * @param {string} key_ring * @returns {string} Resource name string. */ - keyRingPath(project:string,location:string,keyRing:string) { + keyRingPath(project: string, location: string, keyRing: string) { return this.pathTemplates.keyRingPathTemplate.render({ project: project, location: location, @@ -1026,7 +1190,7 @@ export class KeyTrackingServiceClient { * @param {string} organization * @returns {string} Resource name string. */ - organizationPath(organization:string) { + organizationPath(organization: string) { return this.pathTemplates.organizationPathTemplate.render({ organization: organization, }); @@ -1040,7 +1204,8 @@ export class KeyTrackingServiceClient { * @returns {string} A string representing the organization. */ matchOrganizationFromOrganizationName(organizationName: string) { - return this.pathTemplates.organizationPathTemplate.match(organizationName).organization; + return this.pathTemplates.organizationPathTemplate.match(organizationName) + .organization; } /** @@ -1049,10 +1214,12 @@ export class KeyTrackingServiceClient { * @param {string} organization * @returns {string} Resource name string. */ - organizationProtectedResourceScopePath(organization:string) { - return this.pathTemplates.organizationProtectedResourceScopePathTemplate.render({ - organization: organization, - }); + organizationProtectedResourceScopePath(organization: string) { + return this.pathTemplates.organizationProtectedResourceScopePathTemplate.render( + { + organization: organization, + }, + ); } /** @@ -1062,8 +1229,12 @@ export class KeyTrackingServiceClient { * A fully-qualified path representing organization_protectedResourceScope resource. * @returns {string} A string representing the organization. */ - matchOrganizationFromOrganizationProtectedResourceScopeName(organizationProtectedResourceScopeName: string) { - return this.pathTemplates.organizationProtectedResourceScopePathTemplate.match(organizationProtectedResourceScopeName).organization; + matchOrganizationFromOrganizationProtectedResourceScopeName( + organizationProtectedResourceScopeName: string, + ) { + return this.pathTemplates.organizationProtectedResourceScopePathTemplate.match( + organizationProtectedResourceScopeName, + ).organization; } /** @@ -1076,14 +1247,22 @@ export class KeyTrackingServiceClient { * @param {string} crypto_key_version * @returns {string} Resource name string. */ - projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPath(project:string,location:string,keyRing:string,cryptoKey:string,cryptoKeyVersion:string) { - return this.pathTemplates.projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate.render({ - project: project, - location: location, - key_ring: keyRing, - crypto_key: cryptoKey, - crypto_key_version: cryptoKeyVersion, - }); + projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPath( + project: string, + location: string, + keyRing: string, + cryptoKey: string, + cryptoKeyVersion: string, + ) { + return this.pathTemplates.projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate.render( + { + project: project, + location: location, + key_ring: keyRing, + crypto_key: cryptoKey, + crypto_key_version: cryptoKeyVersion, + }, + ); } /** @@ -1093,8 +1272,12 @@ export class KeyTrackingServiceClient { * A fully-qualified path representing project_location_key_ring_crypto_key_crypto_key_version_protectedResourcesSummary resource. * @returns {string} A string representing the project. */ - matchProjectFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName(projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName: string) { - return this.pathTemplates.projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate.match(projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName).project; + matchProjectFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName( + projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName: string, + ) { + return this.pathTemplates.projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate.match( + projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName, + ).project; } /** @@ -1104,8 +1287,12 @@ export class KeyTrackingServiceClient { * A fully-qualified path representing project_location_key_ring_crypto_key_crypto_key_version_protectedResourcesSummary resource. * @returns {string} A string representing the location. */ - matchLocationFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName(projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName: string) { - return this.pathTemplates.projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate.match(projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName).location; + matchLocationFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName( + projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName: string, + ) { + return this.pathTemplates.projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate.match( + projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName, + ).location; } /** @@ -1115,8 +1302,12 @@ export class KeyTrackingServiceClient { * A fully-qualified path representing project_location_key_ring_crypto_key_crypto_key_version_protectedResourcesSummary resource. * @returns {string} A string representing the key_ring. */ - matchKeyRingFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName(projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName: string) { - return this.pathTemplates.projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate.match(projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName).key_ring; + matchKeyRingFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName( + projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName: string, + ) { + return this.pathTemplates.projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate.match( + projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName, + ).key_ring; } /** @@ -1126,8 +1317,12 @@ export class KeyTrackingServiceClient { * A fully-qualified path representing project_location_key_ring_crypto_key_crypto_key_version_protectedResourcesSummary resource. * @returns {string} A string representing the crypto_key. */ - matchCryptoKeyFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName(projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName: string) { - return this.pathTemplates.projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate.match(projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName).crypto_key; + matchCryptoKeyFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName( + projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName: string, + ) { + return this.pathTemplates.projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate.match( + projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName, + ).crypto_key; } /** @@ -1137,8 +1332,12 @@ export class KeyTrackingServiceClient { * A fully-qualified path representing project_location_key_ring_crypto_key_crypto_key_version_protectedResourcesSummary resource. * @returns {string} A string representing the crypto_key_version. */ - matchCryptoKeyVersionFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName(projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName: string) { - return this.pathTemplates.projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate.match(projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName).crypto_key_version; + matchCryptoKeyVersionFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName( + projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName: string, + ) { + return this.pathTemplates.projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate.match( + projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName, + ).crypto_key_version; } /** @@ -1150,13 +1349,20 @@ export class KeyTrackingServiceClient { * @param {string} crypto_key * @returns {string} Resource name string. */ - projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPath(project:string,location:string,keyRing:string,cryptoKey:string) { - return this.pathTemplates.projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPathTemplate.render({ - project: project, - location: location, - key_ring: keyRing, - crypto_key: cryptoKey, - }); + projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPath( + project: string, + location: string, + keyRing: string, + cryptoKey: string, + ) { + return this.pathTemplates.projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPathTemplate.render( + { + project: project, + location: location, + key_ring: keyRing, + crypto_key: cryptoKey, + }, + ); } /** @@ -1166,8 +1372,12 @@ export class KeyTrackingServiceClient { * A fully-qualified path representing project_location_key_ring_crypto_key_protectedResourcesSummary resource. * @returns {string} A string representing the project. */ - matchProjectFromProjectLocationKeyRingCryptoKeyProtectedResourcesSummaryName(projectLocationKeyRingCryptoKeyProtectedResourcesSummaryName: string) { - return this.pathTemplates.projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPathTemplate.match(projectLocationKeyRingCryptoKeyProtectedResourcesSummaryName).project; + matchProjectFromProjectLocationKeyRingCryptoKeyProtectedResourcesSummaryName( + projectLocationKeyRingCryptoKeyProtectedResourcesSummaryName: string, + ) { + return this.pathTemplates.projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPathTemplate.match( + projectLocationKeyRingCryptoKeyProtectedResourcesSummaryName, + ).project; } /** @@ -1177,8 +1387,12 @@ export class KeyTrackingServiceClient { * A fully-qualified path representing project_location_key_ring_crypto_key_protectedResourcesSummary resource. * @returns {string} A string representing the location. */ - matchLocationFromProjectLocationKeyRingCryptoKeyProtectedResourcesSummaryName(projectLocationKeyRingCryptoKeyProtectedResourcesSummaryName: string) { - return this.pathTemplates.projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPathTemplate.match(projectLocationKeyRingCryptoKeyProtectedResourcesSummaryName).location; + matchLocationFromProjectLocationKeyRingCryptoKeyProtectedResourcesSummaryName( + projectLocationKeyRingCryptoKeyProtectedResourcesSummaryName: string, + ) { + return this.pathTemplates.projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPathTemplate.match( + projectLocationKeyRingCryptoKeyProtectedResourcesSummaryName, + ).location; } /** @@ -1188,8 +1402,12 @@ export class KeyTrackingServiceClient { * A fully-qualified path representing project_location_key_ring_crypto_key_protectedResourcesSummary resource. * @returns {string} A string representing the key_ring. */ - matchKeyRingFromProjectLocationKeyRingCryptoKeyProtectedResourcesSummaryName(projectLocationKeyRingCryptoKeyProtectedResourcesSummaryName: string) { - return this.pathTemplates.projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPathTemplate.match(projectLocationKeyRingCryptoKeyProtectedResourcesSummaryName).key_ring; + matchKeyRingFromProjectLocationKeyRingCryptoKeyProtectedResourcesSummaryName( + projectLocationKeyRingCryptoKeyProtectedResourcesSummaryName: string, + ) { + return this.pathTemplates.projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPathTemplate.match( + projectLocationKeyRingCryptoKeyProtectedResourcesSummaryName, + ).key_ring; } /** @@ -1199,8 +1417,12 @@ export class KeyTrackingServiceClient { * A fully-qualified path representing project_location_key_ring_crypto_key_protectedResourcesSummary resource. * @returns {string} A string representing the crypto_key. */ - matchCryptoKeyFromProjectLocationKeyRingCryptoKeyProtectedResourcesSummaryName(projectLocationKeyRingCryptoKeyProtectedResourcesSummaryName: string) { - return this.pathTemplates.projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPathTemplate.match(projectLocationKeyRingCryptoKeyProtectedResourcesSummaryName).crypto_key; + matchCryptoKeyFromProjectLocationKeyRingCryptoKeyProtectedResourcesSummaryName( + projectLocationKeyRingCryptoKeyProtectedResourcesSummaryName: string, + ) { + return this.pathTemplates.projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPathTemplate.match( + projectLocationKeyRingCryptoKeyProtectedResourcesSummaryName, + ).crypto_key; } /** @@ -1213,7 +1435,13 @@ export class KeyTrackingServiceClient { * @param {string} crypto_key_version * @returns {string} Resource name string. */ - publicKeyPath(project:string,location:string,keyRing:string,cryptoKey:string,cryptoKeyVersion:string) { + publicKeyPath( + project: string, + location: string, + keyRing: string, + cryptoKey: string, + cryptoKeyVersion: string, + ) { return this.pathTemplates.publicKeyPathTemplate.render({ project: project, location: location, @@ -1231,7 +1459,8 @@ export class KeyTrackingServiceClient { * @returns {string} A string representing the project. */ matchProjectFromPublicKeyName(publicKeyName: string) { - return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName).project; + return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName) + .project; } /** @@ -1242,7 +1471,8 @@ export class KeyTrackingServiceClient { * @returns {string} A string representing the location. */ matchLocationFromPublicKeyName(publicKeyName: string) { - return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName).location; + return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName) + .location; } /** @@ -1253,7 +1483,8 @@ export class KeyTrackingServiceClient { * @returns {string} A string representing the key_ring. */ matchKeyRingFromPublicKeyName(publicKeyName: string) { - return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName).key_ring; + return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName) + .key_ring; } /** @@ -1264,7 +1495,8 @@ export class KeyTrackingServiceClient { * @returns {string} A string representing the crypto_key. */ matchCryptoKeyFromPublicKeyName(publicKeyName: string) { - return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName).crypto_key; + return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName) + .crypto_key; } /** @@ -1275,7 +1507,8 @@ export class KeyTrackingServiceClient { * @returns {string} A string representing the crypto_key_version. */ matchCryptoKeyVersionFromPublicKeyName(publicKeyName: string) { - return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName).crypto_key_version; + return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName) + .crypto_key_version; } /** @@ -1286,7 +1519,11 @@ export class KeyTrackingServiceClient { * @param {string} retired_resource * @returns {string} Resource name string. */ - retiredResourcePath(project:string,location:string,retiredResource:string) { + retiredResourcePath( + project: string, + location: string, + retiredResource: string, + ) { return this.pathTemplates.retiredResourcePathTemplate.render({ project: project, location: location, @@ -1302,7 +1539,9 @@ export class KeyTrackingServiceClient { * @returns {string} A string representing the project. */ matchProjectFromRetiredResourceName(retiredResourceName: string) { - return this.pathTemplates.retiredResourcePathTemplate.match(retiredResourceName).project; + return this.pathTemplates.retiredResourcePathTemplate.match( + retiredResourceName, + ).project; } /** @@ -1313,7 +1552,9 @@ export class KeyTrackingServiceClient { * @returns {string} A string representing the location. */ matchLocationFromRetiredResourceName(retiredResourceName: string) { - return this.pathTemplates.retiredResourcePathTemplate.match(retiredResourceName).location; + return this.pathTemplates.retiredResourcePathTemplate.match( + retiredResourceName, + ).location; } /** @@ -1324,7 +1565,9 @@ export class KeyTrackingServiceClient { * @returns {string} A string representing the retired_resource. */ matchRetiredResourceFromRetiredResourceName(retiredResourceName: string) { - return this.pathTemplates.retiredResourcePathTemplate.match(retiredResourceName).retired_resource; + return this.pathTemplates.retiredResourcePathTemplate.match( + retiredResourceName, + ).retired_resource; } /** @@ -1335,7 +1578,7 @@ export class KeyTrackingServiceClient { */ close(): Promise { if (this.keyTrackingServiceStub && !this._terminated) { - return this.keyTrackingServiceStub.then(stub => { + return this.keyTrackingServiceStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); @@ -1343,4 +1586,4 @@ export class KeyTrackingServiceClient { } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-kms-inventory/system-test/fixtures/sample/src/index.ts b/packages/google-cloud-kms-inventory/system-test/fixtures/sample/src/index.ts index 5e3859c1f24c..0656015993c9 100644 --- a/packages/google-cloud-kms-inventory/system-test/fixtures/sample/src/index.ts +++ b/packages/google-cloud-kms-inventory/system-test/fixtures/sample/src/index.ts @@ -16,10 +16,15 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -import {KeyDashboardServiceClient, KeyTrackingServiceClient} from '@google-cloud/kms-inventory'; +import { + KeyDashboardServiceClient, + KeyTrackingServiceClient, +} from '@google-cloud/kms-inventory'; // check that the client class type name can be used -function doStuffWithKeyDashboardServiceClient(client: KeyDashboardServiceClient) { +function doStuffWithKeyDashboardServiceClient( + client: KeyDashboardServiceClient, +) { client.close(); } function doStuffWithKeyTrackingServiceClient(client: KeyTrackingServiceClient) { diff --git a/packages/google-cloud-kms-inventory/system-test/install.ts b/packages/google-cloud-kms-inventory/system-test/install.ts index f66069aa3940..ccf167042d2e 100644 --- a/packages/google-cloud-kms-inventory/system-test/install.ts +++ b/packages/google-cloud-kms-inventory/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-kms-inventory/test/gapic_key_dashboard_service_v1.ts b/packages/google-cloud-kms-inventory/test/gapic_key_dashboard_service_v1.ts index d1db9b2b1e62..b0e4abdbe8fe 100644 --- a/packages/google-cloud-kms-inventory/test/gapic_key_dashboard_service_v1.ts +++ b/packages/google-cloud-kms-inventory/test/gapic_key_dashboard_service_v1.ts @@ -19,961 +19,1384 @@ 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 keydashboardserviceModule 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.KeyDashboardServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new keydashboardserviceModule.v1.KeyDashboardServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'kmsinventory.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new keydashboardserviceModule.v1.KeyDashboardServiceClient(); - 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 = keydashboardserviceModule.v1.KeyDashboardServiceClient.servicePath; - assert.strictEqual(servicePath, 'kmsinventory.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = keydashboardserviceModule.v1.KeyDashboardServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'kmsinventory.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new keydashboardserviceModule.v1.KeyDashboardServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'kmsinventory.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new keydashboardserviceModule.v1.KeyDashboardServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'kmsinventory.example.com'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = + new keydashboardserviceModule.v1.KeyDashboardServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'kmsinventory.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 keydashboardserviceModule.v1.KeyDashboardServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'kmsinventory.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 keydashboardserviceModule.v1.KeyDashboardServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'kmsinventory.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 keydashboardserviceModule.v1.KeyDashboardServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); + it('has universeDomain', () => { + const client = + new keydashboardserviceModule.v1.KeyDashboardServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('has port', () => { - const port = keydashboardserviceModule.v1.KeyDashboardServiceClient.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 = + keydashboardserviceModule.v1.KeyDashboardServiceClient.servicePath; + assert.strictEqual(servicePath, 'kmsinventory.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + keydashboardserviceModule.v1.KeyDashboardServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'kmsinventory.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new keydashboardserviceModule.v1.KeyDashboardServiceClient( + { universeDomain: 'example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'kmsinventory.example.com'); + }); - it('should create a client with no option', () => { - const client = new keydashboardserviceModule.v1.KeyDashboardServiceClient(); - assert(client); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new keydashboardserviceModule.v1.KeyDashboardServiceClient( + { universe_domain: 'example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'kmsinventory.example.com'); + }); - it('should create a client with gRPC fallback', () => { - const client = new keydashboardserviceModule.v1.KeyDashboardServiceClient({ - 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 keydashboardserviceModule.v1.KeyDashboardServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'kmsinventory.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 keydashboardserviceModule.v1.KeyDashboardServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.keyDashboardServiceStub, undefined); - await client.initialize(); - assert(client.keyDashboardServiceStub); + 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 keydashboardserviceModule.v1.KeyDashboardServiceClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual( + servicePath, + 'kmsinventory.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 keydashboardserviceModule.v1.KeyDashboardServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.keyDashboardServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new keydashboardserviceModule.v1.KeyDashboardServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('has close method for the non-initialized client', done => { - const client = new keydashboardserviceModule.v1.KeyDashboardServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.keyDashboardServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has port', () => { + const port = keydashboardserviceModule.v1.KeyDashboardServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new keydashboardserviceModule.v1.KeyDashboardServiceClient({ - 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 keydashboardserviceModule.v1.KeyDashboardServiceClient(); + assert(client); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new keydashboardserviceModule.v1.KeyDashboardServiceClient({ - 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 keydashboardserviceModule.v1.KeyDashboardServiceClient( + { + fallback: true, + }, + ); + assert(client); }); - describe('listCryptoKeys', () => { - it('invokes listCryptoKeys without error', async () => { - const client = new keydashboardserviceModule.v1.KeyDashboardServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.inventory.v1.ListCryptoKeysRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.inventory.v1.ListCryptoKeysRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKey()), - generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKey()), - generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKey()), - ]; - client.innerApiCalls.listCryptoKeys = stubSimpleCall(expectedResponse); - const [response] = await client.listCryptoKeys(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listCryptoKeys as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCryptoKeys 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 keydashboardserviceModule.v1.KeyDashboardServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + assert.strictEqual(client.keyDashboardServiceStub, undefined); + await client.initialize(); + assert(client.keyDashboardServiceStub); + }); - it('invokes listCryptoKeys without error using callback', async () => { - const client = new keydashboardserviceModule.v1.KeyDashboardServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.inventory.v1.ListCryptoKeysRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.inventory.v1.ListCryptoKeysRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKey()), - generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKey()), - generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKey()), - ]; - client.innerApiCalls.listCryptoKeys = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listCryptoKeys( - request, - (err?: Error|null, result?: protos.google.cloud.kms.v1.ICryptoKey[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listCryptoKeys as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCryptoKeys 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 keydashboardserviceModule.v1.KeyDashboardServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + client.initialize().catch((err) => { + throw err; + }); + assert(client.keyDashboardServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes listCryptoKeys with error', async () => { - const client = new keydashboardserviceModule.v1.KeyDashboardServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.inventory.v1.ListCryptoKeysRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.inventory.v1.ListCryptoKeysRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listCryptoKeys = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listCryptoKeys(request), expectedError); - const actualRequest = (client.innerApiCalls.listCryptoKeys as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCryptoKeys 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 keydashboardserviceModule.v1.KeyDashboardServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + assert.strictEqual(client.keyDashboardServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes listCryptoKeysStream without error', async () => { - const client = new keydashboardserviceModule.v1.KeyDashboardServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.inventory.v1.ListCryptoKeysRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.inventory.v1.ListCryptoKeysRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKey()), - generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKey()), - generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKey()), - ]; - client.descriptors.page.listCryptoKeys.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listCryptoKeysStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.kms.v1.CryptoKey[] = []; - stream.on('data', (response: protos.google.cloud.kms.v1.CryptoKey) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listCryptoKeys.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listCryptoKeys, request)); - assert( - (client.descriptors.page.listCryptoKeys.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new keydashboardserviceModule.v1.KeyDashboardServiceClient( + { + 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 listCryptoKeysStream with error', async () => { - const client = new keydashboardserviceModule.v1.KeyDashboardServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.inventory.v1.ListCryptoKeysRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.inventory.v1.ListCryptoKeysRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listCryptoKeys.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listCryptoKeysStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.kms.v1.CryptoKey[] = []; - stream.on('data', (response: protos.google.cloud.kms.v1.CryptoKey) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listCryptoKeys.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listCryptoKeys, request)); - assert( - (client.descriptors.page.listCryptoKeys.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new keydashboardserviceModule.v1.KeyDashboardServiceClient( + { + 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('listCryptoKeys', () => { + it('invokes listCryptoKeys without error', async () => { + const client = new keydashboardserviceModule.v1.KeyDashboardServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.inventory.v1.ListCryptoKeysRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.inventory.v1.ListCryptoKeysRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKey()), + generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKey()), + generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKey()), + ]; + client.innerApiCalls.listCryptoKeys = stubSimpleCall(expectedResponse); + const [response] = await client.listCryptoKeys(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listCryptoKeys as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCryptoKeys as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listCryptoKeys without error', async () => { - const client = new keydashboardserviceModule.v1.KeyDashboardServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.inventory.v1.ListCryptoKeysRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.inventory.v1.ListCryptoKeysRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKey()), - generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKey()), - generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKey()), - ]; - client.descriptors.page.listCryptoKeys.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.kms.v1.ICryptoKey[] = []; - const iterable = client.listCryptoKeysAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listCryptoKeys without error using callback', async () => { + const client = new keydashboardserviceModule.v1.KeyDashboardServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.inventory.v1.ListCryptoKeysRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.inventory.v1.ListCryptoKeysRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKey()), + generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKey()), + generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKey()), + ]; + client.innerApiCalls.listCryptoKeys = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listCryptoKeys( + request, + ( + err?: Error | null, + result?: protos.google.cloud.kms.v1.ICryptoKey[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listCryptoKeys.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listCryptoKeys.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listCryptoKeys with error', async () => { - const client = new keydashboardserviceModule.v1.KeyDashboardServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.inventory.v1.ListCryptoKeysRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.inventory.v1.ListCryptoKeysRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listCryptoKeys.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listCryptoKeysAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.kms.v1.ICryptoKey[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listCryptoKeys.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listCryptoKeys.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.listCryptoKeys as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCryptoKeys as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('Path templates', () => { - - describe('cryptoKey', async () => { - const fakePath = "/rendered/path/cryptoKey"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - key_ring: "keyRingValue", - crypto_key: "cryptoKeyValue", - }; - const client = new keydashboardserviceModule.v1.KeyDashboardServiceClient({ - 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 keydashboardserviceModule.v1.KeyDashboardServiceClient({ - 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('invokes listCryptoKeys with error', async () => { + const client = new keydashboardserviceModule.v1.KeyDashboardServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.inventory.v1.ListCryptoKeysRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.inventory.v1.ListCryptoKeysRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listCryptoKeys = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listCryptoKeys(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listCryptoKeys as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCryptoKeys as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchCryptoKeyVersionFromCryptoKeyVersionName', () => { - const result = client.matchCryptoKeyVersionFromCryptoKeyVersionName(fakePath); - assert.strictEqual(result, "cryptoKeyVersionValue"); - assert((client.pathTemplates.cryptoKeyVersionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes listCryptoKeysStream without error', async () => { + const client = new keydashboardserviceModule.v1.KeyDashboardServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.inventory.v1.ListCryptoKeysRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.inventory.v1.ListCryptoKeysRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKey()), + generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKey()), + generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKey()), + ]; + client.descriptors.page.listCryptoKeys.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listCryptoKeysStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.kms.v1.CryptoKey[] = []; + stream.on('data', (response: protos.google.cloud.kms.v1.CryptoKey) => { + responses.push(response); }); - - describe('importJob', async () => { - const fakePath = "/rendered/path/importJob"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - key_ring: "keyRingValue", - import_job: "importJobValue", - }; - const client = new keydashboardserviceModule.v1.KeyDashboardServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.importJobPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.importJobPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('importJobPath', () => { - const result = client.importJobPath("projectValue", "locationValue", "keyRingValue", "importJobValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.importJobPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromImportJobName', () => { - const result = client.matchProjectFromImportJobName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.importJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromImportJobName', () => { - const result = client.matchLocationFromImportJobName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.importJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchKeyRingFromImportJobName', () => { - const result = client.matchKeyRingFromImportJobName(fakePath); - assert.strictEqual(result, "keyRingValue"); - assert((client.pathTemplates.importJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchImportJobFromImportJobName', () => { - const result = client.matchImportJobFromImportJobName(fakePath); - assert.strictEqual(result, "importJobValue"); - assert((client.pathTemplates.importJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + stream.on('end', () => { + resolve(responses); }); - - describe('keyRing', async () => { - const fakePath = "/rendered/path/keyRing"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - key_ring: "keyRingValue", - }; - const client = new keydashboardserviceModule.v1.KeyDashboardServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.keyRingPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.keyRingPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('keyRingPath', () => { - const result = client.keyRingPath("projectValue", "locationValue", "keyRingValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.keyRingPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromKeyRingName', () => { - const result = client.matchProjectFromKeyRingName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.keyRingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromKeyRingName', () => { - const result = client.matchLocationFromKeyRingName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.keyRingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchKeyRingFromKeyRingName', () => { - const result = client.matchKeyRingFromKeyRingName(fakePath); - assert.strictEqual(result, "keyRingValue"); - assert((client.pathTemplates.keyRingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + stream.on('error', (err: Error) => { + reject(err); }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listCryptoKeys.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listCryptoKeys, request), + ); + assert( + (client.descriptors.page.listCryptoKeys.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - describe('project', async () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new keydashboardserviceModule.v1.KeyDashboardServiceClient({ - 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 listCryptoKeysStream with error', async () => { + const client = new keydashboardserviceModule.v1.KeyDashboardServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.inventory.v1.ListCryptoKeysRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.inventory.v1.ListCryptoKeysRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listCryptoKeys.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listCryptoKeysStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.kms.v1.CryptoKey[] = []; + stream.on('data', (response: protos.google.cloud.kms.v1.CryptoKey) => { + responses.push(response); }); - - describe('projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummary', async () => { - const fakePath = "/rendered/path/projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummary"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - key_ring: "keyRingValue", - crypto_key: "cryptoKeyValue", - crypto_key_version: "cryptoKeyVersionValue", - }; - const client = new keydashboardserviceModule.v1.KeyDashboardServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPath', () => { - const result = client.projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPath("projectValue", "locationValue", "keyRingValue", "cryptoKeyValue", "cryptoKeyVersionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName', () => { - const result = client.matchProjectFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName', () => { - const result = client.matchLocationFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchKeyRingFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName', () => { - const result = client.matchKeyRingFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName(fakePath); - assert.strictEqual(result, "keyRingValue"); - assert((client.pathTemplates.projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCryptoKeyFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName', () => { - const result = client.matchCryptoKeyFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName(fakePath); - assert.strictEqual(result, "cryptoKeyValue"); - assert((client.pathTemplates.projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCryptoKeyVersionFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName', () => { - const result = client.matchCryptoKeyVersionFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName(fakePath); - assert.strictEqual(result, "cryptoKeyVersionValue"); - assert((client.pathTemplates.projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + stream.on('end', () => { + resolve(responses); }); - - describe('projectLocationKeyRingCryptoKeyProtectedResourcesSummary', async () => { - const fakePath = "/rendered/path/projectLocationKeyRingCryptoKeyProtectedResourcesSummary"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - key_ring: "keyRingValue", - crypto_key: "cryptoKeyValue", - }; - const client = new keydashboardserviceModule.v1.KeyDashboardServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPath', () => { - const result = client.projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPath("projectValue", "locationValue", "keyRingValue", "cryptoKeyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationKeyRingCryptoKeyProtectedResourcesSummaryName', () => { - const result = client.matchProjectFromProjectLocationKeyRingCryptoKeyProtectedResourcesSummaryName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationKeyRingCryptoKeyProtectedResourcesSummaryName', () => { - const result = client.matchLocationFromProjectLocationKeyRingCryptoKeyProtectedResourcesSummaryName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchKeyRingFromProjectLocationKeyRingCryptoKeyProtectedResourcesSummaryName', () => { - const result = client.matchKeyRingFromProjectLocationKeyRingCryptoKeyProtectedResourcesSummaryName(fakePath); - assert.strictEqual(result, "keyRingValue"); - assert((client.pathTemplates.projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCryptoKeyFromProjectLocationKeyRingCryptoKeyProtectedResourcesSummaryName', () => { - const result = client.matchCryptoKeyFromProjectLocationKeyRingCryptoKeyProtectedResourcesSummaryName(fakePath); - assert.strictEqual(result, "cryptoKeyValue"); - assert((client.pathTemplates.projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + stream.on('error', (err: Error) => { + reject(err); }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listCryptoKeys.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listCryptoKeys, request), + ); + assert( + (client.descriptors.page.listCryptoKeys.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - describe('publicKey', async () => { - const fakePath = "/rendered/path/publicKey"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - key_ring: "keyRingValue", - crypto_key: "cryptoKeyValue", - crypto_key_version: "cryptoKeyVersionValue", - }; - const client = new keydashboardserviceModule.v1.KeyDashboardServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.publicKeyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.publicKeyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('publicKeyPath', () => { - const result = client.publicKeyPath("projectValue", "locationValue", "keyRingValue", "cryptoKeyValue", "cryptoKeyVersionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.publicKeyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('uses async iteration with listCryptoKeys without error', async () => { + const client = new keydashboardserviceModule.v1.KeyDashboardServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.inventory.v1.ListCryptoKeysRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.inventory.v1.ListCryptoKeysRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKey()), + generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKey()), + generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKey()), + ]; + client.descriptors.page.listCryptoKeys.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.kms.v1.ICryptoKey[] = []; + const iterable = client.listCryptoKeysAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listCryptoKeys.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listCryptoKeys.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('matchProjectFromPublicKeyName', () => { - const result = client.matchProjectFromPublicKeyName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.publicKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('uses async iteration with listCryptoKeys with error', async () => { + const client = new keydashboardserviceModule.v1.KeyDashboardServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.inventory.v1.ListCryptoKeysRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.inventory.v1.ListCryptoKeysRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listCryptoKeys.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listCryptoKeysAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.kms.v1.ICryptoKey[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listCryptoKeys.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listCryptoKeys.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('Path templates', () => { + describe('cryptoKey', async () => { + const fakePath = '/rendered/path/cryptoKey'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + key_ring: 'keyRingValue', + crypto_key: 'cryptoKeyValue', + }; + const client = new keydashboardserviceModule.v1.KeyDashboardServiceClient( + { + 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), + ); + }); + }); - it('matchLocationFromPublicKeyName', () => { - const result = client.matchLocationFromPublicKeyName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.publicKeyPathTemplate.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 keydashboardserviceModule.v1.KeyDashboardServiceClient( + { + 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), + ); + }); + }); - it('matchKeyRingFromPublicKeyName', () => { - const result = client.matchKeyRingFromPublicKeyName(fakePath); - assert.strictEqual(result, "keyRingValue"); - assert((client.pathTemplates.publicKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('importJob', async () => { + const fakePath = '/rendered/path/importJob'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + key_ring: 'keyRingValue', + import_job: 'importJobValue', + }; + const client = new keydashboardserviceModule.v1.KeyDashboardServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.importJobPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.importJobPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('importJobPath', () => { + const result = client.importJobPath( + 'projectValue', + 'locationValue', + 'keyRingValue', + 'importJobValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.importJobPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromImportJobName', () => { + const result = client.matchProjectFromImportJobName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.importJobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromImportJobName', () => { + const result = client.matchLocationFromImportJobName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.importJobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchKeyRingFromImportJobName', () => { + const result = client.matchKeyRingFromImportJobName(fakePath); + assert.strictEqual(result, 'keyRingValue'); + assert( + (client.pathTemplates.importJobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchImportJobFromImportJobName', () => { + const result = client.matchImportJobFromImportJobName(fakePath); + assert.strictEqual(result, 'importJobValue'); + assert( + (client.pathTemplates.importJobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchCryptoKeyFromPublicKeyName', () => { - const result = client.matchCryptoKeyFromPublicKeyName(fakePath); - assert.strictEqual(result, "cryptoKeyValue"); - assert((client.pathTemplates.publicKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('keyRing', async () => { + const fakePath = '/rendered/path/keyRing'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + key_ring: 'keyRingValue', + }; + const client = new keydashboardserviceModule.v1.KeyDashboardServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.keyRingPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.keyRingPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('keyRingPath', () => { + const result = client.keyRingPath( + 'projectValue', + 'locationValue', + 'keyRingValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.keyRingPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromKeyRingName', () => { + const result = client.matchProjectFromKeyRingName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.keyRingPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromKeyRingName', () => { + const result = client.matchLocationFromKeyRingName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.keyRingPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchKeyRingFromKeyRingName', () => { + const result = client.matchKeyRingFromKeyRingName(fakePath); + assert.strictEqual(result, 'keyRingValue'); + assert( + (client.pathTemplates.keyRingPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchCryptoKeyVersionFromPublicKeyName', () => { - const result = client.matchCryptoKeyVersionFromPublicKeyName(fakePath); - assert.strictEqual(result, "cryptoKeyVersionValue"); - assert((client.pathTemplates.publicKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('project', async () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = new keydashboardserviceModule.v1.KeyDashboardServiceClient( + { + 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('retiredResource', async () => { - const fakePath = "/rendered/path/retiredResource"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - retired_resource: "retiredResourceValue", - }; - const client = new keydashboardserviceModule.v1.KeyDashboardServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.retiredResourcePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.retiredResourcePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('retiredResourcePath', () => { - const result = client.retiredResourcePath("projectValue", "locationValue", "retiredResourceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.retiredResourcePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + describe('projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummary', async () => { + const fakePath = + '/rendered/path/projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummary'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + key_ring: 'keyRingValue', + crypto_key: 'cryptoKeyValue', + crypto_key_version: 'cryptoKeyVersionValue', + }; + const client = new keydashboardserviceModule.v1.KeyDashboardServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPath', () => { + const result = + client.projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPath( + 'projectValue', + 'locationValue', + 'keyRingValue', + 'cryptoKeyValue', + 'cryptoKeyVersionValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates + .projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName', () => { + const result = + client.matchProjectFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName( + fakePath, + ); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates + .projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName', () => { + const result = + client.matchLocationFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName( + fakePath, + ); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates + .projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchKeyRingFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName', () => { + const result = + client.matchKeyRingFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName( + fakePath, + ); + assert.strictEqual(result, 'keyRingValue'); + assert( + ( + client.pathTemplates + .projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCryptoKeyFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName', () => { + const result = + client.matchCryptoKeyFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName( + fakePath, + ); + assert.strictEqual(result, 'cryptoKeyValue'); + assert( + ( + client.pathTemplates + .projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCryptoKeyVersionFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName', () => { + const result = + client.matchCryptoKeyVersionFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName( + fakePath, + ); + assert.strictEqual(result, 'cryptoKeyVersionValue'); + assert( + ( + client.pathTemplates + .projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchProjectFromRetiredResourceName', () => { - const result = client.matchProjectFromRetiredResourceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.retiredResourcePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('projectLocationKeyRingCryptoKeyProtectedResourcesSummary', async () => { + const fakePath = + '/rendered/path/projectLocationKeyRingCryptoKeyProtectedResourcesSummary'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + key_ring: 'keyRingValue', + crypto_key: 'cryptoKeyValue', + }; + const client = new keydashboardserviceModule.v1.KeyDashboardServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPath', () => { + const result = + client.projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPath( + 'projectValue', + 'locationValue', + 'keyRingValue', + 'cryptoKeyValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates + .projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectLocationKeyRingCryptoKeyProtectedResourcesSummaryName', () => { + const result = + client.matchProjectFromProjectLocationKeyRingCryptoKeyProtectedResourcesSummaryName( + fakePath, + ); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates + .projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromProjectLocationKeyRingCryptoKeyProtectedResourcesSummaryName', () => { + const result = + client.matchLocationFromProjectLocationKeyRingCryptoKeyProtectedResourcesSummaryName( + fakePath, + ); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates + .projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchKeyRingFromProjectLocationKeyRingCryptoKeyProtectedResourcesSummaryName', () => { + const result = + client.matchKeyRingFromProjectLocationKeyRingCryptoKeyProtectedResourcesSummaryName( + fakePath, + ); + assert.strictEqual(result, 'keyRingValue'); + assert( + ( + client.pathTemplates + .projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCryptoKeyFromProjectLocationKeyRingCryptoKeyProtectedResourcesSummaryName', () => { + const result = + client.matchCryptoKeyFromProjectLocationKeyRingCryptoKeyProtectedResourcesSummaryName( + fakePath, + ); + assert.strictEqual(result, 'cryptoKeyValue'); + assert( + ( + client.pathTemplates + .projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchLocationFromRetiredResourceName', () => { - const result = client.matchLocationFromRetiredResourceName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.retiredResourcePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('publicKey', async () => { + const fakePath = '/rendered/path/publicKey'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + key_ring: 'keyRingValue', + crypto_key: 'cryptoKeyValue', + crypto_key_version: 'cryptoKeyVersionValue', + }; + const client = new keydashboardserviceModule.v1.KeyDashboardServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.publicKeyPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.publicKeyPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('publicKeyPath', () => { + const result = client.publicKeyPath( + 'projectValue', + 'locationValue', + 'keyRingValue', + 'cryptoKeyValue', + 'cryptoKeyVersionValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.publicKeyPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromPublicKeyName', () => { + const result = client.matchProjectFromPublicKeyName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.publicKeyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromPublicKeyName', () => { + const result = client.matchLocationFromPublicKeyName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.publicKeyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchKeyRingFromPublicKeyName', () => { + const result = client.matchKeyRingFromPublicKeyName(fakePath); + assert.strictEqual(result, 'keyRingValue'); + assert( + (client.pathTemplates.publicKeyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCryptoKeyFromPublicKeyName', () => { + const result = client.matchCryptoKeyFromPublicKeyName(fakePath); + assert.strictEqual(result, 'cryptoKeyValue'); + assert( + (client.pathTemplates.publicKeyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCryptoKeyVersionFromPublicKeyName', () => { + const result = client.matchCryptoKeyVersionFromPublicKeyName(fakePath); + assert.strictEqual(result, 'cryptoKeyVersionValue'); + assert( + (client.pathTemplates.publicKeyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchRetiredResourceFromRetiredResourceName', () => { - const result = client.matchRetiredResourceFromRetiredResourceName(fakePath); - assert.strictEqual(result, "retiredResourceValue"); - assert((client.pathTemplates.retiredResourcePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('retiredResource', async () => { + const fakePath = '/rendered/path/retiredResource'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + retired_resource: 'retiredResourceValue', + }; + const client = new keydashboardserviceModule.v1.KeyDashboardServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.retiredResourcePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.retiredResourcePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('retiredResourcePath', () => { + const result = client.retiredResourcePath( + 'projectValue', + 'locationValue', + 'retiredResourceValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.retiredResourcePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromRetiredResourceName', () => { + const result = client.matchProjectFromRetiredResourceName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.retiredResourcePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromRetiredResourceName', () => { + const result = client.matchLocationFromRetiredResourceName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.retiredResourcePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRetiredResourceFromRetiredResourceName', () => { + const result = + client.matchRetiredResourceFromRetiredResourceName(fakePath); + assert.strictEqual(result, 'retiredResourceValue'); + assert( + (client.pathTemplates.retiredResourcePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-kms-inventory/test/gapic_key_tracking_service_v1.ts b/packages/google-cloud-kms-inventory/test/gapic_key_tracking_service_v1.ts index 1e33ad18f196..3b83b5f802ca 100644 --- a/packages/google-cloud-kms-inventory/test/gapic_key_tracking_service_v1.ts +++ b/packages/google-cloud-kms-inventory/test/gapic_key_tracking_service_v1.ts @@ -19,1099 +19,1586 @@ 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 keytrackingserviceModule 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.KeyTrackingServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'kmsinventory.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient(); - 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 = keytrackingserviceModule.v1.KeyTrackingServiceClient.servicePath; - assert.strictEqual(servicePath, 'kmsinventory.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = keytrackingserviceModule.v1.KeyTrackingServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'kmsinventory.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'kmsinventory.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'kmsinventory.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 keytrackingserviceModule.v1.KeyTrackingServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'kmsinventory.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 keytrackingserviceModule.v1.KeyTrackingServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'kmsinventory.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 keytrackingserviceModule.v1.KeyTrackingServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); - - it('has port', () => { - const port = keytrackingserviceModule.v1.KeyTrackingServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient(); - assert(client); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'kmsinventory.googleapis.com'); + }); - it('should create a client with gRPC fallback', () => { - const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient({ - fallback: true, - }); - assert(client); - }); + it('has universeDomain', () => { + const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.keyTrackingServiceStub, undefined); - await client.initialize(); - assert(client.keyTrackingServiceStub); - }); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + keytrackingserviceModule.v1.KeyTrackingServiceClient.servicePath; + assert.strictEqual(servicePath, 'kmsinventory.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + keytrackingserviceModule.v1.KeyTrackingServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'kmsinventory.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'kmsinventory.example.com'); + }); - it('has close method for the initialized client', done => { - const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.keyTrackingServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'kmsinventory.example.com'); + }); - it('has close method for the non-initialized client', done => { - const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.keyTrackingServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = + new keytrackingserviceModule.v1.KeyTrackingServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'kmsinventory.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + it('value configured in code has priority over environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = + new keytrackingserviceModule.v1.KeyTrackingServiceClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual( + servicePath, + 'kmsinventory.configured.example.com', + ); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new keytrackingserviceModule.v1.KeyTrackingServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); }); - describe('getProtectedResourcesSummary', () => { - it('invokes getProtectedResourcesSummary without error', async () => { - const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.inventory.v1.GetProtectedResourcesSummaryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.inventory.v1.GetProtectedResourcesSummaryRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.inventory.v1.ProtectedResourcesSummary() - ); - client.innerApiCalls.getProtectedResourcesSummary = stubSimpleCall(expectedResponse); - const [response] = await client.getProtectedResourcesSummary(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getProtectedResourcesSummary as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProtectedResourcesSummary as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getProtectedResourcesSummary without error using callback', async () => { - const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.inventory.v1.GetProtectedResourcesSummaryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.inventory.v1.GetProtectedResourcesSummaryRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.inventory.v1.ProtectedResourcesSummary() - ); - client.innerApiCalls.getProtectedResourcesSummary = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getProtectedResourcesSummary( - request, - (err?: Error|null, result?: protos.google.cloud.kms.inventory.v1.IProtectedResourcesSummary|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getProtectedResourcesSummary as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProtectedResourcesSummary as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has port', () => { + const port = keytrackingserviceModule.v1.KeyTrackingServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('invokes getProtectedResourcesSummary with error', async () => { - const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.inventory.v1.GetProtectedResourcesSummaryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.inventory.v1.GetProtectedResourcesSummaryRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getProtectedResourcesSummary = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getProtectedResourcesSummary(request), expectedError); - const actualRequest = (client.innerApiCalls.getProtectedResourcesSummary as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProtectedResourcesSummary 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 keytrackingserviceModule.v1.KeyTrackingServiceClient(); + assert(client); + }); - it('invokes getProtectedResourcesSummary with closed client', async () => { - const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.inventory.v1.GetProtectedResourcesSummaryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.inventory.v1.GetProtectedResourcesSummaryRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getProtectedResourcesSummary(request), expectedError); - }); + it('should create a client with gRPC fallback', () => { + const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient({ + fallback: true, + }); + assert(client); }); - describe('searchProtectedResources', () => { - it('invokes searchProtectedResources without error', async () => { - const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.inventory.v1.SearchProtectedResourcesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.inventory.v1.SearchProtectedResourcesRequest', ['scope']); - request.scope = defaultValue1; - const expectedHeaderRequestParams = `scope=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.kms.inventory.v1.ProtectedResource()), - generateSampleMessage(new protos.google.cloud.kms.inventory.v1.ProtectedResource()), - generateSampleMessage(new protos.google.cloud.kms.inventory.v1.ProtectedResource()), - ]; - client.innerApiCalls.searchProtectedResources = stubSimpleCall(expectedResponse); - const [response] = await client.searchProtectedResources(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.searchProtectedResources as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.searchProtectedResources 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 keytrackingserviceModule.v1.KeyTrackingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.keyTrackingServiceStub, undefined); + await client.initialize(); + assert(client.keyTrackingServiceStub); + }); - it('invokes searchProtectedResources without error using callback', async () => { - const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.inventory.v1.SearchProtectedResourcesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.inventory.v1.SearchProtectedResourcesRequest', ['scope']); - request.scope = defaultValue1; - const expectedHeaderRequestParams = `scope=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.kms.inventory.v1.ProtectedResource()), - generateSampleMessage(new protos.google.cloud.kms.inventory.v1.ProtectedResource()), - generateSampleMessage(new protos.google.cloud.kms.inventory.v1.ProtectedResource()), - ]; - client.innerApiCalls.searchProtectedResources = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.searchProtectedResources( - request, - (err?: Error|null, result?: protos.google.cloud.kms.inventory.v1.IProtectedResource[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.searchProtectedResources as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.searchProtectedResources 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 keytrackingserviceModule.v1.KeyTrackingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.keyTrackingServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes searchProtectedResources with error', async () => { - const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.inventory.v1.SearchProtectedResourcesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.inventory.v1.SearchProtectedResourcesRequest', ['scope']); - request.scope = defaultValue1; - const expectedHeaderRequestParams = `scope=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.searchProtectedResources = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.searchProtectedResources(request), expectedError); - const actualRequest = (client.innerApiCalls.searchProtectedResources as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.searchProtectedResources 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 keytrackingserviceModule.v1.KeyTrackingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.keyTrackingServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes searchProtectedResourcesStream without error', async () => { - const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.inventory.v1.SearchProtectedResourcesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.inventory.v1.SearchProtectedResourcesRequest', ['scope']); - request.scope = defaultValue1; - const expectedHeaderRequestParams = `scope=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.kms.inventory.v1.ProtectedResource()), - generateSampleMessage(new protos.google.cloud.kms.inventory.v1.ProtectedResource()), - generateSampleMessage(new protos.google.cloud.kms.inventory.v1.ProtectedResource()), - ]; - client.descriptors.page.searchProtectedResources.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.searchProtectedResourcesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.kms.inventory.v1.ProtectedResource[] = []; - stream.on('data', (response: protos.google.cloud.kms.inventory.v1.ProtectedResource) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.searchProtectedResources.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.searchProtectedResources, request)); - assert( - (client.descriptors.page.searchProtectedResources.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient({ + 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 searchProtectedResourcesStream with error', async () => { - const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.inventory.v1.SearchProtectedResourcesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.inventory.v1.SearchProtectedResourcesRequest', ['scope']); - request.scope = defaultValue1; - const expectedHeaderRequestParams = `scope=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.searchProtectedResources.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.searchProtectedResourcesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.kms.inventory.v1.ProtectedResource[] = []; - stream.on('data', (response: protos.google.cloud.kms.inventory.v1.ProtectedResource) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.searchProtectedResources.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.searchProtectedResources, request)); - assert( - (client.descriptors.page.searchProtectedResources.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient({ + 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('getProtectedResourcesSummary', () => { + it('invokes getProtectedResourcesSummary without error', async () => { + const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.inventory.v1.GetProtectedResourcesSummaryRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.inventory.v1.GetProtectedResourcesSummaryRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.inventory.v1.ProtectedResourcesSummary(), + ); + client.innerApiCalls.getProtectedResourcesSummary = + stubSimpleCall(expectedResponse); + const [response] = await client.getProtectedResourcesSummary(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getProtectedResourcesSummary as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProtectedResourcesSummary as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with searchProtectedResources without error', async () => { - const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.inventory.v1.SearchProtectedResourcesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.inventory.v1.SearchProtectedResourcesRequest', ['scope']); - request.scope = defaultValue1; - const expectedHeaderRequestParams = `scope=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.kms.inventory.v1.ProtectedResource()), - generateSampleMessage(new protos.google.cloud.kms.inventory.v1.ProtectedResource()), - generateSampleMessage(new protos.google.cloud.kms.inventory.v1.ProtectedResource()), - ]; - client.descriptors.page.searchProtectedResources.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.kms.inventory.v1.IProtectedResource[] = []; - const iterable = client.searchProtectedResourcesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes getProtectedResourcesSummary without error using callback', async () => { + const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.inventory.v1.GetProtectedResourcesSummaryRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.inventory.v1.GetProtectedResourcesSummaryRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.inventory.v1.ProtectedResourcesSummary(), + ); + client.innerApiCalls.getProtectedResourcesSummary = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getProtectedResourcesSummary( + request, + ( + err?: Error | null, + result?: protos.google.cloud.kms.inventory.v1.IProtectedResourcesSummary | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.searchProtectedResources.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.searchProtectedResources.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with searchProtectedResources with error', async () => { - const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.inventory.v1.SearchProtectedResourcesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.inventory.v1.SearchProtectedResourcesRequest', ['scope']); - request.scope = defaultValue1; - const expectedHeaderRequestParams = `scope=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.searchProtectedResources.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.searchProtectedResourcesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.kms.inventory.v1.IProtectedResource[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.searchProtectedResources.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.searchProtectedResources.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.getProtectedResourcesSummary as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProtectedResourcesSummary as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('Path templates', () => { - - describe('cryptoKey', async () => { - const fakePath = "/rendered/path/cryptoKey"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - key_ring: "keyRingValue", - crypto_key: "cryptoKeyValue", - }; - const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient({ - 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 keytrackingserviceModule.v1.KeyTrackingServiceClient({ - 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('invokes getProtectedResourcesSummary with error', async () => { + const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.inventory.v1.GetProtectedResourcesSummaryRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.inventory.v1.GetProtectedResourcesSummaryRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getProtectedResourcesSummary = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getProtectedResourcesSummary(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.getProtectedResourcesSummary as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProtectedResourcesSummary as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchLocationFromCryptoKeyVersionName', () => { - const result = client.matchLocationFromCryptoKeyVersionName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.cryptoKeyVersionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes getProtectedResourcesSummary with closed client', async () => { + const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.inventory.v1.GetProtectedResourcesSummaryRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.inventory.v1.GetProtectedResourcesSummaryRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.getProtectedResourcesSummary(request), + expectedError, + ); + }); + }); + + describe('searchProtectedResources', () => { + it('invokes searchProtectedResources without error', async () => { + const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.inventory.v1.SearchProtectedResourcesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.inventory.v1.SearchProtectedResourcesRequest', + ['scope'], + ); + request.scope = defaultValue1; + const expectedHeaderRequestParams = `scope=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.kms.inventory.v1.ProtectedResource(), + ), + generateSampleMessage( + new protos.google.cloud.kms.inventory.v1.ProtectedResource(), + ), + generateSampleMessage( + new protos.google.cloud.kms.inventory.v1.ProtectedResource(), + ), + ]; + client.innerApiCalls.searchProtectedResources = + stubSimpleCall(expectedResponse); + const [response] = await client.searchProtectedResources(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.searchProtectedResources as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.searchProtectedResources as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchKeyRingFromCryptoKeyVersionName', () => { - const result = client.matchKeyRingFromCryptoKeyVersionName(fakePath); - assert.strictEqual(result, "keyRingValue"); - assert((client.pathTemplates.cryptoKeyVersionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes searchProtectedResources without error using callback', async () => { + const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.inventory.v1.SearchProtectedResourcesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.inventory.v1.SearchProtectedResourcesRequest', + ['scope'], + ); + request.scope = defaultValue1; + const expectedHeaderRequestParams = `scope=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.kms.inventory.v1.ProtectedResource(), + ), + generateSampleMessage( + new protos.google.cloud.kms.inventory.v1.ProtectedResource(), + ), + generateSampleMessage( + new protos.google.cloud.kms.inventory.v1.ProtectedResource(), + ), + ]; + client.innerApiCalls.searchProtectedResources = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.searchProtectedResources( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.kms.inventory.v1.IProtectedResource[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.searchProtectedResources as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.searchProtectedResources as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchCryptoKeyFromCryptoKeyVersionName', () => { - const result = client.matchCryptoKeyFromCryptoKeyVersionName(fakePath); - assert.strictEqual(result, "cryptoKeyValue"); - assert((client.pathTemplates.cryptoKeyVersionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes searchProtectedResources with error', async () => { + const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.inventory.v1.SearchProtectedResourcesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.inventory.v1.SearchProtectedResourcesRequest', + ['scope'], + ); + request.scope = defaultValue1; + const expectedHeaderRequestParams = `scope=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.searchProtectedResources = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.searchProtectedResources(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.searchProtectedResources as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.searchProtectedResources as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchCryptoKeyVersionFromCryptoKeyVersionName', () => { - const result = client.matchCryptoKeyVersionFromCryptoKeyVersionName(fakePath); - assert.strictEqual(result, "cryptoKeyVersionValue"); - assert((client.pathTemplates.cryptoKeyVersionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes searchProtectedResourcesStream without error', async () => { + const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.inventory.v1.SearchProtectedResourcesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.inventory.v1.SearchProtectedResourcesRequest', + ['scope'], + ); + request.scope = defaultValue1; + const expectedHeaderRequestParams = `scope=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.kms.inventory.v1.ProtectedResource(), + ), + generateSampleMessage( + new protos.google.cloud.kms.inventory.v1.ProtectedResource(), + ), + generateSampleMessage( + new protos.google.cloud.kms.inventory.v1.ProtectedResource(), + ), + ]; + client.descriptors.page.searchProtectedResources.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.searchProtectedResourcesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.kms.inventory.v1.ProtectedResource[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.kms.inventory.v1.ProtectedResource, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - describe('importJob', async () => { - const fakePath = "/rendered/path/importJob"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - key_ring: "keyRingValue", - import_job: "importJobValue", - }; - const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.importJobPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.importJobPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('importJobPath', () => { - const result = client.importJobPath("projectValue", "locationValue", "keyRingValue", "importJobValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.importJobPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromImportJobName', () => { - const result = client.matchProjectFromImportJobName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.importJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromImportJobName', () => { - const result = client.matchLocationFromImportJobName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.importJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchKeyRingFromImportJobName', () => { - const result = client.matchKeyRingFromImportJobName(fakePath); - assert.strictEqual(result, "keyRingValue"); - assert((client.pathTemplates.importJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchImportJobFromImportJobName', () => { - const result = client.matchImportJobFromImportJobName(fakePath); - assert.strictEqual(result, "importJobValue"); - assert((client.pathTemplates.importJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + stream.on('error', (err: Error) => { + reject(err); }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + ( + client.descriptors.page.searchProtectedResources + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.searchProtectedResources, request), + ); + assert( + ( + client.descriptors.page.searchProtectedResources + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - describe('keyRing', async () => { - const fakePath = "/rendered/path/keyRing"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - key_ring: "keyRingValue", - }; - const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.keyRingPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.keyRingPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('keyRingPath', () => { - const result = client.keyRingPath("projectValue", "locationValue", "keyRingValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.keyRingPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromKeyRingName', () => { - const result = client.matchProjectFromKeyRingName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.keyRingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromKeyRingName', () => { - const result = client.matchLocationFromKeyRingName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.keyRingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchKeyRingFromKeyRingName', () => { - const result = client.matchKeyRingFromKeyRingName(fakePath); - assert.strictEqual(result, "keyRingValue"); - assert((client.pathTemplates.keyRingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes searchProtectedResourcesStream with error', async () => { + const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.inventory.v1.SearchProtectedResourcesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.inventory.v1.SearchProtectedResourcesRequest', + ['scope'], + ); + request.scope = defaultValue1; + const expectedHeaderRequestParams = `scope=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.searchProtectedResources.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.searchProtectedResourcesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.kms.inventory.v1.ProtectedResource[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.kms.inventory.v1.ProtectedResource, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - describe('organization', async () => { - const fakePath = "/rendered/path/organization"; - const expectedParameters = { - organization: "organizationValue", - }; - const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient({ - 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)); - }); + stream.on('error', (err: Error) => { + reject(err); }); + }); + await assert.rejects(promise, expectedError); + assert( + ( + client.descriptors.page.searchProtectedResources + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.searchProtectedResources, request), + ); + assert( + ( + client.descriptors.page.searchProtectedResources + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - describe('organizationProtectedResourceScope', async () => { - const fakePath = "/rendered/path/organizationProtectedResourceScope"; - const expectedParameters = { - organization: "organizationValue", - }; - const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationProtectedResourceScopePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationProtectedResourceScopePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationProtectedResourceScopePath', () => { - const result = client.organizationProtectedResourceScopePath("organizationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationProtectedResourceScopePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationProtectedResourceScopeName', () => { - const result = client.matchOrganizationFromOrganizationProtectedResourceScopeName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationProtectedResourceScopePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummary', async () => { - const fakePath = "/rendered/path/projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummary"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - key_ring: "keyRingValue", - crypto_key: "cryptoKeyValue", - crypto_key_version: "cryptoKeyVersionValue", - }; - const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPath', () => { - const result = client.projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPath("projectValue", "locationValue", "keyRingValue", "cryptoKeyValue", "cryptoKeyVersionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName', () => { - const result = client.matchProjectFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName', () => { - const result = client.matchLocationFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchKeyRingFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName', () => { - const result = client.matchKeyRingFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName(fakePath); - assert.strictEqual(result, "keyRingValue"); - assert((client.pathTemplates.projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCryptoKeyFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName', () => { - const result = client.matchCryptoKeyFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName(fakePath); - assert.strictEqual(result, "cryptoKeyValue"); - assert((client.pathTemplates.projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCryptoKeyVersionFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName', () => { - const result = client.matchCryptoKeyVersionFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName(fakePath); - assert.strictEqual(result, "cryptoKeyVersionValue"); - assert((client.pathTemplates.projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('projectLocationKeyRingCryptoKeyProtectedResourcesSummary', async () => { - const fakePath = "/rendered/path/projectLocationKeyRingCryptoKeyProtectedResourcesSummary"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - key_ring: "keyRingValue", - crypto_key: "cryptoKeyValue", - }; - const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPath', () => { - const result = client.projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPath("projectValue", "locationValue", "keyRingValue", "cryptoKeyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectLocationKeyRingCryptoKeyProtectedResourcesSummaryName', () => { - const result = client.matchProjectFromProjectLocationKeyRingCryptoKeyProtectedResourcesSummaryName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProjectLocationKeyRingCryptoKeyProtectedResourcesSummaryName', () => { - const result = client.matchLocationFromProjectLocationKeyRingCryptoKeyProtectedResourcesSummaryName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchKeyRingFromProjectLocationKeyRingCryptoKeyProtectedResourcesSummaryName', () => { - const result = client.matchKeyRingFromProjectLocationKeyRingCryptoKeyProtectedResourcesSummaryName(fakePath); - assert.strictEqual(result, "keyRingValue"); - assert((client.pathTemplates.projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCryptoKeyFromProjectLocationKeyRingCryptoKeyProtectedResourcesSummaryName', () => { - const result = client.matchCryptoKeyFromProjectLocationKeyRingCryptoKeyProtectedResourcesSummaryName(fakePath); - assert.strictEqual(result, "cryptoKeyValue"); - assert((client.pathTemplates.projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('uses async iteration with searchProtectedResources without error', async () => { + const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.inventory.v1.SearchProtectedResourcesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.inventory.v1.SearchProtectedResourcesRequest', + ['scope'], + ); + request.scope = defaultValue1; + const expectedHeaderRequestParams = `scope=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.kms.inventory.v1.ProtectedResource(), + ), + generateSampleMessage( + new protos.google.cloud.kms.inventory.v1.ProtectedResource(), + ), + generateSampleMessage( + new protos.google.cloud.kms.inventory.v1.ProtectedResource(), + ), + ]; + client.descriptors.page.searchProtectedResources.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.kms.inventory.v1.IProtectedResource[] = + []; + const iterable = client.searchProtectedResourcesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.searchProtectedResources + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.searchProtectedResources + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - describe('publicKey', async () => { - const fakePath = "/rendered/path/publicKey"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - key_ring: "keyRingValue", - crypto_key: "cryptoKeyValue", - crypto_key_version: "cryptoKeyVersionValue", - }; - const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.publicKeyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.publicKeyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('publicKeyPath', () => { - const result = client.publicKeyPath("projectValue", "locationValue", "keyRingValue", "cryptoKeyValue", "cryptoKeyVersionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.publicKeyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('uses async iteration with searchProtectedResources with error', async () => { + const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.inventory.v1.SearchProtectedResourcesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.inventory.v1.SearchProtectedResourcesRequest', + ['scope'], + ); + request.scope = defaultValue1; + const expectedHeaderRequestParams = `scope=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.searchProtectedResources.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.searchProtectedResourcesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.kms.inventory.v1.IProtectedResource[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.searchProtectedResources + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.searchProtectedResources + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + + describe('Path templates', () => { + describe('cryptoKey', async () => { + const fakePath = '/rendered/path/cryptoKey'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + key_ring: 'keyRingValue', + crypto_key: 'cryptoKeyValue', + }; + const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient({ + 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), + ); + }); + }); - it('matchProjectFromPublicKeyName', () => { - const result = client.matchProjectFromPublicKeyName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.publicKeyPathTemplate.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 keytrackingserviceModule.v1.KeyTrackingServiceClient({ + 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), + ); + }); + }); - it('matchLocationFromPublicKeyName', () => { - const result = client.matchLocationFromPublicKeyName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.publicKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('importJob', async () => { + const fakePath = '/rendered/path/importJob'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + key_ring: 'keyRingValue', + import_job: 'importJobValue', + }; + const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.importJobPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.importJobPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('importJobPath', () => { + const result = client.importJobPath( + 'projectValue', + 'locationValue', + 'keyRingValue', + 'importJobValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.importJobPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromImportJobName', () => { + const result = client.matchProjectFromImportJobName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.importJobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromImportJobName', () => { + const result = client.matchLocationFromImportJobName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.importJobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchKeyRingFromImportJobName', () => { + const result = client.matchKeyRingFromImportJobName(fakePath); + assert.strictEqual(result, 'keyRingValue'); + assert( + (client.pathTemplates.importJobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchImportJobFromImportJobName', () => { + const result = client.matchImportJobFromImportJobName(fakePath); + assert.strictEqual(result, 'importJobValue'); + assert( + (client.pathTemplates.importJobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchKeyRingFromPublicKeyName', () => { - const result = client.matchKeyRingFromPublicKeyName(fakePath); - assert.strictEqual(result, "keyRingValue"); - assert((client.pathTemplates.publicKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('keyRing', async () => { + const fakePath = '/rendered/path/keyRing'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + key_ring: 'keyRingValue', + }; + const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.keyRingPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.keyRingPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('keyRingPath', () => { + const result = client.keyRingPath( + 'projectValue', + 'locationValue', + 'keyRingValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.keyRingPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromKeyRingName', () => { + const result = client.matchProjectFromKeyRingName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.keyRingPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromKeyRingName', () => { + const result = client.matchLocationFromKeyRingName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.keyRingPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchKeyRingFromKeyRingName', () => { + const result = client.matchKeyRingFromKeyRingName(fakePath); + assert.strictEqual(result, 'keyRingValue'); + assert( + (client.pathTemplates.keyRingPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchCryptoKeyFromPublicKeyName', () => { - const result = client.matchCryptoKeyFromPublicKeyName(fakePath); - assert.strictEqual(result, "cryptoKeyValue"); - assert((client.pathTemplates.publicKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('organization', async () => { + const fakePath = '/rendered/path/organization'; + const expectedParameters = { + organization: 'organizationValue', + }; + const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient({ + 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('matchCryptoKeyVersionFromPublicKeyName', () => { - const result = client.matchCryptoKeyVersionFromPublicKeyName(fakePath); - assert.strictEqual(result, "cryptoKeyVersionValue"); - assert((client.pathTemplates.publicKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('organizationProtectedResourceScope', async () => { + const fakePath = '/rendered/path/organizationProtectedResourceScope'; + const expectedParameters = { + organization: 'organizationValue', + }; + const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.organizationProtectedResourceScopePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationProtectedResourceScopePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('organizationProtectedResourceScopePath', () => { + const result = + client.organizationProtectedResourceScopePath('organizationValue'); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.organizationProtectedResourceScopePathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationProtectedResourceScopeName', () => { + const result = + client.matchOrganizationFromOrganizationProtectedResourceScopeName( + fakePath, + ); + assert.strictEqual(result, 'organizationValue'); + assert( + ( + client.pathTemplates.organizationProtectedResourceScopePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('retiredResource', async () => { - const fakePath = "/rendered/path/retiredResource"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - retired_resource: "retiredResourceValue", - }; - const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.retiredResourcePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.retiredResourcePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('retiredResourcePath', () => { - const result = client.retiredResourcePath("projectValue", "locationValue", "retiredResourceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.retiredResourcePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + describe('projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummary', async () => { + const fakePath = + '/rendered/path/projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummary'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + key_ring: 'keyRingValue', + crypto_key: 'cryptoKeyValue', + crypto_key_version: 'cryptoKeyVersionValue', + }; + const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPath', () => { + const result = + client.projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPath( + 'projectValue', + 'locationValue', + 'keyRingValue', + 'cryptoKeyValue', + 'cryptoKeyVersionValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates + .projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName', () => { + const result = + client.matchProjectFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName( + fakePath, + ); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates + .projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName', () => { + const result = + client.matchLocationFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName( + fakePath, + ); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates + .projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchKeyRingFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName', () => { + const result = + client.matchKeyRingFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName( + fakePath, + ); + assert.strictEqual(result, 'keyRingValue'); + assert( + ( + client.pathTemplates + .projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCryptoKeyFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName', () => { + const result = + client.matchCryptoKeyFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName( + fakePath, + ); + assert.strictEqual(result, 'cryptoKeyValue'); + assert( + ( + client.pathTemplates + .projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCryptoKeyVersionFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName', () => { + const result = + client.matchCryptoKeyVersionFromProjectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryName( + fakePath, + ); + assert.strictEqual(result, 'cryptoKeyVersionValue'); + assert( + ( + client.pathTemplates + .projectLocationKeyRingCryptoKeyCryptoKeyVersionProtectedResourcesSummaryPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchProjectFromRetiredResourceName', () => { - const result = client.matchProjectFromRetiredResourceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.retiredResourcePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('projectLocationKeyRingCryptoKeyProtectedResourcesSummary', async () => { + const fakePath = + '/rendered/path/projectLocationKeyRingCryptoKeyProtectedResourcesSummary'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + key_ring: 'keyRingValue', + crypto_key: 'cryptoKeyValue', + }; + const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPath', () => { + const result = + client.projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPath( + 'projectValue', + 'locationValue', + 'keyRingValue', + 'cryptoKeyValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates + .projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectLocationKeyRingCryptoKeyProtectedResourcesSummaryName', () => { + const result = + client.matchProjectFromProjectLocationKeyRingCryptoKeyProtectedResourcesSummaryName( + fakePath, + ); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates + .projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromProjectLocationKeyRingCryptoKeyProtectedResourcesSummaryName', () => { + const result = + client.matchLocationFromProjectLocationKeyRingCryptoKeyProtectedResourcesSummaryName( + fakePath, + ); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates + .projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchKeyRingFromProjectLocationKeyRingCryptoKeyProtectedResourcesSummaryName', () => { + const result = + client.matchKeyRingFromProjectLocationKeyRingCryptoKeyProtectedResourcesSummaryName( + fakePath, + ); + assert.strictEqual(result, 'keyRingValue'); + assert( + ( + client.pathTemplates + .projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCryptoKeyFromProjectLocationKeyRingCryptoKeyProtectedResourcesSummaryName', () => { + const result = + client.matchCryptoKeyFromProjectLocationKeyRingCryptoKeyProtectedResourcesSummaryName( + fakePath, + ); + assert.strictEqual(result, 'cryptoKeyValue'); + assert( + ( + client.pathTemplates + .projectLocationKeyRingCryptoKeyProtectedResourcesSummaryPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchLocationFromRetiredResourceName', () => { - const result = client.matchLocationFromRetiredResourceName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.retiredResourcePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('publicKey', async () => { + const fakePath = '/rendered/path/publicKey'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + key_ring: 'keyRingValue', + crypto_key: 'cryptoKeyValue', + crypto_key_version: 'cryptoKeyVersionValue', + }; + const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.publicKeyPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.publicKeyPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('publicKeyPath', () => { + const result = client.publicKeyPath( + 'projectValue', + 'locationValue', + 'keyRingValue', + 'cryptoKeyValue', + 'cryptoKeyVersionValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.publicKeyPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromPublicKeyName', () => { + const result = client.matchProjectFromPublicKeyName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.publicKeyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromPublicKeyName', () => { + const result = client.matchLocationFromPublicKeyName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.publicKeyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchKeyRingFromPublicKeyName', () => { + const result = client.matchKeyRingFromPublicKeyName(fakePath); + assert.strictEqual(result, 'keyRingValue'); + assert( + (client.pathTemplates.publicKeyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCryptoKeyFromPublicKeyName', () => { + const result = client.matchCryptoKeyFromPublicKeyName(fakePath); + assert.strictEqual(result, 'cryptoKeyValue'); + assert( + (client.pathTemplates.publicKeyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCryptoKeyVersionFromPublicKeyName', () => { + const result = client.matchCryptoKeyVersionFromPublicKeyName(fakePath); + assert.strictEqual(result, 'cryptoKeyVersionValue'); + assert( + (client.pathTemplates.publicKeyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchRetiredResourceFromRetiredResourceName', () => { - const result = client.matchRetiredResourceFromRetiredResourceName(fakePath); - assert.strictEqual(result, "retiredResourceValue"); - assert((client.pathTemplates.retiredResourcePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('retiredResource', async () => { + const fakePath = '/rendered/path/retiredResource'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + retired_resource: 'retiredResourceValue', + }; + const client = new keytrackingserviceModule.v1.KeyTrackingServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.retiredResourcePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.retiredResourcePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('retiredResourcePath', () => { + const result = client.retiredResourcePath( + 'projectValue', + 'locationValue', + 'retiredResourceValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.retiredResourcePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromRetiredResourceName', () => { + const result = client.matchProjectFromRetiredResourceName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.retiredResourcePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromRetiredResourceName', () => { + const result = client.matchLocationFromRetiredResourceName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.retiredResourcePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRetiredResourceFromRetiredResourceName', () => { + const result = + client.matchRetiredResourceFromRetiredResourceName(fakePath); + assert.strictEqual(result, 'retiredResourceValue'); + assert( + (client.pathTemplates.retiredResourcePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-kms-inventory/webpack.config.js b/packages/google-cloud-kms-inventory/webpack.config.js index 9e62deec15cd..7e4c2732db0b 100644 --- a/packages/google-cloud-kms-inventory/webpack.config.js +++ b/packages/google-cloud-kms-inventory/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-kms/.eslintignore b/packages/google-cloud-kms/.eslintignore new file mode 100644 index 000000000000..cfc348ec4d11 --- /dev/null +++ b/packages/google-cloud-kms/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/packages/google-cloud-kms/.eslintrc.json b/packages/google-cloud-kms/.eslintrc.json new file mode 100644 index 000000000000..3e8d97ccb390 --- /dev/null +++ b/packages/google-cloud-kms/.eslintrc.json @@ -0,0 +1,4 @@ +{ + "extends": "./node_modules/gts", + "root": true +} diff --git a/packages/google-cloud-kms/README.md b/packages/google-cloud-kms/README.md index d6af500977d4..95404ece5303 100644 --- a/packages/google-cloud-kms/README.md +++ b/packages/google-cloud-kms/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-kms/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-kms/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-kms/protos/protos.d.ts b/packages/google-cloud-kms/protos/protos.d.ts index 7772a4ce6ff2..c7b9a7da8652 100644 --- a/packages/google-cloud-kms/protos/protos.d.ts +++ b/packages/google-cloud-kms/protos/protos.d.ts @@ -15264,6 +15264,9 @@ export namespace google { /** CommonLanguageSettings destinations */ destinations?: (google.api.ClientLibraryDestination[]|null); + + /** CommonLanguageSettings selectiveGapicGeneration */ + selectiveGapicGeneration?: (google.api.ISelectiveGapicGeneration|null); } /** Represents a CommonLanguageSettings. */ @@ -15281,6 +15284,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 @@ -15981,6 +15987,9 @@ export namespace google { /** PythonSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** PythonSettings experimentalFeatures */ + experimentalFeatures?: (google.api.PythonSettings.IExperimentalFeatures|null); } /** Represents a PythonSettings. */ @@ -15995,6 +16004,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 @@ -16073,6 +16085,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 { @@ -16399,6 +16523,9 @@ export namespace google { /** GoSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** GoSettings renamedServices */ + renamedServices?: ({ [k: string]: string }|null); } /** Represents a GoSettings. */ @@ -16413,6 +16540,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 @@ -16737,6 +16867,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, @@ -17118,6 +17351,7 @@ export namespace google { /** Edition enum. */ enum Edition { EDITION_UNKNOWN = 0, + EDITION_LEGACY = 900, EDITION_PROTO2 = 998, EDITION_PROTO3 = 999, EDITION_2023 = 1000, @@ -17148,6 +17382,9 @@ export namespace google { /** FileDescriptorProto weakDependency */ weakDependency?: (number[]|null); + /** FileDescriptorProto optionDependency */ + optionDependency?: (string[]|null); + /** FileDescriptorProto messageType */ messageType?: (google.protobuf.IDescriptorProto[]|null); @@ -17197,6 +17434,9 @@ export namespace google { /** FileDescriptorProto weakDependency. */ public weakDependency: number[]; + /** FileDescriptorProto optionDependency. */ + public optionDependency: string[]; + /** FileDescriptorProto messageType. */ public messageType: google.protobuf.IDescriptorProto[]; @@ -17331,6 +17571,9 @@ export namespace google { /** DescriptorProto reservedName */ reservedName?: (string[]|null); + + /** DescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents a DescriptorProto. */ @@ -17372,6 +17615,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 @@ -18219,6 +18465,9 @@ export namespace google { /** EnumDescriptorProto reservedName */ reservedName?: (string[]|null); + + /** EnumDescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents an EnumDescriptorProto. */ @@ -18245,6 +18494,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 @@ -19179,6 +19431,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); @@ -19234,6 +19489,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[]; @@ -19454,6 +19712,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. */ @@ -19692,6 +20065,9 @@ export namespace google { /** EnumValueOptions debugRedact */ debugRedact?: (boolean|null); + /** EnumValueOptions featureSupport */ + featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** EnumValueOptions uninterpretedOption */ uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); } @@ -19714,6 +20090,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[]; @@ -20306,6 +20685,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. */ @@ -20335,6 +20720,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 @@ -20457,6 +20848,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. */ @@ -20576,8 +21077,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. */ @@ -20592,8 +21096,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. @@ -21126,6 +21633,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-kms/protos/protos.js b/packages/google-cloud-kms/protos/protos.js index 8243db680fe1..e04632e48870 100644 --- a/packages/google-cloud-kms/protos/protos.js +++ b/packages/google-cloud-kms/protos/protos.js @@ -38134,6 +38134,7 @@ * @interface ICommonLanguageSettings * @property {string|null} [referenceDocsUri] CommonLanguageSettings referenceDocsUri * @property {Array.|null} [destinations] CommonLanguageSettings destinations + * @property {google.api.ISelectiveGapicGeneration|null} [selectiveGapicGeneration] CommonLanguageSettings selectiveGapicGeneration */ /** @@ -38168,6 +38169,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 @@ -38200,6 +38209,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; }; @@ -38251,6 +38262,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; @@ -38302,6 +38317,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; }; @@ -38344,6 +38364,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; }; @@ -38362,8 +38387,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) { @@ -38371,6 +38398,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; }; @@ -40193,6 +40222,7 @@ * @memberof google.api * @interface IPythonSettings * @property {google.api.ICommonLanguageSettings|null} [common] PythonSettings common + * @property {google.api.PythonSettings.IExperimentalFeatures|null} [experimentalFeatures] PythonSettings experimentalFeatures */ /** @@ -40218,6 +40248,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 @@ -40244,6 +40282,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; }; @@ -40284,6 +40324,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; @@ -40324,6 +40368,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; }; @@ -40344,6 +40393,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; }; @@ -40360,10 +40414,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; }; @@ -40393,6 +40451,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; })(); @@ -41269,6 +41579,7 @@ * @memberof google.api * @interface IGoSettings * @property {google.api.ICommonLanguageSettings|null} [common] GoSettings common + * @property {Object.|null} [renamedServices] GoSettings renamedServices */ /** @@ -41280,6 +41591,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) @@ -41294,6 +41606,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 @@ -41320,6 +41640,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; }; @@ -41350,7 +41673,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) @@ -41360,6 +41683,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; @@ -41400,6 +41746,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; }; @@ -41420,6 +41774,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; }; @@ -41436,10 +41797,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; }; @@ -42078,30 +42447,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; })(); /** @@ -43063,6 +43677,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 @@ -43077,6 +43692,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; @@ -43101,6 +43717,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 @@ -43123,6 +43740,7 @@ this.dependency = []; this.publicDependency = []; this.weakDependency = []; + this.optionDependency = []; this.messageType = []; this.enumType = []; this.service = []; @@ -43173,6 +43791,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 @@ -43294,6 +43920,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; }; @@ -43366,6 +43995,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 = []; @@ -43468,6 +44103,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"; @@ -43522,6 +44164,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -43574,6 +44217,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"); @@ -43637,6 +44287,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -43702,6 +44356,7 @@ object.extension = []; object.publicDependency = []; object.weakDependency = []; + object.optionDependency = []; } if (options.defaults) { object.name = ""; @@ -43758,6 +44413,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; }; @@ -43806,6 +44466,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 */ /** @@ -43911,6 +44572,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 @@ -43963,6 +44632,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; }; @@ -44055,6 +44726,10 @@ message.reservedName.push(reader.string()); break; } + case 11: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -44168,6 +44843,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; }; @@ -44267,6 +44951,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; }; @@ -44296,6 +45000,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; @@ -44341,6 +45046,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; }; @@ -46385,6 +47092,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 */ /** @@ -46445,6 +47153,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 @@ -46482,6 +47198,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; }; @@ -46544,6 +47262,10 @@ message.reservedName.push(reader.string()); break; } + case 6: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -46612,6 +47334,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; }; @@ -46661,6 +47392,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; }; @@ -46685,6 +47436,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; @@ -46705,6 +47457,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; }; @@ -49023,6 +49777,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 @@ -49143,6 +49898,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 @@ -49217,6 +49980,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(); @@ -49318,6 +50083,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 = []; @@ -49453,6 +50222,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"; @@ -49641,6 +50415,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"); @@ -49738,6 +50517,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")) @@ -49770,6 +50550,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) @@ -50042,6 +50824,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -50083,103 +50866,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; @@ -50774,6 +52043,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 */ @@ -50817,6 +52087,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 @@ -50855,6 +52133,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(); @@ -50906,6 +52186,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 = []; @@ -50958,6 +52242,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"; @@ -50991,6 +52280,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"); @@ -51023,6 +52317,7 @@ object.deprecated = false; object.features = null; object.debugRedact = false; + object.featureSupport = null; } if (message.deprecated != null && message.hasOwnProperty("deprecated")) object.deprecated = message.deprecated; @@ -51030,6 +52325,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) @@ -52497,6 +53794,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 */ /** @@ -52562,6 +53861,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 @@ -52598,6 +53913,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; }; @@ -52658,6 +53977,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; @@ -52748,6 +54075,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; }; @@ -52887,6 +54234,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; }; @@ -52910,6 +54305,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; @@ -52923,6 +54320,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; }; @@ -53050,6 +54451,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; })(); @@ -53234,6 +54848,7 @@ default: return "minimumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -53251,6 +54866,7 @@ default: return "maximumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -53299,6 +54915,10 @@ case 0: message.minimumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.minimumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.minimumEdition = 998; @@ -53351,6 +54971,10 @@ case 0: message.maximumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.maximumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.maximumEdition = 998; @@ -53459,7 +55083,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 */ /** @@ -53486,12 +55111,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. @@ -53517,10 +55150,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; }; @@ -53561,8 +55196,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: @@ -53605,6 +55244,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -53617,10 +55257,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; }; @@ -53648,6 +55293,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -53689,10 +55338,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; }; @@ -53711,13 +55365,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; }; @@ -54932,6 +56589,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-kms/protos/protos.json b/packages/google-cloud-kms/protos/protos.json index a65d4cf77163..ee6a57a1d8b9 100644 --- a/packages/google-cloud-kms/protos/protos.json +++ b/packages/google-cloud-kms/protos/protos.json @@ -4404,8 +4404,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": { @@ -4529,6 +4528,10 @@ "rule": "repeated", "type": "ClientLibraryDestination", "id": 2 + }, + "selectiveGapicGeneration": { + "type": "SelectiveGapicGeneration", + "id": 3 } } }, @@ -4669,6 +4672,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 + } + } } } }, @@ -4726,6 +4751,11 @@ "common": { "type": "CommonLanguageSettings", "id": 1 + }, + "renamedServices": { + "keyType": "string", + "type": "string", + "id": 2 } } }, @@ -4787,6 +4817,19 @@ "PACKAGE_MANAGER": 20 } }, + "SelectiveGapicGeneration": { + "fields": { + "methods": { + "rule": "repeated", + "type": "string", + "id": 1 + }, + "generateOmittedAsInternal": { + "type": "bool", + "id": 2 + } + } + }, "LaunchStage": { "values": { "LAUNCH_STAGE_UNSPECIFIED": 0, @@ -4919,12 +4962,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, @@ -4963,6 +5013,11 @@ "type": "int32", "id": 11 }, + "optionDependency": { + "rule": "repeated", + "type": "string", + "id": 15 + }, "messageType": { "rule": "repeated", "type": "DescriptorProto", @@ -5051,6 +5106,10 @@ "rule": "repeated", "type": "string", "id": 10 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 11 } }, "nested": { @@ -5276,6 +5335,10 @@ "rule": "repeated", "type": "string", "id": 5 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 6 } }, "nested": { @@ -5326,7 +5389,14 @@ "type": "ServiceOptions", "id": 3 } - } + }, + "reserved": [ + [ + 4, + 4 + ], + "stream" + ] }, "MethodDescriptorProto": { "edition": "proto2", @@ -5490,6 +5560,7 @@ 42, 42 ], + "php_generic_services", [ 38, 38 @@ -5625,7 +5696,8 @@ "type": "bool", "id": 10, "options": { - "default": false + "default": false, + "deprecated": true } }, "debugRedact": { @@ -5653,6 +5725,10 @@ "type": "FeatureSet", "id": 21 }, + "featureSupport": { + "type": "FeatureSupport", + "id": 22 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -5722,6 +5798,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 + } + } } } }, @@ -5810,6 +5906,10 @@ "default": false } }, + "featureSupport": { + "type": "FieldOptions.FeatureSupport", + "id": 4 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -5952,6 +6052,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_2023", "edition_defaults.value": "EXPLICIT" } @@ -5962,6 +6063,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "OPEN" } @@ -5972,6 +6074,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "PACKED" } @@ -5982,6 +6085,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "VERIFY" } @@ -5992,7 +6096,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" } }, @@ -6002,27 +6107,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, @@ -6067,7 +6183,13 @@ "UTF8_VALIDATION_UNKNOWN": 0, "VERIFY": 2, "NONE": 3 - } + }, + "reserved": [ + [ + 1, + 1 + ] + ] }, "MessageEncoding": { "values": { @@ -6082,6 +6204,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 + } + } + } } } }, @@ -6109,11 +6258,26 @@ "type": "Edition", "id": 3 }, - "features": { + "overridableFeatures": { "type": "FeatureSet", - "id": 2 + "id": 4 + }, + "fixedFeatures": { + "type": "FeatureSet", + "id": 5 } - } + }, + "reserved": [ + [ + 1, + 1 + ], + [ + 2, + 2 + ], + "features" + ] } } }, @@ -6126,6 +6290,12 @@ "id": 1 } }, + "extensions": [ + [ + 536000000, + 536000000 + ] + ], "nested": { "Location": { "fields": { @@ -6211,6 +6381,14 @@ } } }, + "SymbolVisibility": { + "edition": "proto2", + "values": { + "VISIBILITY_UNSET": 0, + "VISIBILITY_LOCAL": 1, + "VISIBILITY_EXPORT": 2 + } + }, "Duration": { "fields": { "seconds": { @@ -6341,6 +6519,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-kms/samples/generated/v1/snippet_metadata_google.cloud.kms.v1.json b/packages/google-cloud-kms/samples/generated/v1/snippet_metadata_google.cloud.kms.v1.json index a4fd2b18a0a8..17c7a281b2df 100644 --- a/packages/google-cloud-kms/samples/generated/v1/snippet_metadata_google.cloud.kms.v1.json +++ b/packages/google-cloud-kms/samples/generated/v1/snippet_metadata_google.cloud.kms.v1.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-kms", - "version": "5.4.0", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-kms/src/v1/autokey_admin_client.ts b/packages/google-cloud-kms/src/v1/autokey_admin_client.ts index a908c257db26..197c6ac8ddba 100644 --- a/packages/google-cloud-kms/src/v1/autokey_admin_client.ts +++ b/packages/google-cloud-kms/src/v1/autokey_admin_client.ts @@ -18,11 +18,20 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, IamClient, IamProtos, LocationsClient, LocationProtos} from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + IamClient, + IamProtos, + 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 @@ -53,7 +62,7 @@ export class AutokeyAdminClient { 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('kms'); @@ -66,11 +75,11 @@ export class AutokeyAdminClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; iamClient: IamClient; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - autokeyAdminStub?: Promise<{[name: string]: Function}>; + pathTemplates: { [name: string]: gax.PathTemplate }; + autokeyAdminStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of AutokeyAdminClient. @@ -111,21 +120,42 @@ export class AutokeyAdminClient { * const client = new AutokeyAdminClient({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 AutokeyAdminClient; - 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 = 'cloudkms.' + 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; @@ -150,7 +180,7 @@ export class AutokeyAdminClient { 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; @@ -163,18 +193,14 @@ export class AutokeyAdminClient { this.auth.defaultScopes = staticMembers.scopes; } this.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); - + this.locationsClient = new this._gaxModule.LocationsClient( this._gaxGrpc, - opts + opts, ); - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process === 'object' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -196,53 +222,57 @@ export class AutokeyAdminClient { // Create useful helper objects for these. this.pathTemplates = { 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}', ), ekmConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/ekmConfig' + 'projects/{project}/locations/{location}/ekmConfig', ), ekmConnectionPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/ekmConnections/{ekm_connection}' + 'projects/{project}/locations/{location}/ekmConnections/{ekm_connection}', ), folderAutokeyConfigPathTemplate: new this._gaxModule.PathTemplate( - 'folders/{folder}/autokeyConfig' + 'folders/{folder}/autokeyConfig', ), importJobPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/keyRings/{key_ring}/importJobs/{import_job}' + 'projects/{project}/locations/{location}/keyRings/{key_ring}/importJobs/{import_job}', ), keyHandlePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/keyHandles/{key_handle}' + 'projects/{project}/locations/{location}/keyHandles/{key_handle}', ), keyRingPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/keyRings/{key_ring}' + 'projects/{project}/locations/{location}/keyRings/{key_ring}', ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' + 'projects/{project}', ), projectAutokeyConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/autokeyConfig' + 'projects/{project}/autokeyConfig', ), publicKeyPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}/publicKey' + 'projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}/publicKey', ), retiredResourcePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/retiredResources/{retired_resource}' + 'projects/{project}/locations/{location}/retiredResources/{retired_resource}', ), singleTenantHsmInstancePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/singleTenantHsmInstances/{single_tenant_hsm_instance}' - ), - singleTenantHsmInstanceProposalPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/singleTenantHsmInstances/{single_tenant_hsm_instance}/proposals/{proposal}' + 'projects/{project}/locations/{location}/singleTenantHsmInstances/{single_tenant_hsm_instance}', ), + singleTenantHsmInstanceProposalPathTemplate: + new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/singleTenantHsmInstances/{single_tenant_hsm_instance}/proposals/{proposal}', + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.kms.v1.AutokeyAdmin', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.kms.v1.AutokeyAdmin', + 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,36 +303,44 @@ export class AutokeyAdminClient { // Put together the "service stub" for // google.cloud.kms.v1.AutokeyAdmin. this.autokeyAdminStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.kms.v1.AutokeyAdmin') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.kms.v1.AutokeyAdmin', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.kms.v1.AutokeyAdmin, - 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 autokeyAdminStubMethods = - ['updateAutokeyConfig', 'getAutokeyConfig', 'showEffectiveAutokeyConfig']; + const autokeyAdminStubMethods = [ + 'updateAutokeyConfig', + 'getAutokeyConfig', + 'showEffectiveAutokeyConfig', + ]; for (const methodName of autokeyAdminStubMethods) { const callPromise = this.autokeyAdminStub.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; @@ -317,8 +355,14 @@ export class AutokeyAdminClient { * @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 'cloudkms.googleapis.com'; } @@ -329,8 +373,14 @@ export class AutokeyAdminClient { * @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 'cloudkms.googleapis.com'; } @@ -363,7 +413,7 @@ export class AutokeyAdminClient { static get scopes() { return [ 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/cloudkms' + 'https://www.googleapis.com/auth/cloudkms', ]; } @@ -373,8 +423,9 @@ export class AutokeyAdminClient { * Return the project ID used by this class. * @returns {Promise} A promise that resolves to string containing the project ID. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback, + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -385,330 +436,441 @@ export class AutokeyAdminClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Updates the {@link protos.google.cloud.kms.v1.AutokeyConfig|AutokeyConfig} for a folder - * or a project. The caller must have both `cloudkms.autokeyConfigs.update` - * permission on the parent folder and `cloudkms.cryptoKeys.setIamPolicy` - * permission on the provided key project. A - * {@link protos.google.cloud.kms.v1.KeyHandle|KeyHandle} creation in the folder's - * descendant projects will use this configuration to determine where to - * create the resulting {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey}. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.kms.v1.AutokeyConfig} request.autokeyConfig - * Required. {@link protos.google.cloud.kms.v1.AutokeyConfig|AutokeyConfig} with values to - * update. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. Masks which fields of the - * {@link protos.google.cloud.kms.v1.AutokeyConfig|AutokeyConfig} to update, e.g. - * `keyProject`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.kms.v1.AutokeyConfig|AutokeyConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/autokey_admin.update_autokey_config.js - * region_tag:cloudkms_v1_generated_AutokeyAdmin_UpdateAutokeyConfig_async - */ + /** + * Updates the {@link protos.google.cloud.kms.v1.AutokeyConfig|AutokeyConfig} for a folder + * or a project. The caller must have both `cloudkms.autokeyConfigs.update` + * permission on the parent folder and `cloudkms.cryptoKeys.setIamPolicy` + * permission on the provided key project. A + * {@link protos.google.cloud.kms.v1.KeyHandle|KeyHandle} creation in the folder's + * descendant projects will use this configuration to determine where to + * create the resulting {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey}. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.kms.v1.AutokeyConfig} request.autokeyConfig + * Required. {@link protos.google.cloud.kms.v1.AutokeyConfig|AutokeyConfig} with values to + * update. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. Masks which fields of the + * {@link protos.google.cloud.kms.v1.AutokeyConfig|AutokeyConfig} to update, e.g. + * `keyProject`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.kms.v1.AutokeyConfig|AutokeyConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/autokey_admin.update_autokey_config.js + * region_tag:cloudkms_v1_generated_AutokeyAdmin_UpdateAutokeyConfig_async + */ updateAutokeyConfig( - request?: protos.google.cloud.kms.v1.IUpdateAutokeyConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.kms.v1.IAutokeyConfig, - protos.google.cloud.kms.v1.IUpdateAutokeyConfigRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.kms.v1.IUpdateAutokeyConfigRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.kms.v1.IAutokeyConfig, + protos.google.cloud.kms.v1.IUpdateAutokeyConfigRequest | undefined, + {} | undefined, + ] + >; updateAutokeyConfig( - request: protos.google.cloud.kms.v1.IUpdateAutokeyConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.kms.v1.IAutokeyConfig, - protos.google.cloud.kms.v1.IUpdateAutokeyConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IUpdateAutokeyConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.kms.v1.IAutokeyConfig, + protos.google.cloud.kms.v1.IUpdateAutokeyConfigRequest | null | undefined, + {} | null | undefined + >, + ): void; updateAutokeyConfig( - request: protos.google.cloud.kms.v1.IUpdateAutokeyConfigRequest, - callback: Callback< - protos.google.cloud.kms.v1.IAutokeyConfig, - protos.google.cloud.kms.v1.IUpdateAutokeyConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IUpdateAutokeyConfigRequest, + callback: Callback< + protos.google.cloud.kms.v1.IAutokeyConfig, + protos.google.cloud.kms.v1.IUpdateAutokeyConfigRequest | null | undefined, + {} | null | undefined + >, + ): void; updateAutokeyConfig( - request?: protos.google.cloud.kms.v1.IUpdateAutokeyConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.kms.v1.IAutokeyConfig, - protos.google.cloud.kms.v1.IUpdateAutokeyConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.kms.v1.IUpdateAutokeyConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.kms.v1.IAutokeyConfig, - protos.google.cloud.kms.v1.IUpdateAutokeyConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.kms.v1.IAutokeyConfig, - protos.google.cloud.kms.v1.IUpdateAutokeyConfigRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.kms.v1.IUpdateAutokeyConfigRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.kms.v1.IAutokeyConfig, + protos.google.cloud.kms.v1.IUpdateAutokeyConfigRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.kms.v1.IAutokeyConfig, + protos.google.cloud.kms.v1.IUpdateAutokeyConfigRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'autokey_config.name': request.autokeyConfig!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'autokey_config.name': request.autokeyConfig!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('updateAutokeyConfig request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.kms.v1.IAutokeyConfig, - protos.google.cloud.kms.v1.IUpdateAutokeyConfigRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.kms.v1.IAutokeyConfig, + | protos.google.cloud.kms.v1.IUpdateAutokeyConfigRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('updateAutokeyConfig response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.updateAutokeyConfig(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.kms.v1.IAutokeyConfig, - protos.google.cloud.kms.v1.IUpdateAutokeyConfigRequest|undefined, - {}|undefined - ]) => { - this._log.info('updateAutokeyConfig response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .updateAutokeyConfig(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.kms.v1.IAutokeyConfig, + protos.google.cloud.kms.v1.IUpdateAutokeyConfigRequest | undefined, + {} | undefined, + ]) => { + this._log.info('updateAutokeyConfig response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 {@link protos.google.cloud.kms.v1.AutokeyConfig|AutokeyConfig} for a folder - * or project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the {@link protos.google.cloud.kms.v1.AutokeyConfig|AutokeyConfig} - * resource, e.g. `folders/{FOLDER_NUMBER}/autokeyConfig` or - * `projects/{PROJECT_NUMBER}/autokeyConfig`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.kms.v1.AutokeyConfig|AutokeyConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/autokey_admin.get_autokey_config.js - * region_tag:cloudkms_v1_generated_AutokeyAdmin_GetAutokeyConfig_async - */ + /** + * Returns the {@link protos.google.cloud.kms.v1.AutokeyConfig|AutokeyConfig} for a folder + * or project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the {@link protos.google.cloud.kms.v1.AutokeyConfig|AutokeyConfig} + * resource, e.g. `folders/{FOLDER_NUMBER}/autokeyConfig` or + * `projects/{PROJECT_NUMBER}/autokeyConfig`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.kms.v1.AutokeyConfig|AutokeyConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/autokey_admin.get_autokey_config.js + * region_tag:cloudkms_v1_generated_AutokeyAdmin_GetAutokeyConfig_async + */ getAutokeyConfig( - request?: protos.google.cloud.kms.v1.IGetAutokeyConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.kms.v1.IAutokeyConfig, - protos.google.cloud.kms.v1.IGetAutokeyConfigRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.kms.v1.IGetAutokeyConfigRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.kms.v1.IAutokeyConfig, + protos.google.cloud.kms.v1.IGetAutokeyConfigRequest | undefined, + {} | undefined, + ] + >; getAutokeyConfig( - request: protos.google.cloud.kms.v1.IGetAutokeyConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.kms.v1.IAutokeyConfig, - protos.google.cloud.kms.v1.IGetAutokeyConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IGetAutokeyConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.kms.v1.IAutokeyConfig, + protos.google.cloud.kms.v1.IGetAutokeyConfigRequest | null | undefined, + {} | null | undefined + >, + ): void; getAutokeyConfig( - request: protos.google.cloud.kms.v1.IGetAutokeyConfigRequest, - callback: Callback< - protos.google.cloud.kms.v1.IAutokeyConfig, - protos.google.cloud.kms.v1.IGetAutokeyConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IGetAutokeyConfigRequest, + callback: Callback< + protos.google.cloud.kms.v1.IAutokeyConfig, + protos.google.cloud.kms.v1.IGetAutokeyConfigRequest | null | undefined, + {} | null | undefined + >, + ): void; getAutokeyConfig( - request?: protos.google.cloud.kms.v1.IGetAutokeyConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.kms.v1.IAutokeyConfig, - protos.google.cloud.kms.v1.IGetAutokeyConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.kms.v1.IGetAutokeyConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.kms.v1.IAutokeyConfig, - protos.google.cloud.kms.v1.IGetAutokeyConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.kms.v1.IAutokeyConfig, - protos.google.cloud.kms.v1.IGetAutokeyConfigRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.kms.v1.IGetAutokeyConfigRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.kms.v1.IAutokeyConfig, + protos.google.cloud.kms.v1.IGetAutokeyConfigRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.kms.v1.IAutokeyConfig, + protos.google.cloud.kms.v1.IGetAutokeyConfigRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getAutokeyConfig request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.kms.v1.IAutokeyConfig, - protos.google.cloud.kms.v1.IGetAutokeyConfigRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.kms.v1.IAutokeyConfig, + | protos.google.cloud.kms.v1.IGetAutokeyConfigRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getAutokeyConfig response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getAutokeyConfig(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.kms.v1.IAutokeyConfig, - protos.google.cloud.kms.v1.IGetAutokeyConfigRequest|undefined, - {}|undefined - ]) => { - this._log.info('getAutokeyConfig response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getAutokeyConfig(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.kms.v1.IAutokeyConfig, + protos.google.cloud.kms.v1.IGetAutokeyConfigRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getAutokeyConfig response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 effective Cloud KMS Autokey configuration for a given project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Name of the resource project to the show effective Cloud KMS - * Autokey configuration for. This may be helpful for interrogating the effect - * of nested folder configurations on a given resource project. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.kms.v1.ShowEffectiveAutokeyConfigResponse|ShowEffectiveAutokeyConfigResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/autokey_admin.show_effective_autokey_config.js - * region_tag:cloudkms_v1_generated_AutokeyAdmin_ShowEffectiveAutokeyConfig_async - */ + /** + * Returns the effective Cloud KMS Autokey configuration for a given project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Name of the resource project to the show effective Cloud KMS + * Autokey configuration for. This may be helpful for interrogating the effect + * of nested folder configurations on a given resource project. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.kms.v1.ShowEffectiveAutokeyConfigResponse|ShowEffectiveAutokeyConfigResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/autokey_admin.show_effective_autokey_config.js + * region_tag:cloudkms_v1_generated_AutokeyAdmin_ShowEffectiveAutokeyConfig_async + */ showEffectiveAutokeyConfig( - request?: protos.google.cloud.kms.v1.IShowEffectiveAutokeyConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.kms.v1.IShowEffectiveAutokeyConfigResponse, - protos.google.cloud.kms.v1.IShowEffectiveAutokeyConfigRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.kms.v1.IShowEffectiveAutokeyConfigRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.kms.v1.IShowEffectiveAutokeyConfigResponse, + protos.google.cloud.kms.v1.IShowEffectiveAutokeyConfigRequest | undefined, + {} | undefined, + ] + >; showEffectiveAutokeyConfig( - request: protos.google.cloud.kms.v1.IShowEffectiveAutokeyConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.kms.v1.IShowEffectiveAutokeyConfigResponse, - protos.google.cloud.kms.v1.IShowEffectiveAutokeyConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IShowEffectiveAutokeyConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.kms.v1.IShowEffectiveAutokeyConfigResponse, + | protos.google.cloud.kms.v1.IShowEffectiveAutokeyConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): void; showEffectiveAutokeyConfig( - request: protos.google.cloud.kms.v1.IShowEffectiveAutokeyConfigRequest, - callback: Callback< - protos.google.cloud.kms.v1.IShowEffectiveAutokeyConfigResponse, - protos.google.cloud.kms.v1.IShowEffectiveAutokeyConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IShowEffectiveAutokeyConfigRequest, + callback: Callback< + protos.google.cloud.kms.v1.IShowEffectiveAutokeyConfigResponse, + | protos.google.cloud.kms.v1.IShowEffectiveAutokeyConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): void; showEffectiveAutokeyConfig( - request?: protos.google.cloud.kms.v1.IShowEffectiveAutokeyConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.kms.v1.IShowEffectiveAutokeyConfigResponse, - protos.google.cloud.kms.v1.IShowEffectiveAutokeyConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.kms.v1.IShowEffectiveAutokeyConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.kms.v1.IShowEffectiveAutokeyConfigResponse, - protos.google.cloud.kms.v1.IShowEffectiveAutokeyConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.kms.v1.IShowEffectiveAutokeyConfigResponse, - protos.google.cloud.kms.v1.IShowEffectiveAutokeyConfigRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.kms.v1.IShowEffectiveAutokeyConfigRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.kms.v1.IShowEffectiveAutokeyConfigResponse, + | protos.google.cloud.kms.v1.IShowEffectiveAutokeyConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.kms.v1.IShowEffectiveAutokeyConfigResponse, + protos.google.cloud.kms.v1.IShowEffectiveAutokeyConfigRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.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('showEffectiveAutokeyConfig request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.kms.v1.IShowEffectiveAutokeyConfigResponse, - protos.google.cloud.kms.v1.IShowEffectiveAutokeyConfigRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.kms.v1.IShowEffectiveAutokeyConfigResponse, + | protos.google.cloud.kms.v1.IShowEffectiveAutokeyConfigRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('showEffectiveAutokeyConfig response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.showEffectiveAutokeyConfig(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.kms.v1.IShowEffectiveAutokeyConfigResponse, - protos.google.cloud.kms.v1.IShowEffectiveAutokeyConfigRequest|undefined, - {}|undefined - ]) => { - this._log.info('showEffectiveAutokeyConfig response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .showEffectiveAutokeyConfig(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.kms.v1.IShowEffectiveAutokeyConfigResponse, + ( + | protos.google.cloud.kms.v1.IShowEffectiveAutokeyConfigRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('showEffectiveAutokeyConfig response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 resource. Returns an empty policy - * if the resource exists and does not have a policy set. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {Object} [request.options] - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. This field is only used by Cloud IAM. - * - * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Gets the access control policy for a resource. Returns an empty policy + * if the resource exists and does not have a policy set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {Object} [request.options] + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. This field is only used by Cloud IAM. + * + * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ getIamPolicy( request: IamProtos.google.iam.v1.GetIamPolicyRequest, options?: @@ -722,40 +884,40 @@ export class AutokeyAdminClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.getIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ setIamPolicy( request: IamProtos.google.iam.v1.SetIamPolicyRequest, options?: @@ -769,41 +931,41 @@ export class AutokeyAdminClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.setIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + */ testIamPermissions( request: IamProtos.google.iam.v1.TestIamPermissionsRequest, options?: @@ -817,12 +979,12 @@ export class AutokeyAdminClient { IamProtos.google.iam.v1.TestIamPermissionsResponse, IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { + >, + ): Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { return this.iamClient.testIamPermissions(request, options, callback); } -/** + /** * Gets information about a location. * * @param {Object} request @@ -857,12 +1019,11 @@ export class AutokeyAdminClient { | 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. @@ -895,7 +1056,7 @@ export class AutokeyAdminClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } @@ -913,7 +1074,12 @@ export class AutokeyAdminClient { * @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, @@ -930,7 +1096,8 @@ export class AutokeyAdminClient { * @returns {string} A string representing the project. */ matchProjectFromCryptoKeyName(cryptoKeyName: string) { - return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName).project; + return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName) + .project; } /** @@ -941,7 +1108,8 @@ export class AutokeyAdminClient { * @returns {string} A string representing the location. */ matchLocationFromCryptoKeyName(cryptoKeyName: string) { - return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName).location; + return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName) + .location; } /** @@ -952,7 +1120,8 @@ export class AutokeyAdminClient { * @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; } /** @@ -963,7 +1132,8 @@ export class AutokeyAdminClient { * @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; } /** @@ -976,7 +1146,13 @@ export class AutokeyAdminClient { * @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, @@ -994,7 +1170,9 @@ export class AutokeyAdminClient { * @returns {string} A string representing the project. */ matchProjectFromCryptoKeyVersionName(cryptoKeyVersionName: string) { - return this.pathTemplates.cryptoKeyVersionPathTemplate.match(cryptoKeyVersionName).project; + return this.pathTemplates.cryptoKeyVersionPathTemplate.match( + cryptoKeyVersionName, + ).project; } /** @@ -1005,7 +1183,9 @@ export class AutokeyAdminClient { * @returns {string} A string representing the location. */ matchLocationFromCryptoKeyVersionName(cryptoKeyVersionName: string) { - return this.pathTemplates.cryptoKeyVersionPathTemplate.match(cryptoKeyVersionName).location; + return this.pathTemplates.cryptoKeyVersionPathTemplate.match( + cryptoKeyVersionName, + ).location; } /** @@ -1016,7 +1196,9 @@ export class AutokeyAdminClient { * @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; } /** @@ -1027,7 +1209,9 @@ export class AutokeyAdminClient { * @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; } /** @@ -1038,7 +1222,9 @@ export class AutokeyAdminClient { * @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; } /** @@ -1048,7 +1234,7 @@ export class AutokeyAdminClient { * @param {string} location * @returns {string} Resource name string. */ - ekmConfigPath(project:string,location:string) { + ekmConfigPath(project: string, location: string) { return this.pathTemplates.ekmConfigPathTemplate.render({ project: project, location: location, @@ -1063,7 +1249,8 @@ export class AutokeyAdminClient { * @returns {string} A string representing the project. */ matchProjectFromEkmConfigName(ekmConfigName: string) { - return this.pathTemplates.ekmConfigPathTemplate.match(ekmConfigName).project; + return this.pathTemplates.ekmConfigPathTemplate.match(ekmConfigName) + .project; } /** @@ -1074,7 +1261,8 @@ export class AutokeyAdminClient { * @returns {string} A string representing the location. */ matchLocationFromEkmConfigName(ekmConfigName: string) { - return this.pathTemplates.ekmConfigPathTemplate.match(ekmConfigName).location; + return this.pathTemplates.ekmConfigPathTemplate.match(ekmConfigName) + .location; } /** @@ -1085,7 +1273,7 @@ export class AutokeyAdminClient { * @param {string} ekm_connection * @returns {string} Resource name string. */ - ekmConnectionPath(project:string,location:string,ekmConnection:string) { + ekmConnectionPath(project: string, location: string, ekmConnection: string) { return this.pathTemplates.ekmConnectionPathTemplate.render({ project: project, location: location, @@ -1101,7 +1289,8 @@ export class AutokeyAdminClient { * @returns {string} A string representing the project. */ matchProjectFromEkmConnectionName(ekmConnectionName: string) { - return this.pathTemplates.ekmConnectionPathTemplate.match(ekmConnectionName).project; + return this.pathTemplates.ekmConnectionPathTemplate.match(ekmConnectionName) + .project; } /** @@ -1112,7 +1301,8 @@ export class AutokeyAdminClient { * @returns {string} A string representing the location. */ matchLocationFromEkmConnectionName(ekmConnectionName: string) { - return this.pathTemplates.ekmConnectionPathTemplate.match(ekmConnectionName).location; + return this.pathTemplates.ekmConnectionPathTemplate.match(ekmConnectionName) + .location; } /** @@ -1123,7 +1313,8 @@ export class AutokeyAdminClient { * @returns {string} A string representing the ekm_connection. */ matchEkmConnectionFromEkmConnectionName(ekmConnectionName: string) { - return this.pathTemplates.ekmConnectionPathTemplate.match(ekmConnectionName).ekm_connection; + return this.pathTemplates.ekmConnectionPathTemplate.match(ekmConnectionName) + .ekm_connection; } /** @@ -1132,7 +1323,7 @@ export class AutokeyAdminClient { * @param {string} folder * @returns {string} Resource name string. */ - folderAutokeyConfigPath(folder:string) { + folderAutokeyConfigPath(folder: string) { return this.pathTemplates.folderAutokeyConfigPathTemplate.render({ folder: folder, }); @@ -1146,7 +1337,9 @@ export class AutokeyAdminClient { * @returns {string} A string representing the folder. */ matchFolderFromFolderAutokeyConfigName(folderAutokeyConfigName: string) { - return this.pathTemplates.folderAutokeyConfigPathTemplate.match(folderAutokeyConfigName).folder; + return this.pathTemplates.folderAutokeyConfigPathTemplate.match( + folderAutokeyConfigName, + ).folder; } /** @@ -1158,7 +1351,12 @@ export class AutokeyAdminClient { * @param {string} import_job * @returns {string} Resource name string. */ - importJobPath(project:string,location:string,keyRing:string,importJob:string) { + importJobPath( + project: string, + location: string, + keyRing: string, + importJob: string, + ) { return this.pathTemplates.importJobPathTemplate.render({ project: project, location: location, @@ -1175,7 +1373,8 @@ export class AutokeyAdminClient { * @returns {string} A string representing the project. */ matchProjectFromImportJobName(importJobName: string) { - return this.pathTemplates.importJobPathTemplate.match(importJobName).project; + return this.pathTemplates.importJobPathTemplate.match(importJobName) + .project; } /** @@ -1186,7 +1385,8 @@ export class AutokeyAdminClient { * @returns {string} A string representing the location. */ matchLocationFromImportJobName(importJobName: string) { - return this.pathTemplates.importJobPathTemplate.match(importJobName).location; + return this.pathTemplates.importJobPathTemplate.match(importJobName) + .location; } /** @@ -1197,7 +1397,8 @@ export class AutokeyAdminClient { * @returns {string} A string representing the key_ring. */ matchKeyRingFromImportJobName(importJobName: string) { - return this.pathTemplates.importJobPathTemplate.match(importJobName).key_ring; + return this.pathTemplates.importJobPathTemplate.match(importJobName) + .key_ring; } /** @@ -1208,7 +1409,8 @@ export class AutokeyAdminClient { * @returns {string} A string representing the import_job. */ matchImportJobFromImportJobName(importJobName: string) { - return this.pathTemplates.importJobPathTemplate.match(importJobName).import_job; + return this.pathTemplates.importJobPathTemplate.match(importJobName) + .import_job; } /** @@ -1219,7 +1421,7 @@ export class AutokeyAdminClient { * @param {string} key_handle * @returns {string} Resource name string. */ - keyHandlePath(project:string,location:string,keyHandle:string) { + keyHandlePath(project: string, location: string, keyHandle: string) { return this.pathTemplates.keyHandlePathTemplate.render({ project: project, location: location, @@ -1235,7 +1437,8 @@ export class AutokeyAdminClient { * @returns {string} A string representing the project. */ matchProjectFromKeyHandleName(keyHandleName: string) { - return this.pathTemplates.keyHandlePathTemplate.match(keyHandleName).project; + return this.pathTemplates.keyHandlePathTemplate.match(keyHandleName) + .project; } /** @@ -1246,7 +1449,8 @@ export class AutokeyAdminClient { * @returns {string} A string representing the location. */ matchLocationFromKeyHandleName(keyHandleName: string) { - return this.pathTemplates.keyHandlePathTemplate.match(keyHandleName).location; + return this.pathTemplates.keyHandlePathTemplate.match(keyHandleName) + .location; } /** @@ -1257,7 +1461,8 @@ export class AutokeyAdminClient { * @returns {string} A string representing the key_handle. */ matchKeyHandleFromKeyHandleName(keyHandleName: string) { - return this.pathTemplates.keyHandlePathTemplate.match(keyHandleName).key_handle; + return this.pathTemplates.keyHandlePathTemplate.match(keyHandleName) + .key_handle; } /** @@ -1268,7 +1473,7 @@ export class AutokeyAdminClient { * @param {string} key_ring * @returns {string} Resource name string. */ - keyRingPath(project:string,location:string,keyRing:string) { + keyRingPath(project: string, location: string, keyRing: string) { return this.pathTemplates.keyRingPathTemplate.render({ project: project, location: location, @@ -1315,7 +1520,7 @@ export class AutokeyAdminClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -1338,7 +1543,7 @@ export class AutokeyAdminClient { * @param {string} project * @returns {string} Resource name string. */ - projectAutokeyConfigPath(project:string) { + projectAutokeyConfigPath(project: string) { return this.pathTemplates.projectAutokeyConfigPathTemplate.render({ project: project, }); @@ -1352,7 +1557,9 @@ export class AutokeyAdminClient { * @returns {string} A string representing the project. */ matchProjectFromProjectAutokeyConfigName(projectAutokeyConfigName: string) { - return this.pathTemplates.projectAutokeyConfigPathTemplate.match(projectAutokeyConfigName).project; + return this.pathTemplates.projectAutokeyConfigPathTemplate.match( + projectAutokeyConfigName, + ).project; } /** @@ -1365,7 +1572,13 @@ export class AutokeyAdminClient { * @param {string} crypto_key_version * @returns {string} Resource name string. */ - publicKeyPath(project:string,location:string,keyRing:string,cryptoKey:string,cryptoKeyVersion:string) { + publicKeyPath( + project: string, + location: string, + keyRing: string, + cryptoKey: string, + cryptoKeyVersion: string, + ) { return this.pathTemplates.publicKeyPathTemplate.render({ project: project, location: location, @@ -1383,7 +1596,8 @@ export class AutokeyAdminClient { * @returns {string} A string representing the project. */ matchProjectFromPublicKeyName(publicKeyName: string) { - return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName).project; + return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName) + .project; } /** @@ -1394,7 +1608,8 @@ export class AutokeyAdminClient { * @returns {string} A string representing the location. */ matchLocationFromPublicKeyName(publicKeyName: string) { - return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName).location; + return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName) + .location; } /** @@ -1405,7 +1620,8 @@ export class AutokeyAdminClient { * @returns {string} A string representing the key_ring. */ matchKeyRingFromPublicKeyName(publicKeyName: string) { - return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName).key_ring; + return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName) + .key_ring; } /** @@ -1416,7 +1632,8 @@ export class AutokeyAdminClient { * @returns {string} A string representing the crypto_key. */ matchCryptoKeyFromPublicKeyName(publicKeyName: string) { - return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName).crypto_key; + return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName) + .crypto_key; } /** @@ -1427,7 +1644,8 @@ export class AutokeyAdminClient { * @returns {string} A string representing the crypto_key_version. */ matchCryptoKeyVersionFromPublicKeyName(publicKeyName: string) { - return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName).crypto_key_version; + return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName) + .crypto_key_version; } /** @@ -1438,7 +1656,11 @@ export class AutokeyAdminClient { * @param {string} retired_resource * @returns {string} Resource name string. */ - retiredResourcePath(project:string,location:string,retiredResource:string) { + retiredResourcePath( + project: string, + location: string, + retiredResource: string, + ) { return this.pathTemplates.retiredResourcePathTemplate.render({ project: project, location: location, @@ -1454,7 +1676,9 @@ export class AutokeyAdminClient { * @returns {string} A string representing the project. */ matchProjectFromRetiredResourceName(retiredResourceName: string) { - return this.pathTemplates.retiredResourcePathTemplate.match(retiredResourceName).project; + return this.pathTemplates.retiredResourcePathTemplate.match( + retiredResourceName, + ).project; } /** @@ -1465,7 +1689,9 @@ export class AutokeyAdminClient { * @returns {string} A string representing the location. */ matchLocationFromRetiredResourceName(retiredResourceName: string) { - return this.pathTemplates.retiredResourcePathTemplate.match(retiredResourceName).location; + return this.pathTemplates.retiredResourcePathTemplate.match( + retiredResourceName, + ).location; } /** @@ -1476,7 +1702,9 @@ export class AutokeyAdminClient { * @returns {string} A string representing the retired_resource. */ matchRetiredResourceFromRetiredResourceName(retiredResourceName: string) { - return this.pathTemplates.retiredResourcePathTemplate.match(retiredResourceName).retired_resource; + return this.pathTemplates.retiredResourcePathTemplate.match( + retiredResourceName, + ).retired_resource; } /** @@ -1487,7 +1715,11 @@ export class AutokeyAdminClient { * @param {string} single_tenant_hsm_instance * @returns {string} Resource name string. */ - singleTenantHsmInstancePath(project:string,location:string,singleTenantHsmInstance:string) { + singleTenantHsmInstancePath( + project: string, + location: string, + singleTenantHsmInstance: string, + ) { return this.pathTemplates.singleTenantHsmInstancePathTemplate.render({ project: project, location: location, @@ -1502,8 +1734,12 @@ export class AutokeyAdminClient { * A fully-qualified path representing SingleTenantHsmInstance resource. * @returns {string} A string representing the project. */ - matchProjectFromSingleTenantHsmInstanceName(singleTenantHsmInstanceName: string) { - return this.pathTemplates.singleTenantHsmInstancePathTemplate.match(singleTenantHsmInstanceName).project; + matchProjectFromSingleTenantHsmInstanceName( + singleTenantHsmInstanceName: string, + ) { + return this.pathTemplates.singleTenantHsmInstancePathTemplate.match( + singleTenantHsmInstanceName, + ).project; } /** @@ -1513,8 +1749,12 @@ export class AutokeyAdminClient { * A fully-qualified path representing SingleTenantHsmInstance resource. * @returns {string} A string representing the location. */ - matchLocationFromSingleTenantHsmInstanceName(singleTenantHsmInstanceName: string) { - return this.pathTemplates.singleTenantHsmInstancePathTemplate.match(singleTenantHsmInstanceName).location; + matchLocationFromSingleTenantHsmInstanceName( + singleTenantHsmInstanceName: string, + ) { + return this.pathTemplates.singleTenantHsmInstancePathTemplate.match( + singleTenantHsmInstanceName, + ).location; } /** @@ -1524,8 +1764,12 @@ export class AutokeyAdminClient { * A fully-qualified path representing SingleTenantHsmInstance resource. * @returns {string} A string representing the single_tenant_hsm_instance. */ - matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceName(singleTenantHsmInstanceName: string) { - return this.pathTemplates.singleTenantHsmInstancePathTemplate.match(singleTenantHsmInstanceName).single_tenant_hsm_instance; + matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceName( + singleTenantHsmInstanceName: string, + ) { + return this.pathTemplates.singleTenantHsmInstancePathTemplate.match( + singleTenantHsmInstanceName, + ).single_tenant_hsm_instance; } /** @@ -1537,13 +1781,20 @@ export class AutokeyAdminClient { * @param {string} proposal * @returns {string} Resource name string. */ - singleTenantHsmInstanceProposalPath(project:string,location:string,singleTenantHsmInstance:string,proposal:string) { - return this.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.render({ - project: project, - location: location, - single_tenant_hsm_instance: singleTenantHsmInstance, - proposal: proposal, - }); + singleTenantHsmInstanceProposalPath( + project: string, + location: string, + singleTenantHsmInstance: string, + proposal: string, + ) { + return this.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.render( + { + project: project, + location: location, + single_tenant_hsm_instance: singleTenantHsmInstance, + proposal: proposal, + }, + ); } /** @@ -1553,8 +1804,12 @@ export class AutokeyAdminClient { * A fully-qualified path representing SingleTenantHsmInstanceProposal resource. * @returns {string} A string representing the project. */ - matchProjectFromSingleTenantHsmInstanceProposalName(singleTenantHsmInstanceProposalName: string) { - return this.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match(singleTenantHsmInstanceProposalName).project; + matchProjectFromSingleTenantHsmInstanceProposalName( + singleTenantHsmInstanceProposalName: string, + ) { + return this.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match( + singleTenantHsmInstanceProposalName, + ).project; } /** @@ -1564,8 +1819,12 @@ export class AutokeyAdminClient { * A fully-qualified path representing SingleTenantHsmInstanceProposal resource. * @returns {string} A string representing the location. */ - matchLocationFromSingleTenantHsmInstanceProposalName(singleTenantHsmInstanceProposalName: string) { - return this.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match(singleTenantHsmInstanceProposalName).location; + matchLocationFromSingleTenantHsmInstanceProposalName( + singleTenantHsmInstanceProposalName: string, + ) { + return this.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match( + singleTenantHsmInstanceProposalName, + ).location; } /** @@ -1575,8 +1834,12 @@ export class AutokeyAdminClient { * A fully-qualified path representing SingleTenantHsmInstanceProposal resource. * @returns {string} A string representing the single_tenant_hsm_instance. */ - matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceProposalName(singleTenantHsmInstanceProposalName: string) { - return this.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match(singleTenantHsmInstanceProposalName).single_tenant_hsm_instance; + matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceProposalName( + singleTenantHsmInstanceProposalName: string, + ) { + return this.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match( + singleTenantHsmInstanceProposalName, + ).single_tenant_hsm_instance; } /** @@ -1586,8 +1849,12 @@ export class AutokeyAdminClient { * A fully-qualified path representing SingleTenantHsmInstanceProposal resource. * @returns {string} A string representing the proposal. */ - matchProposalFromSingleTenantHsmInstanceProposalName(singleTenantHsmInstanceProposalName: string) { - return this.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match(singleTenantHsmInstanceProposalName).proposal; + matchProposalFromSingleTenantHsmInstanceProposalName( + singleTenantHsmInstanceProposalName: string, + ) { + return this.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match( + singleTenantHsmInstanceProposalName, + ).proposal; } /** @@ -1598,14 +1865,18 @@ export class AutokeyAdminClient { */ close(): Promise { if (this.autokeyAdminStub && !this._terminated) { - return this.autokeyAdminStub.then(stub => { + return this.autokeyAdminStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); - this.iamClient.close().catch(err => {throw err}); - this.locationsClient.close().catch(err => {throw err}); + this.iamClient.close().catch((err) => { + throw err; + }); + this.locationsClient.close().catch((err) => { + throw err; + }); }); } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-kms/src/v1/autokey_client.ts b/packages/google-cloud-kms/src/v1/autokey_client.ts index 7874671d9043..a177db38b245 100644 --- a/packages/google-cloud-kms/src/v1/autokey_client.ts +++ b/packages/google-cloud-kms/src/v1/autokey_client.ts @@ -18,11 +18,24 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, IamClient, IamProtos, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, + PaginationCallback, + GaxCall, + IamClient, + IamProtos, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import { Transform } from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); -import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; +import { loggingUtils as logging, decodeAnyProtosInArray } from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -61,7 +74,7 @@ export class AutokeyClient { 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('kms'); @@ -74,12 +87,12 @@ export class AutokeyClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; iamClient: IamClient; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; + pathTemplates: { [name: string]: gax.PathTemplate }; operationsClient: gax.OperationsClient; - autokeyStub?: Promise<{[name: string]: Function}>; + autokeyStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of AutokeyClient. @@ -120,21 +133,42 @@ export class AutokeyClient { * const client = new AutokeyClient({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 AutokeyClient; - 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 = 'cloudkms.' + 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; @@ -159,7 +193,7 @@ export class AutokeyClient { 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; @@ -172,18 +206,14 @@ export class AutokeyClient { this.auth.defaultScopes = staticMembers.scopes; } this.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); - + this.locationsClient = new this._gaxModule.LocationsClient( this._gaxGrpc, - opts + opts, ); - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process === 'object' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -205,55 +235,59 @@ export class AutokeyClient { // Create useful helper objects for these. this.pathTemplates = { 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}', ), ekmConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/ekmConfig' + 'projects/{project}/locations/{location}/ekmConfig', ), ekmConnectionPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/ekmConnections/{ekm_connection}' + 'projects/{project}/locations/{location}/ekmConnections/{ekm_connection}', ), folderAutokeyConfigPathTemplate: new this._gaxModule.PathTemplate( - 'folders/{folder}/autokeyConfig' + 'folders/{folder}/autokeyConfig', ), importJobPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/keyRings/{key_ring}/importJobs/{import_job}' + 'projects/{project}/locations/{location}/keyRings/{key_ring}/importJobs/{import_job}', ), keyHandlePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/keyHandles/{key_handle}' + 'projects/{project}/locations/{location}/keyHandles/{key_handle}', ), keyRingPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/keyRings/{key_ring}' + 'projects/{project}/locations/{location}/keyRings/{key_ring}', ), locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' + 'projects/{project}/locations/{location}', ), projectAutokeyConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/autokeyConfig' + 'projects/{project}/autokeyConfig', ), publicKeyPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}/publicKey' + 'projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}/publicKey', ), retiredResourcePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/retiredResources/{retired_resource}' + 'projects/{project}/locations/{location}/retiredResources/{retired_resource}', ), singleTenantHsmInstancePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/singleTenantHsmInstances/{single_tenant_hsm_instance}' - ), - singleTenantHsmInstanceProposalPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/singleTenantHsmInstances/{single_tenant_hsm_instance}/proposals/{proposal}' + 'projects/{project}/locations/{location}/singleTenantHsmInstances/{single_tenant_hsm_instance}', ), + singleTenantHsmInstanceProposalPathTemplate: + new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/singleTenantHsmInstances/{single_tenant_hsm_instance}/proposals/{proposal}', + ), }; // Some of the methods on this service return "paged" results, // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listKeyHandles: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'keyHandles') + listKeyHandles: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'keyHandles', + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -262,32 +296,114 @@ export class AutokeyClient { // rather than holding a request open. const lroOptions: GrpcClientOptions = { auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1/{name=projects/*}/locations',},{selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',get: '/v1/{resource=projects/*/locations/*/keyRings/*}:getIamPolicy',additional_bindings: [{get: '/v1/{resource=projects/*/locations/*/keyRings/*/cryptoKeys/*}:getIamPolicy',},{get: '/v1/{resource=projects/*/locations/*/keyRings/*/importJobs/*}:getIamPolicy',},{get: '/v1/{resource=projects/*/locations/*/ekmConfig}:getIamPolicy',},{get: '/v1/{resource=projects/*/locations/*/ekmConnections/*}:getIamPolicy',}], - },{selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',post: '/v1/{resource=projects/*/locations/*/keyRings/*}:setIamPolicy',body: '*',additional_bindings: [{post: '/v1/{resource=projects/*/locations/*/keyRings/*/cryptoKeys/*}:setIamPolicy',body: '*',},{post: '/v1/{resource=projects/*/locations/*/keyRings/*/importJobs/*}:setIamPolicy',body: '*',},{post: '/v1/{resource=projects/*/locations/*/ekmConfig}:setIamPolicy',body: '*',},{post: '/v1/{resource=projects/*/locations/*/ekmConnections/*}:setIamPolicy',body: '*',}], - },{selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',post: '/v1/{resource=projects/*/locations/*/keyRings/*}:testIamPermissions',body: '*',additional_bindings: [{post: '/v1/{resource=projects/*/locations/*/keyRings/*/cryptoKeys/*}:testIamPermissions',body: '*',},{post: '/v1/{resource=projects/*/locations/*/keyRings/*/importJobs/*}:testIamPermissions',body: '*',},{post: '/v1/{resource=projects/*/locations/*/ekmConfig}:testIamPermissions',body: '*',},{post: '/v1/{resource=projects/*/locations/*/ekmConnections/*}:testIamPermissions',body: '*',}], - },{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/locations/*/operations/*}',}]; + lroOptions.httpRules = [ + { + selector: 'google.cloud.location.Locations.GetLocation', + get: '/v1/{name=projects/*/locations/*}', + }, + { + selector: 'google.cloud.location.Locations.ListLocations', + get: '/v1/{name=projects/*}/locations', + }, + { + selector: 'google.iam.v1.IAMPolicy.GetIamPolicy', + get: '/v1/{resource=projects/*/locations/*/keyRings/*}:getIamPolicy', + additional_bindings: [ + { + get: '/v1/{resource=projects/*/locations/*/keyRings/*/cryptoKeys/*}:getIamPolicy', + }, + { + get: '/v1/{resource=projects/*/locations/*/keyRings/*/importJobs/*}:getIamPolicy', + }, + { + get: '/v1/{resource=projects/*/locations/*/ekmConfig}:getIamPolicy', + }, + { + get: '/v1/{resource=projects/*/locations/*/ekmConnections/*}:getIamPolicy', + }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.SetIamPolicy', + post: '/v1/{resource=projects/*/locations/*/keyRings/*}:setIamPolicy', + body: '*', + additional_bindings: [ + { + post: '/v1/{resource=projects/*/locations/*/keyRings/*/cryptoKeys/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/keyRings/*/importJobs/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/ekmConfig}:setIamPolicy', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/ekmConnections/*}:setIamPolicy', + body: '*', + }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.TestIamPermissions', + post: '/v1/{resource=projects/*/locations/*/keyRings/*}:testIamPermissions', + body: '*', + additional_bindings: [ + { + post: '/v1/{resource=projects/*/locations/*/keyRings/*/cryptoKeys/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/keyRings/*/importJobs/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/ekmConfig}:testIamPermissions', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/ekmConnections/*}:testIamPermissions', + body: '*', + }, + ], + }, + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v1/{name=projects/*/locations/*/operations/*}', + }, + ]; } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); const createKeyHandleResponse = protoFilesRoot.lookup( - '.google.cloud.kms.v1.KeyHandle') as gax.protobuf.Type; + '.google.cloud.kms.v1.KeyHandle', + ) as gax.protobuf.Type; const createKeyHandleMetadata = protoFilesRoot.lookup( - '.google.cloud.kms.v1.CreateKeyHandleMetadata') as gax.protobuf.Type; + '.google.cloud.kms.v1.CreateKeyHandleMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { createKeyHandle: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createKeyHandleResponse.decode.bind(createKeyHandleResponse), - createKeyHandleMetadata.decode.bind(createKeyHandleMetadata)) + createKeyHandleMetadata.decode.bind(createKeyHandleMetadata), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.kms.v1.Autokey', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.kms.v1.Autokey', + 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 @@ -318,28 +434,37 @@ export class AutokeyClient { // Put together the "service stub" for // google.cloud.kms.v1.Autokey. this.autokeyStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.kms.v1.Autokey') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.kms.v1.Autokey', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.kms.v1.Autokey, - 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 autokeyStubMethods = - ['createKeyHandle', 'getKeyHandle', 'listKeyHandles']; + const autokeyStubMethods = [ + 'createKeyHandle', + 'getKeyHandle', + 'listKeyHandles', + ]; for (const methodName of autokeyStubMethods) { const callPromise = this.autokeyStub.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] || @@ -349,7 +474,7 @@ export class AutokeyClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -364,8 +489,14 @@ export class AutokeyClient { * @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 'cloudkms.googleapis.com'; } @@ -376,8 +507,14 @@ export class AutokeyClient { * @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 'cloudkms.googleapis.com'; } @@ -410,7 +547,7 @@ export class AutokeyClient { static get scopes() { return [ 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/cloudkms' + 'https://www.googleapis.com/auth/cloudkms', ]; } @@ -420,8 +557,9 @@ export class AutokeyClient { * 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; @@ -432,319 +570,426 @@ export class AutokeyClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Returns the {@link protos.google.cloud.kms.v1.KeyHandle|KeyHandle}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the {@link protos.google.cloud.kms.v1.KeyHandle|KeyHandle} resource, - * e.g. - * `projects/{PROJECT_ID}/locations/{LOCATION}/keyHandles/{KEY_HANDLE_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.kms.v1.KeyHandle|KeyHandle}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/autokey.get_key_handle.js - * region_tag:cloudkms_v1_generated_Autokey_GetKeyHandle_async - */ + /** + * Returns the {@link protos.google.cloud.kms.v1.KeyHandle|KeyHandle}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the {@link protos.google.cloud.kms.v1.KeyHandle|KeyHandle} resource, + * e.g. + * `projects/{PROJECT_ID}/locations/{LOCATION}/keyHandles/{KEY_HANDLE_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.kms.v1.KeyHandle|KeyHandle}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/autokey.get_key_handle.js + * region_tag:cloudkms_v1_generated_Autokey_GetKeyHandle_async + */ getKeyHandle( - request?: protos.google.cloud.kms.v1.IGetKeyHandleRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.kms.v1.IKeyHandle, - protos.google.cloud.kms.v1.IGetKeyHandleRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.kms.v1.IGetKeyHandleRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.kms.v1.IKeyHandle, + protos.google.cloud.kms.v1.IGetKeyHandleRequest | undefined, + {} | undefined, + ] + >; getKeyHandle( - request: protos.google.cloud.kms.v1.IGetKeyHandleRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.kms.v1.IKeyHandle, - protos.google.cloud.kms.v1.IGetKeyHandleRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IGetKeyHandleRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.kms.v1.IKeyHandle, + protos.google.cloud.kms.v1.IGetKeyHandleRequest | null | undefined, + {} | null | undefined + >, + ): void; getKeyHandle( - request: protos.google.cloud.kms.v1.IGetKeyHandleRequest, - callback: Callback< - protos.google.cloud.kms.v1.IKeyHandle, - protos.google.cloud.kms.v1.IGetKeyHandleRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IGetKeyHandleRequest, + callback: Callback< + protos.google.cloud.kms.v1.IKeyHandle, + protos.google.cloud.kms.v1.IGetKeyHandleRequest | null | undefined, + {} | null | undefined + >, + ): void; getKeyHandle( - request?: protos.google.cloud.kms.v1.IGetKeyHandleRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.kms.v1.IKeyHandle, - protos.google.cloud.kms.v1.IGetKeyHandleRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.kms.v1.IGetKeyHandleRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.kms.v1.IKeyHandle, - protos.google.cloud.kms.v1.IGetKeyHandleRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.kms.v1.IKeyHandle, - protos.google.cloud.kms.v1.IGetKeyHandleRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.kms.v1.IGetKeyHandleRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.kms.v1.IKeyHandle, + protos.google.cloud.kms.v1.IGetKeyHandleRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.kms.v1.IKeyHandle, + protos.google.cloud.kms.v1.IGetKeyHandleRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getKeyHandle request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.kms.v1.IKeyHandle, - protos.google.cloud.kms.v1.IGetKeyHandleRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.kms.v1.IKeyHandle, + protos.google.cloud.kms.v1.IGetKeyHandleRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getKeyHandle response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getKeyHandle(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.kms.v1.IKeyHandle, - protos.google.cloud.kms.v1.IGetKeyHandleRequest|undefined, - {}|undefined - ]) => { - this._log.info('getKeyHandle response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getKeyHandle(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.kms.v1.IKeyHandle, + protos.google.cloud.kms.v1.IGetKeyHandleRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getKeyHandle response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 {@link protos.google.cloud.kms.v1.KeyHandle|KeyHandle}, triggering the - * provisioning of a new {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey} for CMEK - * use with the given resource type in the configured key project and the same - * location. {@link protos.google.longrunning.Operations.GetOperation|GetOperation} should - * be used to resolve the resulting long-running operation and get the - * resulting {@link protos.google.cloud.kms.v1.KeyHandle|KeyHandle} and - * {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Name of the resource project and location to create the - * {@link protos.google.cloud.kms.v1.KeyHandle|KeyHandle} in, e.g. - * `projects/{PROJECT_ID}/locations/{LOCATION}`. - * @param {string} [request.keyHandleId] - * Optional. Id of the {@link protos.google.cloud.kms.v1.KeyHandle|KeyHandle}. Must be - * unique to the resource project and location. If not provided by the caller, - * a new UUID is used. - * @param {google.cloud.kms.v1.KeyHandle} request.keyHandle - * Required. {@link protos.google.cloud.kms.v1.KeyHandle|KeyHandle} 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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/autokey.create_key_handle.js - * region_tag:cloudkms_v1_generated_Autokey_CreateKeyHandle_async - */ + /** + * Creates a new {@link protos.google.cloud.kms.v1.KeyHandle|KeyHandle}, triggering the + * provisioning of a new {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey} for CMEK + * use with the given resource type in the configured key project and the same + * location. {@link protos.google.longrunning.Operations.GetOperation|GetOperation} should + * be used to resolve the resulting long-running operation and get the + * resulting {@link protos.google.cloud.kms.v1.KeyHandle|KeyHandle} and + * {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Name of the resource project and location to create the + * {@link protos.google.cloud.kms.v1.KeyHandle|KeyHandle} in, e.g. + * `projects/{PROJECT_ID}/locations/{LOCATION}`. + * @param {string} [request.keyHandleId] + * Optional. Id of the {@link protos.google.cloud.kms.v1.KeyHandle|KeyHandle}. Must be + * unique to the resource project and location. If not provided by the caller, + * a new UUID is used. + * @param {google.cloud.kms.v1.KeyHandle} request.keyHandle + * Required. {@link protos.google.cloud.kms.v1.KeyHandle|KeyHandle} 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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/autokey.create_key_handle.js + * region_tag:cloudkms_v1_generated_Autokey_CreateKeyHandle_async + */ createKeyHandle( - request?: protos.google.cloud.kms.v1.ICreateKeyHandleRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.kms.v1.ICreateKeyHandleRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.kms.v1.IKeyHandle, + protos.google.cloud.kms.v1.ICreateKeyHandleMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createKeyHandle( - request: protos.google.cloud.kms.v1.ICreateKeyHandleRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.ICreateKeyHandleRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.kms.v1.IKeyHandle, + protos.google.cloud.kms.v1.ICreateKeyHandleMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createKeyHandle( - request: protos.google.cloud.kms.v1.ICreateKeyHandleRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.ICreateKeyHandleRequest, + callback: Callback< + LROperation< + protos.google.cloud.kms.v1.IKeyHandle, + protos.google.cloud.kms.v1.ICreateKeyHandleMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createKeyHandle( - request?: protos.google.cloud.kms.v1.ICreateKeyHandleRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.kms.v1.ICreateKeyHandleRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.kms.v1.IKeyHandle, + protos.google.cloud.kms.v1.ICreateKeyHandleMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.kms.v1.IKeyHandle, + protos.google.cloud.kms.v1.ICreateKeyHandleMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.kms.v1.IKeyHandle, + protos.google.cloud.kms.v1.ICreateKeyHandleMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-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.kms.v1.IKeyHandle, + protos.google.cloud.kms.v1.ICreateKeyHandleMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createKeyHandle response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createKeyHandle request %j', request); - return this.innerApiCalls.createKeyHandle(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createKeyHandle response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createKeyHandle(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.kms.v1.IKeyHandle, + protos.google.cloud.kms.v1.ICreateKeyHandleMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createKeyHandle response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createKeyHandle()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/autokey.create_key_handle.js - * region_tag:cloudkms_v1_generated_Autokey_CreateKeyHandle_async - */ - async checkCreateKeyHandleProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createKeyHandle()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/autokey.create_key_handle.js + * region_tag:cloudkms_v1_generated_Autokey_CreateKeyHandle_async + */ + async checkCreateKeyHandleProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.kms.v1.KeyHandle, + protos.google.cloud.kms.v1.CreateKeyHandleMetadata + > + > { this._log.info('createKeyHandle long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createKeyHandle, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createKeyHandle, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.kms.v1.KeyHandle, + protos.google.cloud.kms.v1.CreateKeyHandleMetadata + >; } - /** - * Lists {@link protos.google.cloud.kms.v1.KeyHandle|KeyHandles}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Name of the resource project and location from which to list - * {@link protos.google.cloud.kms.v1.KeyHandle|KeyHandles}, e.g. - * `projects/{PROJECT_ID}/locations/{LOCATION}`. - * @param {number} [request.pageSize] - * Optional. Optional limit on the number of - * {@link protos.google.cloud.kms.v1.KeyHandle|KeyHandles} to include in the response. The - * service may return fewer than this value. Further - * {@link protos.google.cloud.kms.v1.KeyHandle|KeyHandles} can subsequently be obtained by - * including the - * {@link protos.google.cloud.kms.v1.ListKeyHandlesResponse.next_page_token|ListKeyHandlesResponse.next_page_token} - * in a subsequent request. If unspecified, at most 100 - * {@link protos.google.cloud.kms.v1.KeyHandle|KeyHandles} will be returned. - * @param {string} [request.pageToken] - * Optional. Optional pagination token, returned earlier via - * {@link protos.google.cloud.kms.v1.ListKeyHandlesResponse.next_page_token|ListKeyHandlesResponse.next_page_token}. - * @param {string} [request.filter] - * Optional. Filter to apply when listing - * {@link protos.google.cloud.kms.v1.KeyHandle|KeyHandles}, e.g. - * `resource_type_selector="{SERVICE}.googleapis.com/{TYPE}"`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link protos.google.cloud.kms.v1.KeyHandle|KeyHandle}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listKeyHandlesAsync()` - * method described below for async iteration which you can stop as 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 {@link protos.google.cloud.kms.v1.KeyHandle|KeyHandles}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Name of the resource project and location from which to list + * {@link protos.google.cloud.kms.v1.KeyHandle|KeyHandles}, e.g. + * `projects/{PROJECT_ID}/locations/{LOCATION}`. + * @param {number} [request.pageSize] + * Optional. Optional limit on the number of + * {@link protos.google.cloud.kms.v1.KeyHandle|KeyHandles} to include in the response. The + * service may return fewer than this value. Further + * {@link protos.google.cloud.kms.v1.KeyHandle|KeyHandles} can subsequently be obtained by + * including the + * {@link protos.google.cloud.kms.v1.ListKeyHandlesResponse.next_page_token|ListKeyHandlesResponse.next_page_token} + * in a subsequent request. If unspecified, at most 100 + * {@link protos.google.cloud.kms.v1.KeyHandle|KeyHandles} will be returned. + * @param {string} [request.pageToken] + * Optional. Optional pagination token, returned earlier via + * {@link protos.google.cloud.kms.v1.ListKeyHandlesResponse.next_page_token|ListKeyHandlesResponse.next_page_token}. + * @param {string} [request.filter] + * Optional. Filter to apply when listing + * {@link protos.google.cloud.kms.v1.KeyHandle|KeyHandles}, e.g. + * `resource_type_selector="{SERVICE}.googleapis.com/{TYPE}"`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.kms.v1.KeyHandle|KeyHandle}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listKeyHandlesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listKeyHandles( - request?: protos.google.cloud.kms.v1.IListKeyHandlesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.kms.v1.IKeyHandle[], - protos.google.cloud.kms.v1.IListKeyHandlesRequest|null, - protos.google.cloud.kms.v1.IListKeyHandlesResponse - ]>; + request?: protos.google.cloud.kms.v1.IListKeyHandlesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.kms.v1.IKeyHandle[], + protos.google.cloud.kms.v1.IListKeyHandlesRequest | null, + protos.google.cloud.kms.v1.IListKeyHandlesResponse, + ] + >; listKeyHandles( - request: protos.google.cloud.kms.v1.IListKeyHandlesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.kms.v1.IListKeyHandlesRequest, - protos.google.cloud.kms.v1.IListKeyHandlesResponse|null|undefined, - protos.google.cloud.kms.v1.IKeyHandle>): void; + request: protos.google.cloud.kms.v1.IListKeyHandlesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.kms.v1.IListKeyHandlesRequest, + protos.google.cloud.kms.v1.IListKeyHandlesResponse | null | undefined, + protos.google.cloud.kms.v1.IKeyHandle + >, + ): void; listKeyHandles( - request: protos.google.cloud.kms.v1.IListKeyHandlesRequest, - callback: PaginationCallback< - protos.google.cloud.kms.v1.IListKeyHandlesRequest, - protos.google.cloud.kms.v1.IListKeyHandlesResponse|null|undefined, - protos.google.cloud.kms.v1.IKeyHandle>): void; + request: protos.google.cloud.kms.v1.IListKeyHandlesRequest, + callback: PaginationCallback< + protos.google.cloud.kms.v1.IListKeyHandlesRequest, + protos.google.cloud.kms.v1.IListKeyHandlesResponse | null | undefined, + protos.google.cloud.kms.v1.IKeyHandle + >, + ): void; listKeyHandles( - request?: protos.google.cloud.kms.v1.IListKeyHandlesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.kms.v1.IListKeyHandlesRequest, - protos.google.cloud.kms.v1.IListKeyHandlesResponse|null|undefined, - protos.google.cloud.kms.v1.IKeyHandle>, - callback?: PaginationCallback< + request?: protos.google.cloud.kms.v1.IListKeyHandlesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.kms.v1.IListKeyHandlesRequest, - protos.google.cloud.kms.v1.IListKeyHandlesResponse|null|undefined, - protos.google.cloud.kms.v1.IKeyHandle>): - Promise<[ - protos.google.cloud.kms.v1.IKeyHandle[], - protos.google.cloud.kms.v1.IListKeyHandlesRequest|null, - protos.google.cloud.kms.v1.IListKeyHandlesResponse - ]>|void { + protos.google.cloud.kms.v1.IListKeyHandlesResponse | null | undefined, + protos.google.cloud.kms.v1.IKeyHandle + >, + callback?: PaginationCallback< + protos.google.cloud.kms.v1.IListKeyHandlesRequest, + protos.google.cloud.kms.v1.IListKeyHandlesResponse | null | undefined, + protos.google.cloud.kms.v1.IKeyHandle + >, + ): Promise< + [ + protos.google.cloud.kms.v1.IKeyHandle[], + protos.google.cloud.kms.v1.IListKeyHandlesRequest | null, + protos.google.cloud.kms.v1.IListKeyHandlesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-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.kms.v1.IListKeyHandlesRequest, - protos.google.cloud.kms.v1.IListKeyHandlesResponse|null|undefined, - protos.google.cloud.kms.v1.IKeyHandle>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.kms.v1.IListKeyHandlesRequest, + protos.google.cloud.kms.v1.IListKeyHandlesResponse | null | undefined, + protos.google.cloud.kms.v1.IKeyHandle + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listKeyHandles values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -753,161 +998,165 @@ export class AutokeyClient { this._log.info('listKeyHandles request %j', request); return this.innerApiCalls .listKeyHandles(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.kms.v1.IKeyHandle[], - protos.google.cloud.kms.v1.IListKeyHandlesRequest|null, - protos.google.cloud.kms.v1.IListKeyHandlesResponse - ]) => { - this._log.info('listKeyHandles values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.kms.v1.IKeyHandle[], + protos.google.cloud.kms.v1.IListKeyHandlesRequest | null, + protos.google.cloud.kms.v1.IListKeyHandlesResponse, + ]) => { + this._log.info('listKeyHandles values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listKeyHandles`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Name of the resource project and location from which to list - * {@link protos.google.cloud.kms.v1.KeyHandle|KeyHandles}, e.g. - * `projects/{PROJECT_ID}/locations/{LOCATION}`. - * @param {number} [request.pageSize] - * Optional. Optional limit on the number of - * {@link protos.google.cloud.kms.v1.KeyHandle|KeyHandles} to include in the response. The - * service may return fewer than this value. Further - * {@link protos.google.cloud.kms.v1.KeyHandle|KeyHandles} can subsequently be obtained by - * including the - * {@link protos.google.cloud.kms.v1.ListKeyHandlesResponse.next_page_token|ListKeyHandlesResponse.next_page_token} - * in a subsequent request. If unspecified, at most 100 - * {@link protos.google.cloud.kms.v1.KeyHandle|KeyHandles} will be returned. - * @param {string} [request.pageToken] - * Optional. Optional pagination token, returned earlier via - * {@link protos.google.cloud.kms.v1.ListKeyHandlesResponse.next_page_token|ListKeyHandlesResponse.next_page_token}. - * @param {string} [request.filter] - * Optional. Filter to apply when listing - * {@link protos.google.cloud.kms.v1.KeyHandle|KeyHandles}, e.g. - * `resource_type_selector="{SERVICE}.googleapis.com/{TYPE}"`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.kms.v1.KeyHandle|KeyHandle} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listKeyHandlesAsync()` - * method described below for async iteration which you can stop as 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 `listKeyHandles`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Name of the resource project and location from which to list + * {@link protos.google.cloud.kms.v1.KeyHandle|KeyHandles}, e.g. + * `projects/{PROJECT_ID}/locations/{LOCATION}`. + * @param {number} [request.pageSize] + * Optional. Optional limit on the number of + * {@link protos.google.cloud.kms.v1.KeyHandle|KeyHandles} to include in the response. The + * service may return fewer than this value. Further + * {@link protos.google.cloud.kms.v1.KeyHandle|KeyHandles} can subsequently be obtained by + * including the + * {@link protos.google.cloud.kms.v1.ListKeyHandlesResponse.next_page_token|ListKeyHandlesResponse.next_page_token} + * in a subsequent request. If unspecified, at most 100 + * {@link protos.google.cloud.kms.v1.KeyHandle|KeyHandles} will be returned. + * @param {string} [request.pageToken] + * Optional. Optional pagination token, returned earlier via + * {@link protos.google.cloud.kms.v1.ListKeyHandlesResponse.next_page_token|ListKeyHandlesResponse.next_page_token}. + * @param {string} [request.filter] + * Optional. Filter to apply when listing + * {@link protos.google.cloud.kms.v1.KeyHandle|KeyHandles}, e.g. + * `resource_type_selector="{SERVICE}.googleapis.com/{TYPE}"`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.kms.v1.KeyHandle|KeyHandle} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listKeyHandlesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listKeyHandlesStream( - request?: protos.google.cloud.kms.v1.IListKeyHandlesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.kms.v1.IListKeyHandlesRequest, + 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['listKeyHandles']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listKeyHandles stream %j', request); return this.descriptors.page.listKeyHandles.createStream( this.innerApiCalls.listKeyHandles as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listKeyHandles`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Name of the resource project and location from which to list - * {@link protos.google.cloud.kms.v1.KeyHandle|KeyHandles}, e.g. - * `projects/{PROJECT_ID}/locations/{LOCATION}`. - * @param {number} [request.pageSize] - * Optional. Optional limit on the number of - * {@link protos.google.cloud.kms.v1.KeyHandle|KeyHandles} to include in the response. The - * service may return fewer than this value. Further - * {@link protos.google.cloud.kms.v1.KeyHandle|KeyHandles} can subsequently be obtained by - * including the - * {@link protos.google.cloud.kms.v1.ListKeyHandlesResponse.next_page_token|ListKeyHandlesResponse.next_page_token} - * in a subsequent request. If unspecified, at most 100 - * {@link protos.google.cloud.kms.v1.KeyHandle|KeyHandles} will be returned. - * @param {string} [request.pageToken] - * Optional. Optional pagination token, returned earlier via - * {@link protos.google.cloud.kms.v1.ListKeyHandlesResponse.next_page_token|ListKeyHandlesResponse.next_page_token}. - * @param {string} [request.filter] - * Optional. Filter to apply when listing - * {@link protos.google.cloud.kms.v1.KeyHandle|KeyHandles}, e.g. - * `resource_type_selector="{SERVICE}.googleapis.com/{TYPE}"`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.kms.v1.KeyHandle|KeyHandle}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@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/autokey.list_key_handles.js - * region_tag:cloudkms_v1_generated_Autokey_ListKeyHandles_async - */ + /** + * Equivalent to `listKeyHandles`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Name of the resource project and location from which to list + * {@link protos.google.cloud.kms.v1.KeyHandle|KeyHandles}, e.g. + * `projects/{PROJECT_ID}/locations/{LOCATION}`. + * @param {number} [request.pageSize] + * Optional. Optional limit on the number of + * {@link protos.google.cloud.kms.v1.KeyHandle|KeyHandles} to include in the response. The + * service may return fewer than this value. Further + * {@link protos.google.cloud.kms.v1.KeyHandle|KeyHandles} can subsequently be obtained by + * including the + * {@link protos.google.cloud.kms.v1.ListKeyHandlesResponse.next_page_token|ListKeyHandlesResponse.next_page_token} + * in a subsequent request. If unspecified, at most 100 + * {@link protos.google.cloud.kms.v1.KeyHandle|KeyHandles} will be returned. + * @param {string} [request.pageToken] + * Optional. Optional pagination token, returned earlier via + * {@link protos.google.cloud.kms.v1.ListKeyHandlesResponse.next_page_token|ListKeyHandlesResponse.next_page_token}. + * @param {string} [request.filter] + * Optional. Filter to apply when listing + * {@link protos.google.cloud.kms.v1.KeyHandle|KeyHandles}, e.g. + * `resource_type_selector="{SERVICE}.googleapis.com/{TYPE}"`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.kms.v1.KeyHandle|KeyHandle}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@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/autokey.list_key_handles.js + * region_tag:cloudkms_v1_generated_Autokey_ListKeyHandles_async + */ listKeyHandlesAsync( - request?: protos.google.cloud.kms.v1.IListKeyHandlesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.kms.v1.IListKeyHandlesRequest, + 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['listKeyHandles']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listKeyHandles iterate %j', request); return this.descriptors.page.listKeyHandles.asyncIterate( this.innerApiCalls['listKeyHandles'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** - * Gets the access control policy for a resource. Returns an empty policy - * if the resource exists and does not have a policy set. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {Object} [request.options] - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. This field is only used by Cloud IAM. - * - * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Gets the access control policy for a resource. Returns an empty policy + * if the resource exists and does not have a policy set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {Object} [request.options] + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. This field is only used by Cloud IAM. + * + * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ getIamPolicy( request: IamProtos.google.iam.v1.GetIamPolicyRequest, options?: @@ -921,40 +1170,40 @@ export class AutokeyClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.getIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ setIamPolicy( request: IamProtos.google.iam.v1.SetIamPolicyRequest, options?: @@ -968,41 +1217,41 @@ export class AutokeyClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.setIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + */ testIamPermissions( request: IamProtos.google.iam.v1.TestIamPermissionsRequest, options?: @@ -1016,12 +1265,12 @@ export class AutokeyClient { IamProtos.google.iam.v1.TestIamPermissionsResponse, IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { + >, + ): Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { return this.iamClient.testIamPermissions(request, options, callback); } -/** + /** * Gets information about a location. * * @param {Object} request @@ -1056,12 +1305,11 @@ export class AutokeyClient { | 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. @@ -1094,12 +1342,12 @@ export class AutokeyClient { */ 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. @@ -1142,22 +1390,22 @@ export class AutokeyClient { 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); } /** @@ -1192,15 +1440,15 @@ export class AutokeyClient { */ 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); } /** @@ -1234,7 +1482,7 @@ export class AutokeyClient { * await client.cancelOperation({name: ''}); * ``` */ - cancelOperation( + cancelOperation( request: protos.google.longrunning.CancelOperationRequest, optionsOrCallback?: | gax.CallOptions @@ -1247,25 +1495,24 @@ export class AutokeyClient { 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 @@ -1304,22 +1551,22 @@ export class AutokeyClient { 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); } @@ -1336,7 +1583,12 @@ export class AutokeyClient { * @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, @@ -1353,7 +1605,8 @@ export class AutokeyClient { * @returns {string} A string representing the project. */ matchProjectFromCryptoKeyName(cryptoKeyName: string) { - return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName).project; + return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName) + .project; } /** @@ -1364,7 +1617,8 @@ export class AutokeyClient { * @returns {string} A string representing the location. */ matchLocationFromCryptoKeyName(cryptoKeyName: string) { - return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName).location; + return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName) + .location; } /** @@ -1375,7 +1629,8 @@ export class AutokeyClient { * @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; } /** @@ -1386,7 +1641,8 @@ export class AutokeyClient { * @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; } /** @@ -1399,7 +1655,13 @@ export class AutokeyClient { * @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, @@ -1417,7 +1679,9 @@ export class AutokeyClient { * @returns {string} A string representing the project. */ matchProjectFromCryptoKeyVersionName(cryptoKeyVersionName: string) { - return this.pathTemplates.cryptoKeyVersionPathTemplate.match(cryptoKeyVersionName).project; + return this.pathTemplates.cryptoKeyVersionPathTemplate.match( + cryptoKeyVersionName, + ).project; } /** @@ -1428,7 +1692,9 @@ export class AutokeyClient { * @returns {string} A string representing the location. */ matchLocationFromCryptoKeyVersionName(cryptoKeyVersionName: string) { - return this.pathTemplates.cryptoKeyVersionPathTemplate.match(cryptoKeyVersionName).location; + return this.pathTemplates.cryptoKeyVersionPathTemplate.match( + cryptoKeyVersionName, + ).location; } /** @@ -1439,7 +1705,9 @@ export class AutokeyClient { * @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; } /** @@ -1450,7 +1718,9 @@ export class AutokeyClient { * @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; } /** @@ -1461,7 +1731,9 @@ export class AutokeyClient { * @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; } /** @@ -1471,7 +1743,7 @@ export class AutokeyClient { * @param {string} location * @returns {string} Resource name string. */ - ekmConfigPath(project:string,location:string) { + ekmConfigPath(project: string, location: string) { return this.pathTemplates.ekmConfigPathTemplate.render({ project: project, location: location, @@ -1486,7 +1758,8 @@ export class AutokeyClient { * @returns {string} A string representing the project. */ matchProjectFromEkmConfigName(ekmConfigName: string) { - return this.pathTemplates.ekmConfigPathTemplate.match(ekmConfigName).project; + return this.pathTemplates.ekmConfigPathTemplate.match(ekmConfigName) + .project; } /** @@ -1497,7 +1770,8 @@ export class AutokeyClient { * @returns {string} A string representing the location. */ matchLocationFromEkmConfigName(ekmConfigName: string) { - return this.pathTemplates.ekmConfigPathTemplate.match(ekmConfigName).location; + return this.pathTemplates.ekmConfigPathTemplate.match(ekmConfigName) + .location; } /** @@ -1508,7 +1782,7 @@ export class AutokeyClient { * @param {string} ekm_connection * @returns {string} Resource name string. */ - ekmConnectionPath(project:string,location:string,ekmConnection:string) { + ekmConnectionPath(project: string, location: string, ekmConnection: string) { return this.pathTemplates.ekmConnectionPathTemplate.render({ project: project, location: location, @@ -1524,7 +1798,8 @@ export class AutokeyClient { * @returns {string} A string representing the project. */ matchProjectFromEkmConnectionName(ekmConnectionName: string) { - return this.pathTemplates.ekmConnectionPathTemplate.match(ekmConnectionName).project; + return this.pathTemplates.ekmConnectionPathTemplate.match(ekmConnectionName) + .project; } /** @@ -1535,7 +1810,8 @@ export class AutokeyClient { * @returns {string} A string representing the location. */ matchLocationFromEkmConnectionName(ekmConnectionName: string) { - return this.pathTemplates.ekmConnectionPathTemplate.match(ekmConnectionName).location; + return this.pathTemplates.ekmConnectionPathTemplate.match(ekmConnectionName) + .location; } /** @@ -1546,7 +1822,8 @@ export class AutokeyClient { * @returns {string} A string representing the ekm_connection. */ matchEkmConnectionFromEkmConnectionName(ekmConnectionName: string) { - return this.pathTemplates.ekmConnectionPathTemplate.match(ekmConnectionName).ekm_connection; + return this.pathTemplates.ekmConnectionPathTemplate.match(ekmConnectionName) + .ekm_connection; } /** @@ -1555,7 +1832,7 @@ export class AutokeyClient { * @param {string} folder * @returns {string} Resource name string. */ - folderAutokeyConfigPath(folder:string) { + folderAutokeyConfigPath(folder: string) { return this.pathTemplates.folderAutokeyConfigPathTemplate.render({ folder: folder, }); @@ -1569,7 +1846,9 @@ export class AutokeyClient { * @returns {string} A string representing the folder. */ matchFolderFromFolderAutokeyConfigName(folderAutokeyConfigName: string) { - return this.pathTemplates.folderAutokeyConfigPathTemplate.match(folderAutokeyConfigName).folder; + return this.pathTemplates.folderAutokeyConfigPathTemplate.match( + folderAutokeyConfigName, + ).folder; } /** @@ -1581,7 +1860,12 @@ export class AutokeyClient { * @param {string} import_job * @returns {string} Resource name string. */ - importJobPath(project:string,location:string,keyRing:string,importJob:string) { + importJobPath( + project: string, + location: string, + keyRing: string, + importJob: string, + ) { return this.pathTemplates.importJobPathTemplate.render({ project: project, location: location, @@ -1598,7 +1882,8 @@ export class AutokeyClient { * @returns {string} A string representing the project. */ matchProjectFromImportJobName(importJobName: string) { - return this.pathTemplates.importJobPathTemplate.match(importJobName).project; + return this.pathTemplates.importJobPathTemplate.match(importJobName) + .project; } /** @@ -1609,7 +1894,8 @@ export class AutokeyClient { * @returns {string} A string representing the location. */ matchLocationFromImportJobName(importJobName: string) { - return this.pathTemplates.importJobPathTemplate.match(importJobName).location; + return this.pathTemplates.importJobPathTemplate.match(importJobName) + .location; } /** @@ -1620,7 +1906,8 @@ export class AutokeyClient { * @returns {string} A string representing the key_ring. */ matchKeyRingFromImportJobName(importJobName: string) { - return this.pathTemplates.importJobPathTemplate.match(importJobName).key_ring; + return this.pathTemplates.importJobPathTemplate.match(importJobName) + .key_ring; } /** @@ -1631,7 +1918,8 @@ export class AutokeyClient { * @returns {string} A string representing the import_job. */ matchImportJobFromImportJobName(importJobName: string) { - return this.pathTemplates.importJobPathTemplate.match(importJobName).import_job; + return this.pathTemplates.importJobPathTemplate.match(importJobName) + .import_job; } /** @@ -1642,7 +1930,7 @@ export class AutokeyClient { * @param {string} key_handle * @returns {string} Resource name string. */ - keyHandlePath(project:string,location:string,keyHandle:string) { + keyHandlePath(project: string, location: string, keyHandle: string) { return this.pathTemplates.keyHandlePathTemplate.render({ project: project, location: location, @@ -1658,7 +1946,8 @@ export class AutokeyClient { * @returns {string} A string representing the project. */ matchProjectFromKeyHandleName(keyHandleName: string) { - return this.pathTemplates.keyHandlePathTemplate.match(keyHandleName).project; + return this.pathTemplates.keyHandlePathTemplate.match(keyHandleName) + .project; } /** @@ -1669,7 +1958,8 @@ export class AutokeyClient { * @returns {string} A string representing the location. */ matchLocationFromKeyHandleName(keyHandleName: string) { - return this.pathTemplates.keyHandlePathTemplate.match(keyHandleName).location; + return this.pathTemplates.keyHandlePathTemplate.match(keyHandleName) + .location; } /** @@ -1680,7 +1970,8 @@ export class AutokeyClient { * @returns {string} A string representing the key_handle. */ matchKeyHandleFromKeyHandleName(keyHandleName: string) { - return this.pathTemplates.keyHandlePathTemplate.match(keyHandleName).key_handle; + return this.pathTemplates.keyHandlePathTemplate.match(keyHandleName) + .key_handle; } /** @@ -1691,7 +1982,7 @@ export class AutokeyClient { * @param {string} key_ring * @returns {string} Resource name string. */ - keyRingPath(project:string,location:string,keyRing:string) { + keyRingPath(project: string, location: string, keyRing: string) { return this.pathTemplates.keyRingPathTemplate.render({ project: project, location: location, @@ -1739,7 +2030,7 @@ export class AutokeyClient { * @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, @@ -1774,7 +2065,7 @@ export class AutokeyClient { * @param {string} project * @returns {string} Resource name string. */ - projectAutokeyConfigPath(project:string) { + projectAutokeyConfigPath(project: string) { return this.pathTemplates.projectAutokeyConfigPathTemplate.render({ project: project, }); @@ -1788,7 +2079,9 @@ export class AutokeyClient { * @returns {string} A string representing the project. */ matchProjectFromProjectAutokeyConfigName(projectAutokeyConfigName: string) { - return this.pathTemplates.projectAutokeyConfigPathTemplate.match(projectAutokeyConfigName).project; + return this.pathTemplates.projectAutokeyConfigPathTemplate.match( + projectAutokeyConfigName, + ).project; } /** @@ -1801,7 +2094,13 @@ export class AutokeyClient { * @param {string} crypto_key_version * @returns {string} Resource name string. */ - publicKeyPath(project:string,location:string,keyRing:string,cryptoKey:string,cryptoKeyVersion:string) { + publicKeyPath( + project: string, + location: string, + keyRing: string, + cryptoKey: string, + cryptoKeyVersion: string, + ) { return this.pathTemplates.publicKeyPathTemplate.render({ project: project, location: location, @@ -1819,7 +2118,8 @@ export class AutokeyClient { * @returns {string} A string representing the project. */ matchProjectFromPublicKeyName(publicKeyName: string) { - return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName).project; + return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName) + .project; } /** @@ -1830,7 +2130,8 @@ export class AutokeyClient { * @returns {string} A string representing the location. */ matchLocationFromPublicKeyName(publicKeyName: string) { - return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName).location; + return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName) + .location; } /** @@ -1841,7 +2142,8 @@ export class AutokeyClient { * @returns {string} A string representing the key_ring. */ matchKeyRingFromPublicKeyName(publicKeyName: string) { - return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName).key_ring; + return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName) + .key_ring; } /** @@ -1852,7 +2154,8 @@ export class AutokeyClient { * @returns {string} A string representing the crypto_key. */ matchCryptoKeyFromPublicKeyName(publicKeyName: string) { - return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName).crypto_key; + return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName) + .crypto_key; } /** @@ -1863,7 +2166,8 @@ export class AutokeyClient { * @returns {string} A string representing the crypto_key_version. */ matchCryptoKeyVersionFromPublicKeyName(publicKeyName: string) { - return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName).crypto_key_version; + return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName) + .crypto_key_version; } /** @@ -1874,7 +2178,11 @@ export class AutokeyClient { * @param {string} retired_resource * @returns {string} Resource name string. */ - retiredResourcePath(project:string,location:string,retiredResource:string) { + retiredResourcePath( + project: string, + location: string, + retiredResource: string, + ) { return this.pathTemplates.retiredResourcePathTemplate.render({ project: project, location: location, @@ -1890,7 +2198,9 @@ export class AutokeyClient { * @returns {string} A string representing the project. */ matchProjectFromRetiredResourceName(retiredResourceName: string) { - return this.pathTemplates.retiredResourcePathTemplate.match(retiredResourceName).project; + return this.pathTemplates.retiredResourcePathTemplate.match( + retiredResourceName, + ).project; } /** @@ -1901,7 +2211,9 @@ export class AutokeyClient { * @returns {string} A string representing the location. */ matchLocationFromRetiredResourceName(retiredResourceName: string) { - return this.pathTemplates.retiredResourcePathTemplate.match(retiredResourceName).location; + return this.pathTemplates.retiredResourcePathTemplate.match( + retiredResourceName, + ).location; } /** @@ -1912,7 +2224,9 @@ export class AutokeyClient { * @returns {string} A string representing the retired_resource. */ matchRetiredResourceFromRetiredResourceName(retiredResourceName: string) { - return this.pathTemplates.retiredResourcePathTemplate.match(retiredResourceName).retired_resource; + return this.pathTemplates.retiredResourcePathTemplate.match( + retiredResourceName, + ).retired_resource; } /** @@ -1923,7 +2237,11 @@ export class AutokeyClient { * @param {string} single_tenant_hsm_instance * @returns {string} Resource name string. */ - singleTenantHsmInstancePath(project:string,location:string,singleTenantHsmInstance:string) { + singleTenantHsmInstancePath( + project: string, + location: string, + singleTenantHsmInstance: string, + ) { return this.pathTemplates.singleTenantHsmInstancePathTemplate.render({ project: project, location: location, @@ -1938,8 +2256,12 @@ export class AutokeyClient { * A fully-qualified path representing SingleTenantHsmInstance resource. * @returns {string} A string representing the project. */ - matchProjectFromSingleTenantHsmInstanceName(singleTenantHsmInstanceName: string) { - return this.pathTemplates.singleTenantHsmInstancePathTemplate.match(singleTenantHsmInstanceName).project; + matchProjectFromSingleTenantHsmInstanceName( + singleTenantHsmInstanceName: string, + ) { + return this.pathTemplates.singleTenantHsmInstancePathTemplate.match( + singleTenantHsmInstanceName, + ).project; } /** @@ -1949,8 +2271,12 @@ export class AutokeyClient { * A fully-qualified path representing SingleTenantHsmInstance resource. * @returns {string} A string representing the location. */ - matchLocationFromSingleTenantHsmInstanceName(singleTenantHsmInstanceName: string) { - return this.pathTemplates.singleTenantHsmInstancePathTemplate.match(singleTenantHsmInstanceName).location; + matchLocationFromSingleTenantHsmInstanceName( + singleTenantHsmInstanceName: string, + ) { + return this.pathTemplates.singleTenantHsmInstancePathTemplate.match( + singleTenantHsmInstanceName, + ).location; } /** @@ -1960,8 +2286,12 @@ export class AutokeyClient { * A fully-qualified path representing SingleTenantHsmInstance resource. * @returns {string} A string representing the single_tenant_hsm_instance. */ - matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceName(singleTenantHsmInstanceName: string) { - return this.pathTemplates.singleTenantHsmInstancePathTemplate.match(singleTenantHsmInstanceName).single_tenant_hsm_instance; + matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceName( + singleTenantHsmInstanceName: string, + ) { + return this.pathTemplates.singleTenantHsmInstancePathTemplate.match( + singleTenantHsmInstanceName, + ).single_tenant_hsm_instance; } /** @@ -1973,13 +2303,20 @@ export class AutokeyClient { * @param {string} proposal * @returns {string} Resource name string. */ - singleTenantHsmInstanceProposalPath(project:string,location:string,singleTenantHsmInstance:string,proposal:string) { - return this.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.render({ - project: project, - location: location, - single_tenant_hsm_instance: singleTenantHsmInstance, - proposal: proposal, - }); + singleTenantHsmInstanceProposalPath( + project: string, + location: string, + singleTenantHsmInstance: string, + proposal: string, + ) { + return this.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.render( + { + project: project, + location: location, + single_tenant_hsm_instance: singleTenantHsmInstance, + proposal: proposal, + }, + ); } /** @@ -1989,8 +2326,12 @@ export class AutokeyClient { * A fully-qualified path representing SingleTenantHsmInstanceProposal resource. * @returns {string} A string representing the project. */ - matchProjectFromSingleTenantHsmInstanceProposalName(singleTenantHsmInstanceProposalName: string) { - return this.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match(singleTenantHsmInstanceProposalName).project; + matchProjectFromSingleTenantHsmInstanceProposalName( + singleTenantHsmInstanceProposalName: string, + ) { + return this.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match( + singleTenantHsmInstanceProposalName, + ).project; } /** @@ -2000,8 +2341,12 @@ export class AutokeyClient { * A fully-qualified path representing SingleTenantHsmInstanceProposal resource. * @returns {string} A string representing the location. */ - matchLocationFromSingleTenantHsmInstanceProposalName(singleTenantHsmInstanceProposalName: string) { - return this.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match(singleTenantHsmInstanceProposalName).location; + matchLocationFromSingleTenantHsmInstanceProposalName( + singleTenantHsmInstanceProposalName: string, + ) { + return this.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match( + singleTenantHsmInstanceProposalName, + ).location; } /** @@ -2011,8 +2356,12 @@ export class AutokeyClient { * A fully-qualified path representing SingleTenantHsmInstanceProposal resource. * @returns {string} A string representing the single_tenant_hsm_instance. */ - matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceProposalName(singleTenantHsmInstanceProposalName: string) { - return this.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match(singleTenantHsmInstanceProposalName).single_tenant_hsm_instance; + matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceProposalName( + singleTenantHsmInstanceProposalName: string, + ) { + return this.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match( + singleTenantHsmInstanceProposalName, + ).single_tenant_hsm_instance; } /** @@ -2022,8 +2371,12 @@ export class AutokeyClient { * A fully-qualified path representing SingleTenantHsmInstanceProposal resource. * @returns {string} A string representing the proposal. */ - matchProposalFromSingleTenantHsmInstanceProposalName(singleTenantHsmInstanceProposalName: string) { - return this.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match(singleTenantHsmInstanceProposalName).proposal; + matchProposalFromSingleTenantHsmInstanceProposalName( + singleTenantHsmInstanceProposalName: string, + ) { + return this.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match( + singleTenantHsmInstanceProposalName, + ).proposal; } /** @@ -2034,15 +2387,19 @@ export class AutokeyClient { */ close(): Promise { if (this.autokeyStub && !this._terminated) { - return this.autokeyStub.then(stub => { + return this.autokeyStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); - this.iamClient.close().catch(err => {throw err}); - this.locationsClient.close().catch(err => {throw err}); + this.iamClient.close().catch((err) => { + throw err; + }); + this.locationsClient.close().catch((err) => { + throw err; + }); void this.operationsClient.close(); }); } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-kms/src/v1/ekm_service_client.ts b/packages/google-cloud-kms/src/v1/ekm_service_client.ts index 9613fde4c2a2..765c14e5c9a8 100644 --- a/packages/google-cloud-kms/src/v1/ekm_service_client.ts +++ b/packages/google-cloud-kms/src/v1/ekm_service_client.ts @@ -18,11 +18,22 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall, IamClient, IamProtos, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + PaginationCallback, + GaxCall, + IamClient, + IamProtos, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import { Transform } from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); -import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; +import { loggingUtils as logging, decodeAnyProtosInArray } from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -48,7 +59,7 @@ export class EkmServiceClient { 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('kms'); @@ -61,11 +72,11 @@ export class EkmServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; iamClient: IamClient; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - ekmServiceStub?: Promise<{[name: string]: Function}>; + pathTemplates: { [name: string]: gax.PathTemplate }; + ekmServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of EkmServiceClient. @@ -106,21 +117,42 @@ export class EkmServiceClient { * const client = new EkmServiceClient({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 EkmServiceClient; - 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 = 'cloudkms.' + 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; @@ -145,7 +177,7 @@ export class EkmServiceClient { 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,18 +190,14 @@ export class EkmServiceClient { this.auth.defaultScopes = staticMembers.scopes; } this.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); - + this.locationsClient = new this._gaxModule.LocationsClient( this._gaxGrpc, - opts + opts, ); - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process === 'object' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -191,61 +219,68 @@ export class EkmServiceClient { // Create useful helper objects for these. this.pathTemplates = { 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}', ), ekmConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/ekmConfig' + 'projects/{project}/locations/{location}/ekmConfig', ), ekmConnectionPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/ekmConnections/{ekm_connection}' + 'projects/{project}/locations/{location}/ekmConnections/{ekm_connection}', ), folderAutokeyConfigPathTemplate: new this._gaxModule.PathTemplate( - 'folders/{folder}/autokeyConfig' + 'folders/{folder}/autokeyConfig', ), importJobPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/keyRings/{key_ring}/importJobs/{import_job}' + 'projects/{project}/locations/{location}/keyRings/{key_ring}/importJobs/{import_job}', ), keyHandlePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/keyHandles/{key_handle}' + 'projects/{project}/locations/{location}/keyHandles/{key_handle}', ), keyRingPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/keyRings/{key_ring}' + 'projects/{project}/locations/{location}/keyRings/{key_ring}', ), locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' + 'projects/{project}/locations/{location}', ), projectAutokeyConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/autokeyConfig' + 'projects/{project}/autokeyConfig', ), publicKeyPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}/publicKey' + 'projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}/publicKey', ), retiredResourcePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/retiredResources/{retired_resource}' + 'projects/{project}/locations/{location}/retiredResources/{retired_resource}', ), singleTenantHsmInstancePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/singleTenantHsmInstances/{single_tenant_hsm_instance}' - ), - singleTenantHsmInstanceProposalPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/singleTenantHsmInstances/{single_tenant_hsm_instance}/proposals/{proposal}' + 'projects/{project}/locations/{location}/singleTenantHsmInstances/{single_tenant_hsm_instance}', ), + singleTenantHsmInstanceProposalPathTemplate: + new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/singleTenantHsmInstances/{single_tenant_hsm_instance}/proposals/{proposal}', + ), }; // Some of the methods on this service return "paged" results, // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listEkmConnections: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'ekmConnections') + listEkmConnections: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'ekmConnections', + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.kms.v1.EkmService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.kms.v1.EkmService', + 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 @@ -276,37 +311,48 @@ export class EkmServiceClient { // Put together the "service stub" for // google.cloud.kms.v1.EkmService. this.ekmServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.kms.v1.EkmService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.kms.v1.EkmService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.kms.v1.EkmService, - 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 ekmServiceStubMethods = - ['listEkmConnections', 'getEkmConnection', 'createEkmConnection', 'updateEkmConnection', 'getEkmConfig', 'updateEkmConfig', 'verifyConnectivity']; + const ekmServiceStubMethods = [ + 'listEkmConnections', + 'getEkmConnection', + 'createEkmConnection', + 'updateEkmConnection', + 'getEkmConfig', + 'updateEkmConfig', + 'verifyConnectivity', + ]; for (const methodName of ekmServiceStubMethods) { const callPromise = this.ekmServiceStub.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; @@ -321,8 +367,14 @@ export class EkmServiceClient { * @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 'cloudkms.googleapis.com'; } @@ -333,8 +385,14 @@ export class EkmServiceClient { * @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 'cloudkms.googleapis.com'; } @@ -367,7 +425,7 @@ export class EkmServiceClient { static get scopes() { return [ 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/cloudkms' + 'https://www.googleapis.com/auth/cloudkms', ]; } @@ -377,8 +435,9 @@ export class EkmServiceClient { * 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,695 +448,910 @@ export class EkmServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Returns metadata for a given - * {@link protos.google.cloud.kms.v1.EkmConnection|EkmConnection}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The {@link protos.google.cloud.kms.v1.EkmConnection.name|name} of the - * {@link protos.google.cloud.kms.v1.EkmConnection|EkmConnection} 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.kms.v1.EkmConnection|EkmConnection}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/ekm_service.get_ekm_connection.js - * region_tag:cloudkms_v1_generated_EkmService_GetEkmConnection_async - */ + /** + * Returns metadata for a given + * {@link protos.google.cloud.kms.v1.EkmConnection|EkmConnection}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The {@link protos.google.cloud.kms.v1.EkmConnection.name|name} of the + * {@link protos.google.cloud.kms.v1.EkmConnection|EkmConnection} 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.kms.v1.EkmConnection|EkmConnection}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/ekm_service.get_ekm_connection.js + * region_tag:cloudkms_v1_generated_EkmService_GetEkmConnection_async + */ getEkmConnection( - request?: protos.google.cloud.kms.v1.IGetEkmConnectionRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.kms.v1.IEkmConnection, - protos.google.cloud.kms.v1.IGetEkmConnectionRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.kms.v1.IGetEkmConnectionRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.kms.v1.IEkmConnection, + protos.google.cloud.kms.v1.IGetEkmConnectionRequest | undefined, + {} | undefined, + ] + >; getEkmConnection( - request: protos.google.cloud.kms.v1.IGetEkmConnectionRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.kms.v1.IEkmConnection, - protos.google.cloud.kms.v1.IGetEkmConnectionRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IGetEkmConnectionRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.kms.v1.IEkmConnection, + protos.google.cloud.kms.v1.IGetEkmConnectionRequest | null | undefined, + {} | null | undefined + >, + ): void; getEkmConnection( - request: protos.google.cloud.kms.v1.IGetEkmConnectionRequest, - callback: Callback< - protos.google.cloud.kms.v1.IEkmConnection, - protos.google.cloud.kms.v1.IGetEkmConnectionRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IGetEkmConnectionRequest, + callback: Callback< + protos.google.cloud.kms.v1.IEkmConnection, + protos.google.cloud.kms.v1.IGetEkmConnectionRequest | null | undefined, + {} | null | undefined + >, + ): void; getEkmConnection( - request?: protos.google.cloud.kms.v1.IGetEkmConnectionRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.kms.v1.IEkmConnection, - protos.google.cloud.kms.v1.IGetEkmConnectionRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.kms.v1.IGetEkmConnectionRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.kms.v1.IEkmConnection, - protos.google.cloud.kms.v1.IGetEkmConnectionRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.kms.v1.IEkmConnection, - protos.google.cloud.kms.v1.IGetEkmConnectionRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.kms.v1.IGetEkmConnectionRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.kms.v1.IEkmConnection, + protos.google.cloud.kms.v1.IGetEkmConnectionRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.kms.v1.IEkmConnection, + protos.google.cloud.kms.v1.IGetEkmConnectionRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getEkmConnection request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.kms.v1.IEkmConnection, - protos.google.cloud.kms.v1.IGetEkmConnectionRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.kms.v1.IEkmConnection, + | protos.google.cloud.kms.v1.IGetEkmConnectionRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getEkmConnection response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getEkmConnection(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.kms.v1.IEkmConnection, - protos.google.cloud.kms.v1.IGetEkmConnectionRequest|undefined, - {}|undefined - ]) => { - this._log.info('getEkmConnection response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getEkmConnection(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.kms.v1.IEkmConnection, + protos.google.cloud.kms.v1.IGetEkmConnectionRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getEkmConnection response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 {@link protos.google.cloud.kms.v1.EkmConnection|EkmConnection} in a given - * Project and Location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the location associated with the - * {@link protos.google.cloud.kms.v1.EkmConnection|EkmConnection}, in the format - * `projects/* /locations/*`. - * @param {string} request.ekmConnectionId - * Required. It must be unique within a location and match the regular - * expression `[a-zA-Z0-9_-]{1,63}`. - * @param {google.cloud.kms.v1.EkmConnection} request.ekmConnection - * Required. An {@link protos.google.cloud.kms.v1.EkmConnection|EkmConnection} with - * initial field values. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.kms.v1.EkmConnection|EkmConnection}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/ekm_service.create_ekm_connection.js - * region_tag:cloudkms_v1_generated_EkmService_CreateEkmConnection_async - */ + /** + * Creates a new {@link protos.google.cloud.kms.v1.EkmConnection|EkmConnection} in a given + * Project and Location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the location associated with the + * {@link protos.google.cloud.kms.v1.EkmConnection|EkmConnection}, in the format + * `projects/* /locations/*`. + * @param {string} request.ekmConnectionId + * Required. It must be unique within a location and match the regular + * expression `[a-zA-Z0-9_-]{1,63}`. + * @param {google.cloud.kms.v1.EkmConnection} request.ekmConnection + * Required. An {@link protos.google.cloud.kms.v1.EkmConnection|EkmConnection} with + * initial field values. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.kms.v1.EkmConnection|EkmConnection}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/ekm_service.create_ekm_connection.js + * region_tag:cloudkms_v1_generated_EkmService_CreateEkmConnection_async + */ createEkmConnection( - request?: protos.google.cloud.kms.v1.ICreateEkmConnectionRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.kms.v1.IEkmConnection, - protos.google.cloud.kms.v1.ICreateEkmConnectionRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.kms.v1.ICreateEkmConnectionRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.kms.v1.IEkmConnection, + protos.google.cloud.kms.v1.ICreateEkmConnectionRequest | undefined, + {} | undefined, + ] + >; createEkmConnection( - request: protos.google.cloud.kms.v1.ICreateEkmConnectionRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.kms.v1.IEkmConnection, - protos.google.cloud.kms.v1.ICreateEkmConnectionRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.ICreateEkmConnectionRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.kms.v1.IEkmConnection, + protos.google.cloud.kms.v1.ICreateEkmConnectionRequest | null | undefined, + {} | null | undefined + >, + ): void; createEkmConnection( - request: protos.google.cloud.kms.v1.ICreateEkmConnectionRequest, - callback: Callback< - protos.google.cloud.kms.v1.IEkmConnection, - protos.google.cloud.kms.v1.ICreateEkmConnectionRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.ICreateEkmConnectionRequest, + callback: Callback< + protos.google.cloud.kms.v1.IEkmConnection, + protos.google.cloud.kms.v1.ICreateEkmConnectionRequest | null | undefined, + {} | null | undefined + >, + ): void; createEkmConnection( - request?: protos.google.cloud.kms.v1.ICreateEkmConnectionRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.kms.v1.IEkmConnection, - protos.google.cloud.kms.v1.ICreateEkmConnectionRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.kms.v1.ICreateEkmConnectionRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.kms.v1.IEkmConnection, - protos.google.cloud.kms.v1.ICreateEkmConnectionRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.kms.v1.IEkmConnection, - protos.google.cloud.kms.v1.ICreateEkmConnectionRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.kms.v1.ICreateEkmConnectionRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.kms.v1.IEkmConnection, + protos.google.cloud.kms.v1.ICreateEkmConnectionRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.kms.v1.IEkmConnection, + protos.google.cloud.kms.v1.ICreateEkmConnectionRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.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('createEkmConnection request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.kms.v1.IEkmConnection, - protos.google.cloud.kms.v1.ICreateEkmConnectionRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.kms.v1.IEkmConnection, + | protos.google.cloud.kms.v1.ICreateEkmConnectionRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('createEkmConnection response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.createEkmConnection(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.kms.v1.IEkmConnection, - protos.google.cloud.kms.v1.ICreateEkmConnectionRequest|undefined, - {}|undefined - ]) => { - this._log.info('createEkmConnection response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .createEkmConnection(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.kms.v1.IEkmConnection, + protos.google.cloud.kms.v1.ICreateEkmConnectionRequest | undefined, + {} | undefined, + ]) => { + this._log.info('createEkmConnection response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 {@link protos.google.cloud.kms.v1.EkmConnection|EkmConnection}'s metadata. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.kms.v1.EkmConnection} request.ekmConnection - * Required. {@link protos.google.cloud.kms.v1.EkmConnection|EkmConnection} with updated - * values. - * @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.kms.v1.EkmConnection|EkmConnection}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/ekm_service.update_ekm_connection.js - * region_tag:cloudkms_v1_generated_EkmService_UpdateEkmConnection_async - */ + /** + * Updates an {@link protos.google.cloud.kms.v1.EkmConnection|EkmConnection}'s metadata. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.kms.v1.EkmConnection} request.ekmConnection + * Required. {@link protos.google.cloud.kms.v1.EkmConnection|EkmConnection} with updated + * values. + * @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.kms.v1.EkmConnection|EkmConnection}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/ekm_service.update_ekm_connection.js + * region_tag:cloudkms_v1_generated_EkmService_UpdateEkmConnection_async + */ updateEkmConnection( - request?: protos.google.cloud.kms.v1.IUpdateEkmConnectionRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.kms.v1.IEkmConnection, - protos.google.cloud.kms.v1.IUpdateEkmConnectionRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.kms.v1.IUpdateEkmConnectionRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.kms.v1.IEkmConnection, + protos.google.cloud.kms.v1.IUpdateEkmConnectionRequest | undefined, + {} | undefined, + ] + >; updateEkmConnection( - request: protos.google.cloud.kms.v1.IUpdateEkmConnectionRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.kms.v1.IEkmConnection, - protos.google.cloud.kms.v1.IUpdateEkmConnectionRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IUpdateEkmConnectionRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.kms.v1.IEkmConnection, + protos.google.cloud.kms.v1.IUpdateEkmConnectionRequest | null | undefined, + {} | null | undefined + >, + ): void; updateEkmConnection( - request: protos.google.cloud.kms.v1.IUpdateEkmConnectionRequest, - callback: Callback< - protos.google.cloud.kms.v1.IEkmConnection, - protos.google.cloud.kms.v1.IUpdateEkmConnectionRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IUpdateEkmConnectionRequest, + callback: Callback< + protos.google.cloud.kms.v1.IEkmConnection, + protos.google.cloud.kms.v1.IUpdateEkmConnectionRequest | null | undefined, + {} | null | undefined + >, + ): void; updateEkmConnection( - request?: protos.google.cloud.kms.v1.IUpdateEkmConnectionRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.kms.v1.IEkmConnection, - protos.google.cloud.kms.v1.IUpdateEkmConnectionRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.kms.v1.IUpdateEkmConnectionRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.kms.v1.IEkmConnection, - protos.google.cloud.kms.v1.IUpdateEkmConnectionRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.kms.v1.IEkmConnection, - protos.google.cloud.kms.v1.IUpdateEkmConnectionRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.kms.v1.IUpdateEkmConnectionRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.kms.v1.IEkmConnection, + protos.google.cloud.kms.v1.IUpdateEkmConnectionRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.kms.v1.IEkmConnection, + protos.google.cloud.kms.v1.IUpdateEkmConnectionRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'ekm_connection.name': request.ekmConnection!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'ekm_connection.name': request.ekmConnection!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('updateEkmConnection request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.kms.v1.IEkmConnection, - protos.google.cloud.kms.v1.IUpdateEkmConnectionRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.kms.v1.IEkmConnection, + | protos.google.cloud.kms.v1.IUpdateEkmConnectionRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('updateEkmConnection response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.updateEkmConnection(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.kms.v1.IEkmConnection, - protos.google.cloud.kms.v1.IUpdateEkmConnectionRequest|undefined, - {}|undefined - ]) => { - this._log.info('updateEkmConnection response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .updateEkmConnection(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.kms.v1.IEkmConnection, + protos.google.cloud.kms.v1.IUpdateEkmConnectionRequest | undefined, + {} | undefined, + ]) => { + this._log.info('updateEkmConnection response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 {@link protos.google.cloud.kms.v1.EkmConfig|EkmConfig} singleton resource - * for a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The {@link protos.google.cloud.kms.v1.EkmConfig.name|name} of the - * {@link protos.google.cloud.kms.v1.EkmConfig|EkmConfig} 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.kms.v1.EkmConfig|EkmConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/ekm_service.get_ekm_config.js - * region_tag:cloudkms_v1_generated_EkmService_GetEkmConfig_async - */ + /** + * Returns the {@link protos.google.cloud.kms.v1.EkmConfig|EkmConfig} singleton resource + * for a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The {@link protos.google.cloud.kms.v1.EkmConfig.name|name} of the + * {@link protos.google.cloud.kms.v1.EkmConfig|EkmConfig} 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.kms.v1.EkmConfig|EkmConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/ekm_service.get_ekm_config.js + * region_tag:cloudkms_v1_generated_EkmService_GetEkmConfig_async + */ getEkmConfig( - request?: protos.google.cloud.kms.v1.IGetEkmConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.kms.v1.IEkmConfig, - protos.google.cloud.kms.v1.IGetEkmConfigRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.kms.v1.IGetEkmConfigRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.kms.v1.IEkmConfig, + protos.google.cloud.kms.v1.IGetEkmConfigRequest | undefined, + {} | undefined, + ] + >; getEkmConfig( - request: protos.google.cloud.kms.v1.IGetEkmConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.kms.v1.IEkmConfig, - protos.google.cloud.kms.v1.IGetEkmConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IGetEkmConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.kms.v1.IEkmConfig, + protos.google.cloud.kms.v1.IGetEkmConfigRequest | null | undefined, + {} | null | undefined + >, + ): void; getEkmConfig( - request: protos.google.cloud.kms.v1.IGetEkmConfigRequest, - callback: Callback< - protos.google.cloud.kms.v1.IEkmConfig, - protos.google.cloud.kms.v1.IGetEkmConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IGetEkmConfigRequest, + callback: Callback< + protos.google.cloud.kms.v1.IEkmConfig, + protos.google.cloud.kms.v1.IGetEkmConfigRequest | null | undefined, + {} | null | undefined + >, + ): void; getEkmConfig( - request?: protos.google.cloud.kms.v1.IGetEkmConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.kms.v1.IEkmConfig, - protos.google.cloud.kms.v1.IGetEkmConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.kms.v1.IGetEkmConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.kms.v1.IEkmConfig, - protos.google.cloud.kms.v1.IGetEkmConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.kms.v1.IEkmConfig, - protos.google.cloud.kms.v1.IGetEkmConfigRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.kms.v1.IGetEkmConfigRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.kms.v1.IEkmConfig, + protos.google.cloud.kms.v1.IGetEkmConfigRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.kms.v1.IEkmConfig, + protos.google.cloud.kms.v1.IGetEkmConfigRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getEkmConfig request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.kms.v1.IEkmConfig, - protos.google.cloud.kms.v1.IGetEkmConfigRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.kms.v1.IEkmConfig, + protos.google.cloud.kms.v1.IGetEkmConfigRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getEkmConfig response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getEkmConfig(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.kms.v1.IEkmConfig, - protos.google.cloud.kms.v1.IGetEkmConfigRequest|undefined, - {}|undefined - ]) => { - this._log.info('getEkmConfig response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getEkmConfig(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.kms.v1.IEkmConfig, + protos.google.cloud.kms.v1.IGetEkmConfigRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getEkmConfig response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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.kms.v1.EkmConfig|EkmConfig} singleton resource - * for a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.kms.v1.EkmConfig} request.ekmConfig - * Required. {@link protos.google.cloud.kms.v1.EkmConfig|EkmConfig} with updated values. - * @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.kms.v1.EkmConfig|EkmConfig}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/ekm_service.update_ekm_config.js - * region_tag:cloudkms_v1_generated_EkmService_UpdateEkmConfig_async - */ + /** + * Updates the {@link protos.google.cloud.kms.v1.EkmConfig|EkmConfig} singleton resource + * for a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.kms.v1.EkmConfig} request.ekmConfig + * Required. {@link protos.google.cloud.kms.v1.EkmConfig|EkmConfig} with updated values. + * @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.kms.v1.EkmConfig|EkmConfig}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/ekm_service.update_ekm_config.js + * region_tag:cloudkms_v1_generated_EkmService_UpdateEkmConfig_async + */ updateEkmConfig( - request?: protos.google.cloud.kms.v1.IUpdateEkmConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.kms.v1.IEkmConfig, - protos.google.cloud.kms.v1.IUpdateEkmConfigRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.kms.v1.IUpdateEkmConfigRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.kms.v1.IEkmConfig, + protos.google.cloud.kms.v1.IUpdateEkmConfigRequest | undefined, + {} | undefined, + ] + >; updateEkmConfig( - request: protos.google.cloud.kms.v1.IUpdateEkmConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.kms.v1.IEkmConfig, - protos.google.cloud.kms.v1.IUpdateEkmConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IUpdateEkmConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.kms.v1.IEkmConfig, + protos.google.cloud.kms.v1.IUpdateEkmConfigRequest | null | undefined, + {} | null | undefined + >, + ): void; updateEkmConfig( - request: protos.google.cloud.kms.v1.IUpdateEkmConfigRequest, - callback: Callback< - protos.google.cloud.kms.v1.IEkmConfig, - protos.google.cloud.kms.v1.IUpdateEkmConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IUpdateEkmConfigRequest, + callback: Callback< + protos.google.cloud.kms.v1.IEkmConfig, + protos.google.cloud.kms.v1.IUpdateEkmConfigRequest | null | undefined, + {} | null | undefined + >, + ): void; updateEkmConfig( - request?: protos.google.cloud.kms.v1.IUpdateEkmConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.kms.v1.IEkmConfig, - protos.google.cloud.kms.v1.IUpdateEkmConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.kms.v1.IUpdateEkmConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.kms.v1.IEkmConfig, - protos.google.cloud.kms.v1.IUpdateEkmConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.kms.v1.IEkmConfig, - protos.google.cloud.kms.v1.IUpdateEkmConfigRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.kms.v1.IUpdateEkmConfigRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.kms.v1.IEkmConfig, + protos.google.cloud.kms.v1.IUpdateEkmConfigRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.kms.v1.IEkmConfig, + protos.google.cloud.kms.v1.IUpdateEkmConfigRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'ekm_config.name': request.ekmConfig!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'ekm_config.name': request.ekmConfig!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('updateEkmConfig request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.kms.v1.IEkmConfig, - protos.google.cloud.kms.v1.IUpdateEkmConfigRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.kms.v1.IEkmConfig, + protos.google.cloud.kms.v1.IUpdateEkmConfigRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('updateEkmConfig response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.updateEkmConfig(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.kms.v1.IEkmConfig, - protos.google.cloud.kms.v1.IUpdateEkmConfigRequest|undefined, - {}|undefined - ]) => { - this._log.info('updateEkmConfig response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .updateEkmConfig(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.kms.v1.IEkmConfig, + protos.google.cloud.kms.v1.IUpdateEkmConfigRequest | undefined, + {} | undefined, + ]) => { + this._log.info('updateEkmConfig response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Verifies that Cloud KMS can successfully connect to the external key - * manager specified by an {@link protos.google.cloud.kms.v1.EkmConnection|EkmConnection}. - * If there is an error connecting to the EKM, this method returns a - * FAILED_PRECONDITION status containing structured information as described - * at https://cloud.google.com/kms/docs/reference/ekm_errors. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The {@link protos.google.cloud.kms.v1.EkmConnection.name|name} of the - * {@link protos.google.cloud.kms.v1.EkmConnection|EkmConnection} to verify. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.kms.v1.VerifyConnectivityResponse|VerifyConnectivityResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/ekm_service.verify_connectivity.js - * region_tag:cloudkms_v1_generated_EkmService_VerifyConnectivity_async - */ + /** + * Verifies that Cloud KMS can successfully connect to the external key + * manager specified by an {@link protos.google.cloud.kms.v1.EkmConnection|EkmConnection}. + * If there is an error connecting to the EKM, this method returns a + * FAILED_PRECONDITION status containing structured information as described + * at https://cloud.google.com/kms/docs/reference/ekm_errors. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The {@link protos.google.cloud.kms.v1.EkmConnection.name|name} of the + * {@link protos.google.cloud.kms.v1.EkmConnection|EkmConnection} to verify. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.kms.v1.VerifyConnectivityResponse|VerifyConnectivityResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/ekm_service.verify_connectivity.js + * region_tag:cloudkms_v1_generated_EkmService_VerifyConnectivity_async + */ verifyConnectivity( - request?: protos.google.cloud.kms.v1.IVerifyConnectivityRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.kms.v1.IVerifyConnectivityResponse, - protos.google.cloud.kms.v1.IVerifyConnectivityRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.kms.v1.IVerifyConnectivityRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.kms.v1.IVerifyConnectivityResponse, + protos.google.cloud.kms.v1.IVerifyConnectivityRequest | undefined, + {} | undefined, + ] + >; verifyConnectivity( - request: protos.google.cloud.kms.v1.IVerifyConnectivityRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.kms.v1.IVerifyConnectivityResponse, - protos.google.cloud.kms.v1.IVerifyConnectivityRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IVerifyConnectivityRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.kms.v1.IVerifyConnectivityResponse, + protos.google.cloud.kms.v1.IVerifyConnectivityRequest | null | undefined, + {} | null | undefined + >, + ): void; verifyConnectivity( - request: protos.google.cloud.kms.v1.IVerifyConnectivityRequest, - callback: Callback< - protos.google.cloud.kms.v1.IVerifyConnectivityResponse, - protos.google.cloud.kms.v1.IVerifyConnectivityRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IVerifyConnectivityRequest, + callback: Callback< + protos.google.cloud.kms.v1.IVerifyConnectivityResponse, + protos.google.cloud.kms.v1.IVerifyConnectivityRequest | null | undefined, + {} | null | undefined + >, + ): void; verifyConnectivity( - request?: protos.google.cloud.kms.v1.IVerifyConnectivityRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.kms.v1.IVerifyConnectivityResponse, - protos.google.cloud.kms.v1.IVerifyConnectivityRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.kms.v1.IVerifyConnectivityRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.kms.v1.IVerifyConnectivityResponse, - protos.google.cloud.kms.v1.IVerifyConnectivityRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.kms.v1.IVerifyConnectivityResponse, - protos.google.cloud.kms.v1.IVerifyConnectivityRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.kms.v1.IVerifyConnectivityRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.kms.v1.IVerifyConnectivityResponse, + protos.google.cloud.kms.v1.IVerifyConnectivityRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.kms.v1.IVerifyConnectivityResponse, + protos.google.cloud.kms.v1.IVerifyConnectivityRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('verifyConnectivity request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.kms.v1.IVerifyConnectivityResponse, - protos.google.cloud.kms.v1.IVerifyConnectivityRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.kms.v1.IVerifyConnectivityResponse, + | protos.google.cloud.kms.v1.IVerifyConnectivityRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('verifyConnectivity response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.verifyConnectivity(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.kms.v1.IVerifyConnectivityResponse, - protos.google.cloud.kms.v1.IVerifyConnectivityRequest|undefined, - {}|undefined - ]) => { - this._log.info('verifyConnectivity response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .verifyConnectivity(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.kms.v1.IVerifyConnectivityResponse, + protos.google.cloud.kms.v1.IVerifyConnectivityRequest | undefined, + {} | undefined, + ]) => { + this._log.info('verifyConnectivity response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 {@link protos.google.cloud.kms.v1.EkmConnection|EkmConnections}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the location associated with the - * {@link protos.google.cloud.kms.v1.EkmConnection|EkmConnections} to list, in the format - * `projects/* /locations/*`. - * @param {number} [request.pageSize] - * Optional. Optional limit on the number of - * {@link protos.google.cloud.kms.v1.EkmConnection|EkmConnections} to include in the - * response. Further {@link protos.google.cloud.kms.v1.EkmConnection|EkmConnections} can - * subsequently be obtained by including the - * {@link protos.google.cloud.kms.v1.ListEkmConnectionsResponse.next_page_token|ListEkmConnectionsResponse.next_page_token} - * in a subsequent request. If unspecified, the server will pick an - * appropriate default. - * @param {string} [request.pageToken] - * Optional. Optional pagination token, returned earlier via - * {@link protos.google.cloud.kms.v1.ListEkmConnectionsResponse.next_page_token|ListEkmConnectionsResponse.next_page_token}. - * @param {string} [request.filter] - * Optional. Only include resources that match the filter in the response. For - * more information, see - * [Sorting and filtering list - * results](https://cloud.google.com/kms/docs/sorting-and-filtering). - * @param {string} [request.orderBy] - * Optional. Specify how the results should be sorted. If not specified, the - * results will be sorted in the default order. For more information, see - * [Sorting and filtering list - * results](https://cloud.google.com/kms/docs/sorting-and-filtering). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link protos.google.cloud.kms.v1.EkmConnection|EkmConnection}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listEkmConnectionsAsync()` - * method described below for async iteration which you can stop as 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 {@link protos.google.cloud.kms.v1.EkmConnection|EkmConnections}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the location associated with the + * {@link protos.google.cloud.kms.v1.EkmConnection|EkmConnections} to list, in the format + * `projects/* /locations/*`. + * @param {number} [request.pageSize] + * Optional. Optional limit on the number of + * {@link protos.google.cloud.kms.v1.EkmConnection|EkmConnections} to include in the + * response. Further {@link protos.google.cloud.kms.v1.EkmConnection|EkmConnections} can + * subsequently be obtained by including the + * {@link protos.google.cloud.kms.v1.ListEkmConnectionsResponse.next_page_token|ListEkmConnectionsResponse.next_page_token} + * in a subsequent request. If unspecified, the server will pick an + * appropriate default. + * @param {string} [request.pageToken] + * Optional. Optional pagination token, returned earlier via + * {@link protos.google.cloud.kms.v1.ListEkmConnectionsResponse.next_page_token|ListEkmConnectionsResponse.next_page_token}. + * @param {string} [request.filter] + * Optional. Only include resources that match the filter in the response. For + * more information, see + * [Sorting and filtering list + * results](https://cloud.google.com/kms/docs/sorting-and-filtering). + * @param {string} [request.orderBy] + * Optional. Specify how the results should be sorted. If not specified, the + * results will be sorted in the default order. For more information, see + * [Sorting and filtering list + * results](https://cloud.google.com/kms/docs/sorting-and-filtering). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.kms.v1.EkmConnection|EkmConnection}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listEkmConnectionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listEkmConnections( - request?: protos.google.cloud.kms.v1.IListEkmConnectionsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.kms.v1.IEkmConnection[], - protos.google.cloud.kms.v1.IListEkmConnectionsRequest|null, - protos.google.cloud.kms.v1.IListEkmConnectionsResponse - ]>; + request?: protos.google.cloud.kms.v1.IListEkmConnectionsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.kms.v1.IEkmConnection[], + protos.google.cloud.kms.v1.IListEkmConnectionsRequest | null, + protos.google.cloud.kms.v1.IListEkmConnectionsResponse, + ] + >; listEkmConnections( - request: protos.google.cloud.kms.v1.IListEkmConnectionsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.kms.v1.IListEkmConnectionsRequest, - protos.google.cloud.kms.v1.IListEkmConnectionsResponse|null|undefined, - protos.google.cloud.kms.v1.IEkmConnection>): void; + request: protos.google.cloud.kms.v1.IListEkmConnectionsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.kms.v1.IListEkmConnectionsRequest, + protos.google.cloud.kms.v1.IListEkmConnectionsResponse | null | undefined, + protos.google.cloud.kms.v1.IEkmConnection + >, + ): void; listEkmConnections( - request: protos.google.cloud.kms.v1.IListEkmConnectionsRequest, - callback: PaginationCallback< - protos.google.cloud.kms.v1.IListEkmConnectionsRequest, - protos.google.cloud.kms.v1.IListEkmConnectionsResponse|null|undefined, - protos.google.cloud.kms.v1.IEkmConnection>): void; + request: protos.google.cloud.kms.v1.IListEkmConnectionsRequest, + callback: PaginationCallback< + protos.google.cloud.kms.v1.IListEkmConnectionsRequest, + protos.google.cloud.kms.v1.IListEkmConnectionsResponse | null | undefined, + protos.google.cloud.kms.v1.IEkmConnection + >, + ): void; listEkmConnections( - request?: protos.google.cloud.kms.v1.IListEkmConnectionsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< + request?: protos.google.cloud.kms.v1.IListEkmConnectionsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.kms.v1.IListEkmConnectionsRequest, - protos.google.cloud.kms.v1.IListEkmConnectionsResponse|null|undefined, - protos.google.cloud.kms.v1.IEkmConnection>, - callback?: PaginationCallback< - protos.google.cloud.kms.v1.IListEkmConnectionsRequest, - protos.google.cloud.kms.v1.IListEkmConnectionsResponse|null|undefined, - protos.google.cloud.kms.v1.IEkmConnection>): - Promise<[ - protos.google.cloud.kms.v1.IEkmConnection[], - protos.google.cloud.kms.v1.IListEkmConnectionsRequest|null, - protos.google.cloud.kms.v1.IListEkmConnectionsResponse - ]>|void { + | protos.google.cloud.kms.v1.IListEkmConnectionsResponse + | null + | undefined, + protos.google.cloud.kms.v1.IEkmConnection + >, + callback?: PaginationCallback< + protos.google.cloud.kms.v1.IListEkmConnectionsRequest, + protos.google.cloud.kms.v1.IListEkmConnectionsResponse | null | undefined, + protos.google.cloud.kms.v1.IEkmConnection + >, + ): Promise< + [ + protos.google.cloud.kms.v1.IEkmConnection[], + protos.google.cloud.kms.v1.IListEkmConnectionsRequest | null, + protos.google.cloud.kms.v1.IListEkmConnectionsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-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.kms.v1.IListEkmConnectionsRequest, - protos.google.cloud.kms.v1.IListEkmConnectionsResponse|null|undefined, - protos.google.cloud.kms.v1.IEkmConnection>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.kms.v1.IListEkmConnectionsRequest, + | protos.google.cloud.kms.v1.IListEkmConnectionsResponse + | null + | undefined, + protos.google.cloud.kms.v1.IEkmConnection + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listEkmConnections values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1086,171 +1360,175 @@ export class EkmServiceClient { this._log.info('listEkmConnections request %j', request); return this.innerApiCalls .listEkmConnections(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.kms.v1.IEkmConnection[], - protos.google.cloud.kms.v1.IListEkmConnectionsRequest|null, - protos.google.cloud.kms.v1.IListEkmConnectionsResponse - ]) => { - this._log.info('listEkmConnections values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.kms.v1.IEkmConnection[], + protos.google.cloud.kms.v1.IListEkmConnectionsRequest | null, + protos.google.cloud.kms.v1.IListEkmConnectionsResponse, + ]) => { + this._log.info('listEkmConnections values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listEkmConnections`, 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 location associated with the - * {@link protos.google.cloud.kms.v1.EkmConnection|EkmConnections} to list, in the format - * `projects/* /locations/*`. - * @param {number} [request.pageSize] - * Optional. Optional limit on the number of - * {@link protos.google.cloud.kms.v1.EkmConnection|EkmConnections} to include in the - * response. Further {@link protos.google.cloud.kms.v1.EkmConnection|EkmConnections} can - * subsequently be obtained by including the - * {@link protos.google.cloud.kms.v1.ListEkmConnectionsResponse.next_page_token|ListEkmConnectionsResponse.next_page_token} - * in a subsequent request. If unspecified, the server will pick an - * appropriate default. - * @param {string} [request.pageToken] - * Optional. Optional pagination token, returned earlier via - * {@link protos.google.cloud.kms.v1.ListEkmConnectionsResponse.next_page_token|ListEkmConnectionsResponse.next_page_token}. - * @param {string} [request.filter] - * Optional. Only include resources that match the filter in the response. For - * more information, see - * [Sorting and filtering list - * results](https://cloud.google.com/kms/docs/sorting-and-filtering). - * @param {string} [request.orderBy] - * Optional. Specify how the results should be sorted. If not specified, the - * results will be sorted in the default order. For more information, see - * [Sorting and filtering list - * results](https://cloud.google.com/kms/docs/sorting-and-filtering). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.kms.v1.EkmConnection|EkmConnection} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listEkmConnectionsAsync()` - * method described below for async iteration which you can stop as 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 `listEkmConnections`, 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 location associated with the + * {@link protos.google.cloud.kms.v1.EkmConnection|EkmConnections} to list, in the format + * `projects/* /locations/*`. + * @param {number} [request.pageSize] + * Optional. Optional limit on the number of + * {@link protos.google.cloud.kms.v1.EkmConnection|EkmConnections} to include in the + * response. Further {@link protos.google.cloud.kms.v1.EkmConnection|EkmConnections} can + * subsequently be obtained by including the + * {@link protos.google.cloud.kms.v1.ListEkmConnectionsResponse.next_page_token|ListEkmConnectionsResponse.next_page_token} + * in a subsequent request. If unspecified, the server will pick an + * appropriate default. + * @param {string} [request.pageToken] + * Optional. Optional pagination token, returned earlier via + * {@link protos.google.cloud.kms.v1.ListEkmConnectionsResponse.next_page_token|ListEkmConnectionsResponse.next_page_token}. + * @param {string} [request.filter] + * Optional. Only include resources that match the filter in the response. For + * more information, see + * [Sorting and filtering list + * results](https://cloud.google.com/kms/docs/sorting-and-filtering). + * @param {string} [request.orderBy] + * Optional. Specify how the results should be sorted. If not specified, the + * results will be sorted in the default order. For more information, see + * [Sorting and filtering list + * results](https://cloud.google.com/kms/docs/sorting-and-filtering). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.kms.v1.EkmConnection|EkmConnection} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listEkmConnectionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listEkmConnectionsStream( - request?: protos.google.cloud.kms.v1.IListEkmConnectionsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.kms.v1.IListEkmConnectionsRequest, + 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['listEkmConnections']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listEkmConnections stream %j', request); return this.descriptors.page.listEkmConnections.createStream( this.innerApiCalls.listEkmConnections as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listEkmConnections`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used 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 location associated with the - * {@link protos.google.cloud.kms.v1.EkmConnection|EkmConnections} to list, in the format - * `projects/* /locations/*`. - * @param {number} [request.pageSize] - * Optional. Optional limit on the number of - * {@link protos.google.cloud.kms.v1.EkmConnection|EkmConnections} to include in the - * response. Further {@link protos.google.cloud.kms.v1.EkmConnection|EkmConnections} can - * subsequently be obtained by including the - * {@link protos.google.cloud.kms.v1.ListEkmConnectionsResponse.next_page_token|ListEkmConnectionsResponse.next_page_token} - * in a subsequent request. If unspecified, the server will pick an - * appropriate default. - * @param {string} [request.pageToken] - * Optional. Optional pagination token, returned earlier via - * {@link protos.google.cloud.kms.v1.ListEkmConnectionsResponse.next_page_token|ListEkmConnectionsResponse.next_page_token}. - * @param {string} [request.filter] - * Optional. Only include resources that match the filter in the response. For - * more information, see - * [Sorting and filtering list - * results](https://cloud.google.com/kms/docs/sorting-and-filtering). - * @param {string} [request.orderBy] - * Optional. Specify how the results should be sorted. If not specified, the - * results will be sorted in the default order. For more information, see - * [Sorting and filtering list - * results](https://cloud.google.com/kms/docs/sorting-and-filtering). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.kms.v1.EkmConnection|EkmConnection}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@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/ekm_service.list_ekm_connections.js - * region_tag:cloudkms_v1_generated_EkmService_ListEkmConnections_async - */ + /** + * Equivalent to `listEkmConnections`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used 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 location associated with the + * {@link protos.google.cloud.kms.v1.EkmConnection|EkmConnections} to list, in the format + * `projects/* /locations/*`. + * @param {number} [request.pageSize] + * Optional. Optional limit on the number of + * {@link protos.google.cloud.kms.v1.EkmConnection|EkmConnections} to include in the + * response. Further {@link protos.google.cloud.kms.v1.EkmConnection|EkmConnections} can + * subsequently be obtained by including the + * {@link protos.google.cloud.kms.v1.ListEkmConnectionsResponse.next_page_token|ListEkmConnectionsResponse.next_page_token} + * in a subsequent request. If unspecified, the server will pick an + * appropriate default. + * @param {string} [request.pageToken] + * Optional. Optional pagination token, returned earlier via + * {@link protos.google.cloud.kms.v1.ListEkmConnectionsResponse.next_page_token|ListEkmConnectionsResponse.next_page_token}. + * @param {string} [request.filter] + * Optional. Only include resources that match the filter in the response. For + * more information, see + * [Sorting and filtering list + * results](https://cloud.google.com/kms/docs/sorting-and-filtering). + * @param {string} [request.orderBy] + * Optional. Specify how the results should be sorted. If not specified, the + * results will be sorted in the default order. For more information, see + * [Sorting and filtering list + * results](https://cloud.google.com/kms/docs/sorting-and-filtering). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.kms.v1.EkmConnection|EkmConnection}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@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/ekm_service.list_ekm_connections.js + * region_tag:cloudkms_v1_generated_EkmService_ListEkmConnections_async + */ listEkmConnectionsAsync( - request?: protos.google.cloud.kms.v1.IListEkmConnectionsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.kms.v1.IListEkmConnectionsRequest, + 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['listEkmConnections']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listEkmConnections iterate %j', request); return this.descriptors.page.listEkmConnections.asyncIterate( this.innerApiCalls['listEkmConnections'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** - * Gets the access control policy for a resource. Returns an empty policy - * if the resource exists and does not have a policy set. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {Object} [request.options] - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. This field is only used by Cloud IAM. - * - * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Gets the access control policy for a resource. Returns an empty policy + * if the resource exists and does not have a policy set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {Object} [request.options] + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. This field is only used by Cloud IAM. + * + * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ getIamPolicy( request: IamProtos.google.iam.v1.GetIamPolicyRequest, options?: @@ -1264,40 +1542,40 @@ export class EkmServiceClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.getIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ setIamPolicy( request: IamProtos.google.iam.v1.SetIamPolicyRequest, options?: @@ -1311,41 +1589,41 @@ export class EkmServiceClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.setIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + */ testIamPermissions( request: IamProtos.google.iam.v1.TestIamPermissionsRequest, options?: @@ -1359,12 +1637,12 @@ export class EkmServiceClient { IamProtos.google.iam.v1.TestIamPermissionsResponse, IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { + >, + ): Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { return this.iamClient.testIamPermissions(request, options, callback); } -/** + /** * Gets information about a location. * * @param {Object} request @@ -1399,12 +1677,11 @@ export class EkmServiceClient { | 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. @@ -1437,7 +1714,7 @@ export class EkmServiceClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } @@ -1455,7 +1732,12 @@ export class EkmServiceClient { * @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, @@ -1472,7 +1754,8 @@ export class EkmServiceClient { * @returns {string} A string representing the project. */ matchProjectFromCryptoKeyName(cryptoKeyName: string) { - return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName).project; + return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName) + .project; } /** @@ -1483,7 +1766,8 @@ export class EkmServiceClient { * @returns {string} A string representing the location. */ matchLocationFromCryptoKeyName(cryptoKeyName: string) { - return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName).location; + return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName) + .location; } /** @@ -1494,7 +1778,8 @@ export class EkmServiceClient { * @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; } /** @@ -1505,7 +1790,8 @@ export class EkmServiceClient { * @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; } /** @@ -1518,7 +1804,13 @@ export class EkmServiceClient { * @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, @@ -1536,7 +1828,9 @@ export class EkmServiceClient { * @returns {string} A string representing the project. */ matchProjectFromCryptoKeyVersionName(cryptoKeyVersionName: string) { - return this.pathTemplates.cryptoKeyVersionPathTemplate.match(cryptoKeyVersionName).project; + return this.pathTemplates.cryptoKeyVersionPathTemplate.match( + cryptoKeyVersionName, + ).project; } /** @@ -1547,7 +1841,9 @@ export class EkmServiceClient { * @returns {string} A string representing the location. */ matchLocationFromCryptoKeyVersionName(cryptoKeyVersionName: string) { - return this.pathTemplates.cryptoKeyVersionPathTemplate.match(cryptoKeyVersionName).location; + return this.pathTemplates.cryptoKeyVersionPathTemplate.match( + cryptoKeyVersionName, + ).location; } /** @@ -1558,7 +1854,9 @@ export class EkmServiceClient { * @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; } /** @@ -1569,7 +1867,9 @@ export class EkmServiceClient { * @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; } /** @@ -1580,7 +1880,9 @@ export class EkmServiceClient { * @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; } /** @@ -1590,7 +1892,7 @@ export class EkmServiceClient { * @param {string} location * @returns {string} Resource name string. */ - ekmConfigPath(project:string,location:string) { + ekmConfigPath(project: string, location: string) { return this.pathTemplates.ekmConfigPathTemplate.render({ project: project, location: location, @@ -1605,7 +1907,8 @@ export class EkmServiceClient { * @returns {string} A string representing the project. */ matchProjectFromEkmConfigName(ekmConfigName: string) { - return this.pathTemplates.ekmConfigPathTemplate.match(ekmConfigName).project; + return this.pathTemplates.ekmConfigPathTemplate.match(ekmConfigName) + .project; } /** @@ -1616,7 +1919,8 @@ export class EkmServiceClient { * @returns {string} A string representing the location. */ matchLocationFromEkmConfigName(ekmConfigName: string) { - return this.pathTemplates.ekmConfigPathTemplate.match(ekmConfigName).location; + return this.pathTemplates.ekmConfigPathTemplate.match(ekmConfigName) + .location; } /** @@ -1627,7 +1931,7 @@ export class EkmServiceClient { * @param {string} ekm_connection * @returns {string} Resource name string. */ - ekmConnectionPath(project:string,location:string,ekmConnection:string) { + ekmConnectionPath(project: string, location: string, ekmConnection: string) { return this.pathTemplates.ekmConnectionPathTemplate.render({ project: project, location: location, @@ -1643,7 +1947,8 @@ export class EkmServiceClient { * @returns {string} A string representing the project. */ matchProjectFromEkmConnectionName(ekmConnectionName: string) { - return this.pathTemplates.ekmConnectionPathTemplate.match(ekmConnectionName).project; + return this.pathTemplates.ekmConnectionPathTemplate.match(ekmConnectionName) + .project; } /** @@ -1654,7 +1959,8 @@ export class EkmServiceClient { * @returns {string} A string representing the location. */ matchLocationFromEkmConnectionName(ekmConnectionName: string) { - return this.pathTemplates.ekmConnectionPathTemplate.match(ekmConnectionName).location; + return this.pathTemplates.ekmConnectionPathTemplate.match(ekmConnectionName) + .location; } /** @@ -1665,7 +1971,8 @@ export class EkmServiceClient { * @returns {string} A string representing the ekm_connection. */ matchEkmConnectionFromEkmConnectionName(ekmConnectionName: string) { - return this.pathTemplates.ekmConnectionPathTemplate.match(ekmConnectionName).ekm_connection; + return this.pathTemplates.ekmConnectionPathTemplate.match(ekmConnectionName) + .ekm_connection; } /** @@ -1674,7 +1981,7 @@ export class EkmServiceClient { * @param {string} folder * @returns {string} Resource name string. */ - folderAutokeyConfigPath(folder:string) { + folderAutokeyConfigPath(folder: string) { return this.pathTemplates.folderAutokeyConfigPathTemplate.render({ folder: folder, }); @@ -1688,7 +1995,9 @@ export class EkmServiceClient { * @returns {string} A string representing the folder. */ matchFolderFromFolderAutokeyConfigName(folderAutokeyConfigName: string) { - return this.pathTemplates.folderAutokeyConfigPathTemplate.match(folderAutokeyConfigName).folder; + return this.pathTemplates.folderAutokeyConfigPathTemplate.match( + folderAutokeyConfigName, + ).folder; } /** @@ -1700,7 +2009,12 @@ export class EkmServiceClient { * @param {string} import_job * @returns {string} Resource name string. */ - importJobPath(project:string,location:string,keyRing:string,importJob:string) { + importJobPath( + project: string, + location: string, + keyRing: string, + importJob: string, + ) { return this.pathTemplates.importJobPathTemplate.render({ project: project, location: location, @@ -1717,7 +2031,8 @@ export class EkmServiceClient { * @returns {string} A string representing the project. */ matchProjectFromImportJobName(importJobName: string) { - return this.pathTemplates.importJobPathTemplate.match(importJobName).project; + return this.pathTemplates.importJobPathTemplate.match(importJobName) + .project; } /** @@ -1728,7 +2043,8 @@ export class EkmServiceClient { * @returns {string} A string representing the location. */ matchLocationFromImportJobName(importJobName: string) { - return this.pathTemplates.importJobPathTemplate.match(importJobName).location; + return this.pathTemplates.importJobPathTemplate.match(importJobName) + .location; } /** @@ -1739,7 +2055,8 @@ export class EkmServiceClient { * @returns {string} A string representing the key_ring. */ matchKeyRingFromImportJobName(importJobName: string) { - return this.pathTemplates.importJobPathTemplate.match(importJobName).key_ring; + return this.pathTemplates.importJobPathTemplate.match(importJobName) + .key_ring; } /** @@ -1750,7 +2067,8 @@ export class EkmServiceClient { * @returns {string} A string representing the import_job. */ matchImportJobFromImportJobName(importJobName: string) { - return this.pathTemplates.importJobPathTemplate.match(importJobName).import_job; + return this.pathTemplates.importJobPathTemplate.match(importJobName) + .import_job; } /** @@ -1761,7 +2079,7 @@ export class EkmServiceClient { * @param {string} key_handle * @returns {string} Resource name string. */ - keyHandlePath(project:string,location:string,keyHandle:string) { + keyHandlePath(project: string, location: string, keyHandle: string) { return this.pathTemplates.keyHandlePathTemplate.render({ project: project, location: location, @@ -1777,7 +2095,8 @@ export class EkmServiceClient { * @returns {string} A string representing the project. */ matchProjectFromKeyHandleName(keyHandleName: string) { - return this.pathTemplates.keyHandlePathTemplate.match(keyHandleName).project; + return this.pathTemplates.keyHandlePathTemplate.match(keyHandleName) + .project; } /** @@ -1788,7 +2107,8 @@ export class EkmServiceClient { * @returns {string} A string representing the location. */ matchLocationFromKeyHandleName(keyHandleName: string) { - return this.pathTemplates.keyHandlePathTemplate.match(keyHandleName).location; + return this.pathTemplates.keyHandlePathTemplate.match(keyHandleName) + .location; } /** @@ -1799,7 +2119,8 @@ export class EkmServiceClient { * @returns {string} A string representing the key_handle. */ matchKeyHandleFromKeyHandleName(keyHandleName: string) { - return this.pathTemplates.keyHandlePathTemplate.match(keyHandleName).key_handle; + return this.pathTemplates.keyHandlePathTemplate.match(keyHandleName) + .key_handle; } /** @@ -1810,7 +2131,7 @@ export class EkmServiceClient { * @param {string} key_ring * @returns {string} Resource name string. */ - keyRingPath(project:string,location:string,keyRing:string) { + keyRingPath(project: string, location: string, keyRing: string) { return this.pathTemplates.keyRingPathTemplate.render({ project: project, location: location, @@ -1858,7 +2179,7 @@ export class EkmServiceClient { * @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, @@ -1893,7 +2214,7 @@ export class EkmServiceClient { * @param {string} project * @returns {string} Resource name string. */ - projectAutokeyConfigPath(project:string) { + projectAutokeyConfigPath(project: string) { return this.pathTemplates.projectAutokeyConfigPathTemplate.render({ project: project, }); @@ -1907,7 +2228,9 @@ export class EkmServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectAutokeyConfigName(projectAutokeyConfigName: string) { - return this.pathTemplates.projectAutokeyConfigPathTemplate.match(projectAutokeyConfigName).project; + return this.pathTemplates.projectAutokeyConfigPathTemplate.match( + projectAutokeyConfigName, + ).project; } /** @@ -1920,7 +2243,13 @@ export class EkmServiceClient { * @param {string} crypto_key_version * @returns {string} Resource name string. */ - publicKeyPath(project:string,location:string,keyRing:string,cryptoKey:string,cryptoKeyVersion:string) { + publicKeyPath( + project: string, + location: string, + keyRing: string, + cryptoKey: string, + cryptoKeyVersion: string, + ) { return this.pathTemplates.publicKeyPathTemplate.render({ project: project, location: location, @@ -1938,7 +2267,8 @@ export class EkmServiceClient { * @returns {string} A string representing the project. */ matchProjectFromPublicKeyName(publicKeyName: string) { - return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName).project; + return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName) + .project; } /** @@ -1949,7 +2279,8 @@ export class EkmServiceClient { * @returns {string} A string representing the location. */ matchLocationFromPublicKeyName(publicKeyName: string) { - return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName).location; + return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName) + .location; } /** @@ -1960,7 +2291,8 @@ export class EkmServiceClient { * @returns {string} A string representing the key_ring. */ matchKeyRingFromPublicKeyName(publicKeyName: string) { - return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName).key_ring; + return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName) + .key_ring; } /** @@ -1971,7 +2303,8 @@ export class EkmServiceClient { * @returns {string} A string representing the crypto_key. */ matchCryptoKeyFromPublicKeyName(publicKeyName: string) { - return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName).crypto_key; + return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName) + .crypto_key; } /** @@ -1982,7 +2315,8 @@ export class EkmServiceClient { * @returns {string} A string representing the crypto_key_version. */ matchCryptoKeyVersionFromPublicKeyName(publicKeyName: string) { - return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName).crypto_key_version; + return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName) + .crypto_key_version; } /** @@ -1993,7 +2327,11 @@ export class EkmServiceClient { * @param {string} retired_resource * @returns {string} Resource name string. */ - retiredResourcePath(project:string,location:string,retiredResource:string) { + retiredResourcePath( + project: string, + location: string, + retiredResource: string, + ) { return this.pathTemplates.retiredResourcePathTemplate.render({ project: project, location: location, @@ -2009,7 +2347,9 @@ export class EkmServiceClient { * @returns {string} A string representing the project. */ matchProjectFromRetiredResourceName(retiredResourceName: string) { - return this.pathTemplates.retiredResourcePathTemplate.match(retiredResourceName).project; + return this.pathTemplates.retiredResourcePathTemplate.match( + retiredResourceName, + ).project; } /** @@ -2020,7 +2360,9 @@ export class EkmServiceClient { * @returns {string} A string representing the location. */ matchLocationFromRetiredResourceName(retiredResourceName: string) { - return this.pathTemplates.retiredResourcePathTemplate.match(retiredResourceName).location; + return this.pathTemplates.retiredResourcePathTemplate.match( + retiredResourceName, + ).location; } /** @@ -2031,7 +2373,9 @@ export class EkmServiceClient { * @returns {string} A string representing the retired_resource. */ matchRetiredResourceFromRetiredResourceName(retiredResourceName: string) { - return this.pathTemplates.retiredResourcePathTemplate.match(retiredResourceName).retired_resource; + return this.pathTemplates.retiredResourcePathTemplate.match( + retiredResourceName, + ).retired_resource; } /** @@ -2042,7 +2386,11 @@ export class EkmServiceClient { * @param {string} single_tenant_hsm_instance * @returns {string} Resource name string. */ - singleTenantHsmInstancePath(project:string,location:string,singleTenantHsmInstance:string) { + singleTenantHsmInstancePath( + project: string, + location: string, + singleTenantHsmInstance: string, + ) { return this.pathTemplates.singleTenantHsmInstancePathTemplate.render({ project: project, location: location, @@ -2057,8 +2405,12 @@ export class EkmServiceClient { * A fully-qualified path representing SingleTenantHsmInstance resource. * @returns {string} A string representing the project. */ - matchProjectFromSingleTenantHsmInstanceName(singleTenantHsmInstanceName: string) { - return this.pathTemplates.singleTenantHsmInstancePathTemplate.match(singleTenantHsmInstanceName).project; + matchProjectFromSingleTenantHsmInstanceName( + singleTenantHsmInstanceName: string, + ) { + return this.pathTemplates.singleTenantHsmInstancePathTemplate.match( + singleTenantHsmInstanceName, + ).project; } /** @@ -2068,8 +2420,12 @@ export class EkmServiceClient { * A fully-qualified path representing SingleTenantHsmInstance resource. * @returns {string} A string representing the location. */ - matchLocationFromSingleTenantHsmInstanceName(singleTenantHsmInstanceName: string) { - return this.pathTemplates.singleTenantHsmInstancePathTemplate.match(singleTenantHsmInstanceName).location; + matchLocationFromSingleTenantHsmInstanceName( + singleTenantHsmInstanceName: string, + ) { + return this.pathTemplates.singleTenantHsmInstancePathTemplate.match( + singleTenantHsmInstanceName, + ).location; } /** @@ -2079,8 +2435,12 @@ export class EkmServiceClient { * A fully-qualified path representing SingleTenantHsmInstance resource. * @returns {string} A string representing the single_tenant_hsm_instance. */ - matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceName(singleTenantHsmInstanceName: string) { - return this.pathTemplates.singleTenantHsmInstancePathTemplate.match(singleTenantHsmInstanceName).single_tenant_hsm_instance; + matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceName( + singleTenantHsmInstanceName: string, + ) { + return this.pathTemplates.singleTenantHsmInstancePathTemplate.match( + singleTenantHsmInstanceName, + ).single_tenant_hsm_instance; } /** @@ -2092,13 +2452,20 @@ export class EkmServiceClient { * @param {string} proposal * @returns {string} Resource name string. */ - singleTenantHsmInstanceProposalPath(project:string,location:string,singleTenantHsmInstance:string,proposal:string) { - return this.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.render({ - project: project, - location: location, - single_tenant_hsm_instance: singleTenantHsmInstance, - proposal: proposal, - }); + singleTenantHsmInstanceProposalPath( + project: string, + location: string, + singleTenantHsmInstance: string, + proposal: string, + ) { + return this.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.render( + { + project: project, + location: location, + single_tenant_hsm_instance: singleTenantHsmInstance, + proposal: proposal, + }, + ); } /** @@ -2108,8 +2475,12 @@ export class EkmServiceClient { * A fully-qualified path representing SingleTenantHsmInstanceProposal resource. * @returns {string} A string representing the project. */ - matchProjectFromSingleTenantHsmInstanceProposalName(singleTenantHsmInstanceProposalName: string) { - return this.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match(singleTenantHsmInstanceProposalName).project; + matchProjectFromSingleTenantHsmInstanceProposalName( + singleTenantHsmInstanceProposalName: string, + ) { + return this.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match( + singleTenantHsmInstanceProposalName, + ).project; } /** @@ -2119,8 +2490,12 @@ export class EkmServiceClient { * A fully-qualified path representing SingleTenantHsmInstanceProposal resource. * @returns {string} A string representing the location. */ - matchLocationFromSingleTenantHsmInstanceProposalName(singleTenantHsmInstanceProposalName: string) { - return this.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match(singleTenantHsmInstanceProposalName).location; + matchLocationFromSingleTenantHsmInstanceProposalName( + singleTenantHsmInstanceProposalName: string, + ) { + return this.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match( + singleTenantHsmInstanceProposalName, + ).location; } /** @@ -2130,8 +2505,12 @@ export class EkmServiceClient { * A fully-qualified path representing SingleTenantHsmInstanceProposal resource. * @returns {string} A string representing the single_tenant_hsm_instance. */ - matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceProposalName(singleTenantHsmInstanceProposalName: string) { - return this.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match(singleTenantHsmInstanceProposalName).single_tenant_hsm_instance; + matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceProposalName( + singleTenantHsmInstanceProposalName: string, + ) { + return this.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match( + singleTenantHsmInstanceProposalName, + ).single_tenant_hsm_instance; } /** @@ -2141,8 +2520,12 @@ export class EkmServiceClient { * A fully-qualified path representing SingleTenantHsmInstanceProposal resource. * @returns {string} A string representing the proposal. */ - matchProposalFromSingleTenantHsmInstanceProposalName(singleTenantHsmInstanceProposalName: string) { - return this.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match(singleTenantHsmInstanceProposalName).proposal; + matchProposalFromSingleTenantHsmInstanceProposalName( + singleTenantHsmInstanceProposalName: string, + ) { + return this.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match( + singleTenantHsmInstanceProposalName, + ).proposal; } /** @@ -2153,14 +2536,18 @@ export class EkmServiceClient { */ close(): Promise { if (this.ekmServiceStub && !this._terminated) { - return this.ekmServiceStub.then(stub => { + return this.ekmServiceStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); - this.iamClient.close().catch(err => {throw err}); - this.locationsClient.close().catch(err => {throw err}); + this.iamClient.close().catch((err) => { + throw err; + }); + this.locationsClient.close().catch((err) => { + throw err; + }); }); } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-kms/src/v1/hsm_management_client.ts b/packages/google-cloud-kms/src/v1/hsm_management_client.ts index 4fb6d6b5edc8..3bf2d730e1a7 100644 --- a/packages/google-cloud-kms/src/v1/hsm_management_client.ts +++ b/packages/google-cloud-kms/src/v1/hsm_management_client.ts @@ -18,11 +18,24 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, IamClient, IamProtos, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, + PaginationCallback, + GaxCall, + IamClient, + IamProtos, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import { Transform } from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); -import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; +import { loggingUtils as logging, decodeAnyProtosInArray } from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -50,7 +63,7 @@ export class HsmManagementClient { 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('kms'); @@ -63,12 +76,12 @@ export class HsmManagementClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; iamClient: IamClient; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; + pathTemplates: { [name: string]: gax.PathTemplate }; operationsClient: gax.OperationsClient; - hsmManagementStub?: Promise<{[name: string]: Function}>; + hsmManagementStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of HsmManagementClient. @@ -109,21 +122,42 @@ export class HsmManagementClient { * const client = new HsmManagementClient({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 HsmManagementClient; - 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 = 'cloudkms.' + 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; @@ -148,7 +182,7 @@ export class HsmManagementClient { 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; @@ -161,18 +195,14 @@ export class HsmManagementClient { this.auth.defaultScopes = staticMembers.scopes; } this.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); - + this.locationsClient = new this._gaxModule.LocationsClient( this._gaxGrpc, - opts + opts, ); - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process === 'object' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -194,57 +224,64 @@ export class HsmManagementClient { // Create useful helper objects for these. this.pathTemplates = { 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}', ), ekmConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/ekmConfig' + 'projects/{project}/locations/{location}/ekmConfig', ), ekmConnectionPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/ekmConnections/{ekm_connection}' + 'projects/{project}/locations/{location}/ekmConnections/{ekm_connection}', ), folderAutokeyConfigPathTemplate: new this._gaxModule.PathTemplate( - 'folders/{folder}/autokeyConfig' + 'folders/{folder}/autokeyConfig', ), importJobPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/keyRings/{key_ring}/importJobs/{import_job}' + 'projects/{project}/locations/{location}/keyRings/{key_ring}/importJobs/{import_job}', ), keyHandlePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/keyHandles/{key_handle}' + 'projects/{project}/locations/{location}/keyHandles/{key_handle}', ), keyRingPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/keyRings/{key_ring}' + 'projects/{project}/locations/{location}/keyRings/{key_ring}', ), locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' + 'projects/{project}/locations/{location}', ), projectAutokeyConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/autokeyConfig' + 'projects/{project}/autokeyConfig', ), publicKeyPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}/publicKey' + 'projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}/publicKey', ), retiredResourcePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/retiredResources/{retired_resource}' + 'projects/{project}/locations/{location}/retiredResources/{retired_resource}', ), singleTenantHsmInstancePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/singleTenantHsmInstances/{single_tenant_hsm_instance}' - ), - singleTenantHsmInstanceProposalPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/singleTenantHsmInstances/{single_tenant_hsm_instance}/proposals/{proposal}' + 'projects/{project}/locations/{location}/singleTenantHsmInstances/{single_tenant_hsm_instance}', ), + singleTenantHsmInstanceProposalPathTemplate: + new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/singleTenantHsmInstances/{single_tenant_hsm_instance}/proposals/{proposal}', + ), }; // Some of the methods on this service return "paged" results, // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listSingleTenantHsmInstances: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'singleTenantHsmInstances'), - listSingleTenantHsmInstanceProposals: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'singleTenantHsmInstanceProposals') + listSingleTenantHsmInstances: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'singleTenantHsmInstances', + ), + listSingleTenantHsmInstanceProposals: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'singleTenantHsmInstanceProposals', + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -253,48 +290,152 @@ export class HsmManagementClient { // rather than holding a request open. const lroOptions: GrpcClientOptions = { auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1/{name=projects/*}/locations',},{selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',get: '/v1/{resource=projects/*/locations/*/keyRings/*}:getIamPolicy',additional_bindings: [{get: '/v1/{resource=projects/*/locations/*/keyRings/*/cryptoKeys/*}:getIamPolicy',},{get: '/v1/{resource=projects/*/locations/*/keyRings/*/importJobs/*}:getIamPolicy',},{get: '/v1/{resource=projects/*/locations/*/ekmConfig}:getIamPolicy',},{get: '/v1/{resource=projects/*/locations/*/ekmConnections/*}:getIamPolicy',}], - },{selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',post: '/v1/{resource=projects/*/locations/*/keyRings/*}:setIamPolicy',body: '*',additional_bindings: [{post: '/v1/{resource=projects/*/locations/*/keyRings/*/cryptoKeys/*}:setIamPolicy',body: '*',},{post: '/v1/{resource=projects/*/locations/*/keyRings/*/importJobs/*}:setIamPolicy',body: '*',},{post: '/v1/{resource=projects/*/locations/*/ekmConfig}:setIamPolicy',body: '*',},{post: '/v1/{resource=projects/*/locations/*/ekmConnections/*}:setIamPolicy',body: '*',}], - },{selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',post: '/v1/{resource=projects/*/locations/*/keyRings/*}:testIamPermissions',body: '*',additional_bindings: [{post: '/v1/{resource=projects/*/locations/*/keyRings/*/cryptoKeys/*}:testIamPermissions',body: '*',},{post: '/v1/{resource=projects/*/locations/*/keyRings/*/importJobs/*}:testIamPermissions',body: '*',},{post: '/v1/{resource=projects/*/locations/*/ekmConfig}:testIamPermissions',body: '*',},{post: '/v1/{resource=projects/*/locations/*/ekmConnections/*}:testIamPermissions',body: '*',}], - },{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/locations/*/operations/*}',}]; + lroOptions.httpRules = [ + { + selector: 'google.cloud.location.Locations.GetLocation', + get: '/v1/{name=projects/*/locations/*}', + }, + { + selector: 'google.cloud.location.Locations.ListLocations', + get: '/v1/{name=projects/*}/locations', + }, + { + selector: 'google.iam.v1.IAMPolicy.GetIamPolicy', + get: '/v1/{resource=projects/*/locations/*/keyRings/*}:getIamPolicy', + additional_bindings: [ + { + get: '/v1/{resource=projects/*/locations/*/keyRings/*/cryptoKeys/*}:getIamPolicy', + }, + { + get: '/v1/{resource=projects/*/locations/*/keyRings/*/importJobs/*}:getIamPolicy', + }, + { + get: '/v1/{resource=projects/*/locations/*/ekmConfig}:getIamPolicy', + }, + { + get: '/v1/{resource=projects/*/locations/*/ekmConnections/*}:getIamPolicy', + }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.SetIamPolicy', + post: '/v1/{resource=projects/*/locations/*/keyRings/*}:setIamPolicy', + body: '*', + additional_bindings: [ + { + post: '/v1/{resource=projects/*/locations/*/keyRings/*/cryptoKeys/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/keyRings/*/importJobs/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/ekmConfig}:setIamPolicy', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/ekmConnections/*}:setIamPolicy', + body: '*', + }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.TestIamPermissions', + post: '/v1/{resource=projects/*/locations/*/keyRings/*}:testIamPermissions', + body: '*', + additional_bindings: [ + { + post: '/v1/{resource=projects/*/locations/*/keyRings/*/cryptoKeys/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/keyRings/*/importJobs/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/ekmConfig}:testIamPermissions', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/ekmConnections/*}:testIamPermissions', + body: '*', + }, + ], + }, + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v1/{name=projects/*/locations/*/operations/*}', + }, + ]; } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); const createSingleTenantHsmInstanceResponse = protoFilesRoot.lookup( - '.google.cloud.kms.v1.SingleTenantHsmInstance') as gax.protobuf.Type; + '.google.cloud.kms.v1.SingleTenantHsmInstance', + ) as gax.protobuf.Type; const createSingleTenantHsmInstanceMetadata = protoFilesRoot.lookup( - '.google.cloud.kms.v1.CreateSingleTenantHsmInstanceMetadata') as gax.protobuf.Type; + '.google.cloud.kms.v1.CreateSingleTenantHsmInstanceMetadata', + ) as gax.protobuf.Type; const createSingleTenantHsmInstanceProposalResponse = protoFilesRoot.lookup( - '.google.cloud.kms.v1.SingleTenantHsmInstanceProposal') as gax.protobuf.Type; + '.google.cloud.kms.v1.SingleTenantHsmInstanceProposal', + ) as gax.protobuf.Type; const createSingleTenantHsmInstanceProposalMetadata = protoFilesRoot.lookup( - '.google.cloud.kms.v1.CreateSingleTenantHsmInstanceProposalMetadata') as gax.protobuf.Type; - const executeSingleTenantHsmInstanceProposalResponse = protoFilesRoot.lookup( - '.google.cloud.kms.v1.ExecuteSingleTenantHsmInstanceProposalResponse') as gax.protobuf.Type; - const executeSingleTenantHsmInstanceProposalMetadata = protoFilesRoot.lookup( - '.google.cloud.kms.v1.ExecuteSingleTenantHsmInstanceProposalMetadata') as gax.protobuf.Type; + '.google.cloud.kms.v1.CreateSingleTenantHsmInstanceProposalMetadata', + ) as gax.protobuf.Type; + const executeSingleTenantHsmInstanceProposalResponse = + protoFilesRoot.lookup( + '.google.cloud.kms.v1.ExecuteSingleTenantHsmInstanceProposalResponse', + ) as gax.protobuf.Type; + const executeSingleTenantHsmInstanceProposalMetadata = + protoFilesRoot.lookup( + '.google.cloud.kms.v1.ExecuteSingleTenantHsmInstanceProposalMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { createSingleTenantHsmInstance: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - createSingleTenantHsmInstanceResponse.decode.bind(createSingleTenantHsmInstanceResponse), - createSingleTenantHsmInstanceMetadata.decode.bind(createSingleTenantHsmInstanceMetadata)), - createSingleTenantHsmInstanceProposal: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - createSingleTenantHsmInstanceProposalResponse.decode.bind(createSingleTenantHsmInstanceProposalResponse), - createSingleTenantHsmInstanceProposalMetadata.decode.bind(createSingleTenantHsmInstanceProposalMetadata)), - executeSingleTenantHsmInstanceProposal: new this._gaxModule.LongrunningDescriptor( - this.operationsClient, - executeSingleTenantHsmInstanceProposalResponse.decode.bind(executeSingleTenantHsmInstanceProposalResponse), - executeSingleTenantHsmInstanceProposalMetadata.decode.bind(executeSingleTenantHsmInstanceProposalMetadata)) + createSingleTenantHsmInstanceResponse.decode.bind( + createSingleTenantHsmInstanceResponse, + ), + createSingleTenantHsmInstanceMetadata.decode.bind( + createSingleTenantHsmInstanceMetadata, + ), + ), + createSingleTenantHsmInstanceProposal: + new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createSingleTenantHsmInstanceProposalResponse.decode.bind( + createSingleTenantHsmInstanceProposalResponse, + ), + createSingleTenantHsmInstanceProposalMetadata.decode.bind( + createSingleTenantHsmInstanceProposalMetadata, + ), + ), + executeSingleTenantHsmInstanceProposal: + new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + executeSingleTenantHsmInstanceProposalResponse.decode.bind( + executeSingleTenantHsmInstanceProposalResponse, + ), + executeSingleTenantHsmInstanceProposalMetadata.decode.bind( + executeSingleTenantHsmInstanceProposalMetadata, + ), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.kms.v1.HsmManagement', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.kms.v1.HsmManagement', + 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 @@ -325,28 +466,43 @@ export class HsmManagementClient { // Put together the "service stub" for // google.cloud.kms.v1.HsmManagement. this.hsmManagementStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.kms.v1.HsmManagement') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.kms.v1.HsmManagement', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.kms.v1.HsmManagement, - 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 hsmManagementStubMethods = - ['listSingleTenantHsmInstances', 'getSingleTenantHsmInstance', 'createSingleTenantHsmInstance', 'createSingleTenantHsmInstanceProposal', 'approveSingleTenantHsmInstanceProposal', 'executeSingleTenantHsmInstanceProposal', 'getSingleTenantHsmInstanceProposal', 'listSingleTenantHsmInstanceProposals', 'deleteSingleTenantHsmInstanceProposal']; + const hsmManagementStubMethods = [ + 'listSingleTenantHsmInstances', + 'getSingleTenantHsmInstance', + 'createSingleTenantHsmInstance', + 'createSingleTenantHsmInstanceProposal', + 'approveSingleTenantHsmInstanceProposal', + 'executeSingleTenantHsmInstanceProposal', + 'getSingleTenantHsmInstanceProposal', + 'listSingleTenantHsmInstanceProposals', + 'deleteSingleTenantHsmInstanceProposal', + ]; for (const methodName of hsmManagementStubMethods) { const callPromise = this.hsmManagementStub.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] || @@ -356,7 +512,7 @@ export class HsmManagementClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -371,8 +527,14 @@ export class HsmManagementClient { * @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 'cloudkms.googleapis.com'; } @@ -383,8 +545,14 @@ export class HsmManagementClient { * @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 'cloudkms.googleapis.com'; } @@ -417,7 +585,7 @@ export class HsmManagementClient { static get scopes() { return [ 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/cloudkms' + 'https://www.googleapis.com/auth/cloudkms', ]; } @@ -427,8 +595,9 @@ export class HsmManagementClient { * 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; @@ -439,876 +608,1319 @@ export class HsmManagementClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Returns metadata for a given - * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstance|SingleTenantHsmInstance}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The {@link protos.google.cloud.kms.v1.SingleTenantHsmInstance.name|name} of - * the {@link protos.google.cloud.kms.v1.SingleTenantHsmInstance|SingleTenantHsmInstance} - * 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.kms.v1.SingleTenantHsmInstance|SingleTenantHsmInstance}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/hsm_management.get_single_tenant_hsm_instance.js - * region_tag:cloudkms_v1_generated_HsmManagement_GetSingleTenantHsmInstance_async - */ + /** + * Returns metadata for a given + * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstance|SingleTenantHsmInstance}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The {@link protos.google.cloud.kms.v1.SingleTenantHsmInstance.name|name} of + * the {@link protos.google.cloud.kms.v1.SingleTenantHsmInstance|SingleTenantHsmInstance} + * 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.kms.v1.SingleTenantHsmInstance|SingleTenantHsmInstance}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/hsm_management.get_single_tenant_hsm_instance.js + * region_tag:cloudkms_v1_generated_HsmManagement_GetSingleTenantHsmInstance_async + */ getSingleTenantHsmInstance( - request?: protos.google.cloud.kms.v1.IGetSingleTenantHsmInstanceRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.kms.v1.ISingleTenantHsmInstance, - protos.google.cloud.kms.v1.IGetSingleTenantHsmInstanceRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.kms.v1.IGetSingleTenantHsmInstanceRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.kms.v1.ISingleTenantHsmInstance, + protos.google.cloud.kms.v1.IGetSingleTenantHsmInstanceRequest | undefined, + {} | undefined, + ] + >; getSingleTenantHsmInstance( - request: protos.google.cloud.kms.v1.IGetSingleTenantHsmInstanceRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.kms.v1.ISingleTenantHsmInstance, - protos.google.cloud.kms.v1.IGetSingleTenantHsmInstanceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IGetSingleTenantHsmInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.kms.v1.ISingleTenantHsmInstance, + | protos.google.cloud.kms.v1.IGetSingleTenantHsmInstanceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getSingleTenantHsmInstance( - request: protos.google.cloud.kms.v1.IGetSingleTenantHsmInstanceRequest, - callback: Callback< - protos.google.cloud.kms.v1.ISingleTenantHsmInstance, - protos.google.cloud.kms.v1.IGetSingleTenantHsmInstanceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IGetSingleTenantHsmInstanceRequest, + callback: Callback< + protos.google.cloud.kms.v1.ISingleTenantHsmInstance, + | protos.google.cloud.kms.v1.IGetSingleTenantHsmInstanceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getSingleTenantHsmInstance( - request?: protos.google.cloud.kms.v1.IGetSingleTenantHsmInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.kms.v1.ISingleTenantHsmInstance, - protos.google.cloud.kms.v1.IGetSingleTenantHsmInstanceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.kms.v1.IGetSingleTenantHsmInstanceRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.kms.v1.ISingleTenantHsmInstance, - protos.google.cloud.kms.v1.IGetSingleTenantHsmInstanceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.kms.v1.ISingleTenantHsmInstance, - protos.google.cloud.kms.v1.IGetSingleTenantHsmInstanceRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.kms.v1.IGetSingleTenantHsmInstanceRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.kms.v1.ISingleTenantHsmInstance, + | protos.google.cloud.kms.v1.IGetSingleTenantHsmInstanceRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.kms.v1.ISingleTenantHsmInstance, + protos.google.cloud.kms.v1.IGetSingleTenantHsmInstanceRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getSingleTenantHsmInstance request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.kms.v1.ISingleTenantHsmInstance, - protos.google.cloud.kms.v1.IGetSingleTenantHsmInstanceRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.kms.v1.ISingleTenantHsmInstance, + | protos.google.cloud.kms.v1.IGetSingleTenantHsmInstanceRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getSingleTenantHsmInstance response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getSingleTenantHsmInstance(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.kms.v1.ISingleTenantHsmInstance, - protos.google.cloud.kms.v1.IGetSingleTenantHsmInstanceRequest|undefined, - {}|undefined - ]) => { - this._log.info('getSingleTenantHsmInstance response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getSingleTenantHsmInstance(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.kms.v1.ISingleTenantHsmInstance, + ( + | protos.google.cloud.kms.v1.IGetSingleTenantHsmInstanceRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getSingleTenantHsmInstance response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Approves a - * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal|SingleTenantHsmInstanceProposal} - * for a given - * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstance|SingleTenantHsmInstance}. The - * proposal must be in the - * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal.State.PENDING|PENDING} - * state. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The - * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal.name|name} of the - * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal|SingleTenantHsmInstanceProposal} - * to approve. - * @param {google.cloud.kms.v1.ApproveSingleTenantHsmInstanceProposalRequest.QuorumReply} request.quorumReply - * Required. The reply to - * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal.QuorumParameters|QuorumParameters} - * for approving the proposal. - * @param {google.cloud.kms.v1.ApproveSingleTenantHsmInstanceProposalRequest.RequiredActionQuorumReply} request.requiredActionQuorumReply - * Required. The reply to - * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal.RequiredActionQuorumParameters|RequiredActionQuorumParameters} - * for approving the proposal. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.kms.v1.ApproveSingleTenantHsmInstanceProposalResponse|ApproveSingleTenantHsmInstanceProposalResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/hsm_management.approve_single_tenant_hsm_instance_proposal.js - * region_tag:cloudkms_v1_generated_HsmManagement_ApproveSingleTenantHsmInstanceProposal_async - */ + /** + * Approves a + * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal|SingleTenantHsmInstanceProposal} + * for a given + * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstance|SingleTenantHsmInstance}. The + * proposal must be in the + * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal.State.PENDING|PENDING} + * state. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The + * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal.name|name} of the + * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal|SingleTenantHsmInstanceProposal} + * to approve. + * @param {google.cloud.kms.v1.ApproveSingleTenantHsmInstanceProposalRequest.QuorumReply} request.quorumReply + * Required. The reply to + * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal.QuorumParameters|QuorumParameters} + * for approving the proposal. + * @param {google.cloud.kms.v1.ApproveSingleTenantHsmInstanceProposalRequest.RequiredActionQuorumReply} request.requiredActionQuorumReply + * Required. The reply to + * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal.RequiredActionQuorumParameters|RequiredActionQuorumParameters} + * for approving the proposal. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.kms.v1.ApproveSingleTenantHsmInstanceProposalResponse|ApproveSingleTenantHsmInstanceProposalResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/hsm_management.approve_single_tenant_hsm_instance_proposal.js + * region_tag:cloudkms_v1_generated_HsmManagement_ApproveSingleTenantHsmInstanceProposal_async + */ approveSingleTenantHsmInstanceProposal( - request?: protos.google.cloud.kms.v1.IApproveSingleTenantHsmInstanceProposalRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.kms.v1.IApproveSingleTenantHsmInstanceProposalResponse, - protos.google.cloud.kms.v1.IApproveSingleTenantHsmInstanceProposalRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.kms.v1.IApproveSingleTenantHsmInstanceProposalRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.kms.v1.IApproveSingleTenantHsmInstanceProposalResponse, + ( + | protos.google.cloud.kms.v1.IApproveSingleTenantHsmInstanceProposalRequest + | undefined + ), + {} | undefined, + ] + >; approveSingleTenantHsmInstanceProposal( - request: protos.google.cloud.kms.v1.IApproveSingleTenantHsmInstanceProposalRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.kms.v1.IApproveSingleTenantHsmInstanceProposalResponse, - protos.google.cloud.kms.v1.IApproveSingleTenantHsmInstanceProposalRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IApproveSingleTenantHsmInstanceProposalRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.kms.v1.IApproveSingleTenantHsmInstanceProposalResponse, + | protos.google.cloud.kms.v1.IApproveSingleTenantHsmInstanceProposalRequest + | null + | undefined, + {} | null | undefined + >, + ): void; approveSingleTenantHsmInstanceProposal( - request: protos.google.cloud.kms.v1.IApproveSingleTenantHsmInstanceProposalRequest, - callback: Callback< - protos.google.cloud.kms.v1.IApproveSingleTenantHsmInstanceProposalResponse, - protos.google.cloud.kms.v1.IApproveSingleTenantHsmInstanceProposalRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IApproveSingleTenantHsmInstanceProposalRequest, + callback: Callback< + protos.google.cloud.kms.v1.IApproveSingleTenantHsmInstanceProposalResponse, + | protos.google.cloud.kms.v1.IApproveSingleTenantHsmInstanceProposalRequest + | null + | undefined, + {} | null | undefined + >, + ): void; approveSingleTenantHsmInstanceProposal( - request?: protos.google.cloud.kms.v1.IApproveSingleTenantHsmInstanceProposalRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.kms.v1.IApproveSingleTenantHsmInstanceProposalResponse, - protos.google.cloud.kms.v1.IApproveSingleTenantHsmInstanceProposalRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.kms.v1.IApproveSingleTenantHsmInstanceProposalRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.kms.v1.IApproveSingleTenantHsmInstanceProposalResponse, - protos.google.cloud.kms.v1.IApproveSingleTenantHsmInstanceProposalRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.kms.v1.IApproveSingleTenantHsmInstanceProposalResponse, - protos.google.cloud.kms.v1.IApproveSingleTenantHsmInstanceProposalRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.kms.v1.IApproveSingleTenantHsmInstanceProposalRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.kms.v1.IApproveSingleTenantHsmInstanceProposalResponse, + | protos.google.cloud.kms.v1.IApproveSingleTenantHsmInstanceProposalRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.kms.v1.IApproveSingleTenantHsmInstanceProposalResponse, + ( + | protos.google.cloud.kms.v1.IApproveSingleTenantHsmInstanceProposalRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('approveSingleTenantHsmInstanceProposal request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.kms.v1.IApproveSingleTenantHsmInstanceProposalResponse, - protos.google.cloud.kms.v1.IApproveSingleTenantHsmInstanceProposalRequest|null|undefined, - {}|null|undefined>|undefined = callback + this._log.info( + 'approveSingleTenantHsmInstanceProposal request %j', + request, + ); + const wrappedCallback: + | Callback< + protos.google.cloud.kms.v1.IApproveSingleTenantHsmInstanceProposalResponse, + | protos.google.cloud.kms.v1.IApproveSingleTenantHsmInstanceProposalRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { - this._log.info('approveSingleTenantHsmInstanceProposal response %j', response); + this._log.info( + 'approveSingleTenantHsmInstanceProposal response %j', + response, + ); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.approveSingleTenantHsmInstanceProposal(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.kms.v1.IApproveSingleTenantHsmInstanceProposalResponse, - protos.google.cloud.kms.v1.IApproveSingleTenantHsmInstanceProposalRequest|undefined, - {}|undefined - ]) => { - this._log.info('approveSingleTenantHsmInstanceProposal response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .approveSingleTenantHsmInstanceProposal(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.kms.v1.IApproveSingleTenantHsmInstanceProposalResponse, + ( + | protos.google.cloud.kms.v1.IApproveSingleTenantHsmInstanceProposalRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info( + 'approveSingleTenantHsmInstanceProposal response %j', + response, + ); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 metadata for a given - * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal|SingleTenantHsmInstanceProposal}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The - * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal.name|name} of the - * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal|SingleTenantHsmInstanceProposal} - * 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.kms.v1.SingleTenantHsmInstanceProposal|SingleTenantHsmInstanceProposal}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/hsm_management.get_single_tenant_hsm_instance_proposal.js - * region_tag:cloudkms_v1_generated_HsmManagement_GetSingleTenantHsmInstanceProposal_async - */ + /** + * Returns metadata for a given + * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal|SingleTenantHsmInstanceProposal}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The + * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal.name|name} of the + * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal|SingleTenantHsmInstanceProposal} + * 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.kms.v1.SingleTenantHsmInstanceProposal|SingleTenantHsmInstanceProposal}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/hsm_management.get_single_tenant_hsm_instance_proposal.js + * region_tag:cloudkms_v1_generated_HsmManagement_GetSingleTenantHsmInstanceProposal_async + */ getSingleTenantHsmInstanceProposal( - request?: protos.google.cloud.kms.v1.IGetSingleTenantHsmInstanceProposalRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.kms.v1.ISingleTenantHsmInstanceProposal, - protos.google.cloud.kms.v1.IGetSingleTenantHsmInstanceProposalRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.kms.v1.IGetSingleTenantHsmInstanceProposalRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.kms.v1.ISingleTenantHsmInstanceProposal, + ( + | protos.google.cloud.kms.v1.IGetSingleTenantHsmInstanceProposalRequest + | undefined + ), + {} | undefined, + ] + >; getSingleTenantHsmInstanceProposal( - request: protos.google.cloud.kms.v1.IGetSingleTenantHsmInstanceProposalRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.kms.v1.ISingleTenantHsmInstanceProposal, - protos.google.cloud.kms.v1.IGetSingleTenantHsmInstanceProposalRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IGetSingleTenantHsmInstanceProposalRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.kms.v1.ISingleTenantHsmInstanceProposal, + | protos.google.cloud.kms.v1.IGetSingleTenantHsmInstanceProposalRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getSingleTenantHsmInstanceProposal( - request: protos.google.cloud.kms.v1.IGetSingleTenantHsmInstanceProposalRequest, - callback: Callback< - protos.google.cloud.kms.v1.ISingleTenantHsmInstanceProposal, - protos.google.cloud.kms.v1.IGetSingleTenantHsmInstanceProposalRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IGetSingleTenantHsmInstanceProposalRequest, + callback: Callback< + protos.google.cloud.kms.v1.ISingleTenantHsmInstanceProposal, + | protos.google.cloud.kms.v1.IGetSingleTenantHsmInstanceProposalRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getSingleTenantHsmInstanceProposal( - request?: protos.google.cloud.kms.v1.IGetSingleTenantHsmInstanceProposalRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.kms.v1.ISingleTenantHsmInstanceProposal, - protos.google.cloud.kms.v1.IGetSingleTenantHsmInstanceProposalRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.kms.v1.IGetSingleTenantHsmInstanceProposalRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.kms.v1.ISingleTenantHsmInstanceProposal, - protos.google.cloud.kms.v1.IGetSingleTenantHsmInstanceProposalRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.kms.v1.ISingleTenantHsmInstanceProposal, - protos.google.cloud.kms.v1.IGetSingleTenantHsmInstanceProposalRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.kms.v1.IGetSingleTenantHsmInstanceProposalRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.kms.v1.ISingleTenantHsmInstanceProposal, + | protos.google.cloud.kms.v1.IGetSingleTenantHsmInstanceProposalRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.kms.v1.ISingleTenantHsmInstanceProposal, + ( + | protos.google.cloud.kms.v1.IGetSingleTenantHsmInstanceProposalRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getSingleTenantHsmInstanceProposal request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.kms.v1.ISingleTenantHsmInstanceProposal, - protos.google.cloud.kms.v1.IGetSingleTenantHsmInstanceProposalRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.kms.v1.ISingleTenantHsmInstanceProposal, + | protos.google.cloud.kms.v1.IGetSingleTenantHsmInstanceProposalRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { - this._log.info('getSingleTenantHsmInstanceProposal response %j', response); + this._log.info( + 'getSingleTenantHsmInstanceProposal response %j', + response, + ); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getSingleTenantHsmInstanceProposal(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.kms.v1.ISingleTenantHsmInstanceProposal, - protos.google.cloud.kms.v1.IGetSingleTenantHsmInstanceProposalRequest|undefined, - {}|undefined - ]) => { - this._log.info('getSingleTenantHsmInstanceProposal response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getSingleTenantHsmInstanceProposal(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.kms.v1.ISingleTenantHsmInstanceProposal, + ( + | protos.google.cloud.kms.v1.IGetSingleTenantHsmInstanceProposalRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info( + 'getSingleTenantHsmInstanceProposal response %j', + response, + ); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 - * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal|SingleTenantHsmInstanceProposal}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The - * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal.name|name} of the - * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal|SingleTenantHsmInstanceProposal} - * 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/hsm_management.delete_single_tenant_hsm_instance_proposal.js - * region_tag:cloudkms_v1_generated_HsmManagement_DeleteSingleTenantHsmInstanceProposal_async - */ + /** + * Deletes a + * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal|SingleTenantHsmInstanceProposal}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The + * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal.name|name} of the + * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal|SingleTenantHsmInstanceProposal} + * 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/hsm_management.delete_single_tenant_hsm_instance_proposal.js + * region_tag:cloudkms_v1_generated_HsmManagement_DeleteSingleTenantHsmInstanceProposal_async + */ deleteSingleTenantHsmInstanceProposal( - request?: protos.google.cloud.kms.v1.IDeleteSingleTenantHsmInstanceProposalRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.kms.v1.IDeleteSingleTenantHsmInstanceProposalRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.kms.v1.IDeleteSingleTenantHsmInstanceProposalRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.kms.v1.IDeleteSingleTenantHsmInstanceProposalRequest + | undefined + ), + {} | undefined, + ] + >; deleteSingleTenantHsmInstanceProposal( - request: protos.google.cloud.kms.v1.IDeleteSingleTenantHsmInstanceProposalRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.kms.v1.IDeleteSingleTenantHsmInstanceProposalRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IDeleteSingleTenantHsmInstanceProposalRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.kms.v1.IDeleteSingleTenantHsmInstanceProposalRequest + | null + | undefined, + {} | null | undefined + >, + ): void; deleteSingleTenantHsmInstanceProposal( - request: protos.google.cloud.kms.v1.IDeleteSingleTenantHsmInstanceProposalRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.kms.v1.IDeleteSingleTenantHsmInstanceProposalRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IDeleteSingleTenantHsmInstanceProposalRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.kms.v1.IDeleteSingleTenantHsmInstanceProposalRequest + | null + | undefined, + {} | null | undefined + >, + ): void; deleteSingleTenantHsmInstanceProposal( - request?: protos.google.cloud.kms.v1.IDeleteSingleTenantHsmInstanceProposalRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.kms.v1.IDeleteSingleTenantHsmInstanceProposalRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.kms.v1.IDeleteSingleTenantHsmInstanceProposalRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.protobuf.IEmpty, - protos.google.cloud.kms.v1.IDeleteSingleTenantHsmInstanceProposalRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.kms.v1.IDeleteSingleTenantHsmInstanceProposalRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.kms.v1.IDeleteSingleTenantHsmInstanceProposalRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.kms.v1.IDeleteSingleTenantHsmInstanceProposalRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.kms.v1.IDeleteSingleTenantHsmInstanceProposalRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('deleteSingleTenantHsmInstanceProposal request %j', request); - const wrappedCallback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.kms.v1.IDeleteSingleTenantHsmInstanceProposalRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.kms.v1.IDeleteSingleTenantHsmInstanceProposalRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { - this._log.info('deleteSingleTenantHsmInstanceProposal response %j', response); + this._log.info( + 'deleteSingleTenantHsmInstanceProposal response %j', + response, + ); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.deleteSingleTenantHsmInstanceProposal(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.protobuf.IEmpty, - protos.google.cloud.kms.v1.IDeleteSingleTenantHsmInstanceProposalRequest|undefined, - {}|undefined - ]) => { - this._log.info('deleteSingleTenantHsmInstanceProposal response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .deleteSingleTenantHsmInstanceProposal(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.kms.v1.IDeleteSingleTenantHsmInstanceProposalRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info( + 'deleteSingleTenantHsmInstanceProposal response %j', + response, + ); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 - * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstance|SingleTenantHsmInstance} in a - * given Project and Location. User must create a RegisterTwoFactorAuthKeys - * proposal with this single-tenant HSM instance to finish setup of the - * instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the location associated with the - * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstance|SingleTenantHsmInstance}, in - * the format `projects/* /locations/*`. - * @param {string} [request.singleTenantHsmInstanceId] - * Optional. It must be unique within a location and match the regular - * expression `[a-zA-Z0-9_-]{1,63}`. - * @param {google.cloud.kms.v1.SingleTenantHsmInstance} request.singleTenantHsmInstance - * Required. An - * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstance|SingleTenantHsmInstance} with - * initial field values. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/hsm_management.create_single_tenant_hsm_instance.js - * region_tag:cloudkms_v1_generated_HsmManagement_CreateSingleTenantHsmInstance_async - */ + /** + * Creates a new + * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstance|SingleTenantHsmInstance} in a + * given Project and Location. User must create a RegisterTwoFactorAuthKeys + * proposal with this single-tenant HSM instance to finish setup of the + * instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the location associated with the + * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstance|SingleTenantHsmInstance}, in + * the format `projects/* /locations/*`. + * @param {string} [request.singleTenantHsmInstanceId] + * Optional. It must be unique within a location and match the regular + * expression `[a-zA-Z0-9_-]{1,63}`. + * @param {google.cloud.kms.v1.SingleTenantHsmInstance} request.singleTenantHsmInstance + * Required. An + * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstance|SingleTenantHsmInstance} with + * initial field values. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/hsm_management.create_single_tenant_hsm_instance.js + * region_tag:cloudkms_v1_generated_HsmManagement_CreateSingleTenantHsmInstance_async + */ createSingleTenantHsmInstance( - request?: protos.google.cloud.kms.v1.ICreateSingleTenantHsmInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.kms.v1.ICreateSingleTenantHsmInstanceRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.kms.v1.ISingleTenantHsmInstance, + protos.google.cloud.kms.v1.ICreateSingleTenantHsmInstanceMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createSingleTenantHsmInstance( - request: protos.google.cloud.kms.v1.ICreateSingleTenantHsmInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.ICreateSingleTenantHsmInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.kms.v1.ISingleTenantHsmInstance, + protos.google.cloud.kms.v1.ICreateSingleTenantHsmInstanceMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createSingleTenantHsmInstance( - request: protos.google.cloud.kms.v1.ICreateSingleTenantHsmInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.ICreateSingleTenantHsmInstanceRequest, + callback: Callback< + LROperation< + protos.google.cloud.kms.v1.ISingleTenantHsmInstance, + protos.google.cloud.kms.v1.ICreateSingleTenantHsmInstanceMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createSingleTenantHsmInstance( - request?: protos.google.cloud.kms.v1.ICreateSingleTenantHsmInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.kms.v1.ICreateSingleTenantHsmInstanceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.kms.v1.ISingleTenantHsmInstance, + protos.google.cloud.kms.v1.ICreateSingleTenantHsmInstanceMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.kms.v1.ISingleTenantHsmInstance, + protos.google.cloud.kms.v1.ICreateSingleTenantHsmInstanceMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.kms.v1.ISingleTenantHsmInstance, + protos.google.cloud.kms.v1.ICreateSingleTenantHsmInstanceMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-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.kms.v1.ISingleTenantHsmInstance, + protos.google.cloud.kms.v1.ICreateSingleTenantHsmInstanceMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { - this._log.info('createSingleTenantHsmInstance response %j', rawResponse); + this._log.info( + 'createSingleTenantHsmInstance response %j', + rawResponse, + ); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createSingleTenantHsmInstance request %j', request); - return this.innerApiCalls.createSingleTenantHsmInstance(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createSingleTenantHsmInstance response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createSingleTenantHsmInstance(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.kms.v1.ISingleTenantHsmInstance, + protos.google.cloud.kms.v1.ICreateSingleTenantHsmInstanceMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info( + 'createSingleTenantHsmInstance response %j', + rawResponse, + ); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createSingleTenantHsmInstance()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/hsm_management.create_single_tenant_hsm_instance.js - * region_tag:cloudkms_v1_generated_HsmManagement_CreateSingleTenantHsmInstance_async - */ - async checkCreateSingleTenantHsmInstanceProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createSingleTenantHsmInstance()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/hsm_management.create_single_tenant_hsm_instance.js + * region_tag:cloudkms_v1_generated_HsmManagement_CreateSingleTenantHsmInstance_async + */ + async checkCreateSingleTenantHsmInstanceProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.kms.v1.SingleTenantHsmInstance, + protos.google.cloud.kms.v1.CreateSingleTenantHsmInstanceMetadata + > + > { this._log.info('createSingleTenantHsmInstance long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createSingleTenantHsmInstance, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createSingleTenantHsmInstance, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.kms.v1.SingleTenantHsmInstance, + protos.google.cloud.kms.v1.CreateSingleTenantHsmInstanceMetadata + >; } -/** - * Creates a new - * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal|SingleTenantHsmInstanceProposal} - * for a given - * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstance|SingleTenantHsmInstance}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The {@link protos.google.cloud.kms.v1.SingleTenantHsmInstance.name|name} of - * the {@link protos.google.cloud.kms.v1.SingleTenantHsmInstance|SingleTenantHsmInstance} - * associated with the - * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal|SingleTenantHsmInstanceProposals}. - * @param {string} [request.singleTenantHsmInstanceProposalId] - * Optional. It must be unique within a location and match the regular - * expression `[a-zA-Z0-9_-]{1,63}`. - * @param {google.cloud.kms.v1.SingleTenantHsmInstanceProposal} request.singleTenantHsmInstanceProposal - * Required. The - * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal|SingleTenantHsmInstanceProposal} - * 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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/hsm_management.create_single_tenant_hsm_instance_proposal.js - * region_tag:cloudkms_v1_generated_HsmManagement_CreateSingleTenantHsmInstanceProposal_async - */ + /** + * Creates a new + * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal|SingleTenantHsmInstanceProposal} + * for a given + * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstance|SingleTenantHsmInstance}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The {@link protos.google.cloud.kms.v1.SingleTenantHsmInstance.name|name} of + * the {@link protos.google.cloud.kms.v1.SingleTenantHsmInstance|SingleTenantHsmInstance} + * associated with the + * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal|SingleTenantHsmInstanceProposals}. + * @param {string} [request.singleTenantHsmInstanceProposalId] + * Optional. It must be unique within a location and match the regular + * expression `[a-zA-Z0-9_-]{1,63}`. + * @param {google.cloud.kms.v1.SingleTenantHsmInstanceProposal} request.singleTenantHsmInstanceProposal + * Required. The + * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal|SingleTenantHsmInstanceProposal} + * 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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/hsm_management.create_single_tenant_hsm_instance_proposal.js + * region_tag:cloudkms_v1_generated_HsmManagement_CreateSingleTenantHsmInstanceProposal_async + */ createSingleTenantHsmInstanceProposal( - request?: protos.google.cloud.kms.v1.ICreateSingleTenantHsmInstanceProposalRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.kms.v1.ICreateSingleTenantHsmInstanceProposalRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.kms.v1.ISingleTenantHsmInstanceProposal, + protos.google.cloud.kms.v1.ICreateSingleTenantHsmInstanceProposalMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createSingleTenantHsmInstanceProposal( - request: protos.google.cloud.kms.v1.ICreateSingleTenantHsmInstanceProposalRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.ICreateSingleTenantHsmInstanceProposalRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.kms.v1.ISingleTenantHsmInstanceProposal, + protos.google.cloud.kms.v1.ICreateSingleTenantHsmInstanceProposalMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createSingleTenantHsmInstanceProposal( - request: protos.google.cloud.kms.v1.ICreateSingleTenantHsmInstanceProposalRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.ICreateSingleTenantHsmInstanceProposalRequest, + callback: Callback< + LROperation< + protos.google.cloud.kms.v1.ISingleTenantHsmInstanceProposal, + protos.google.cloud.kms.v1.ICreateSingleTenantHsmInstanceProposalMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createSingleTenantHsmInstanceProposal( - request?: protos.google.cloud.kms.v1.ICreateSingleTenantHsmInstanceProposalRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.kms.v1.ICreateSingleTenantHsmInstanceProposalRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.kms.v1.ISingleTenantHsmInstanceProposal, + protos.google.cloud.kms.v1.ICreateSingleTenantHsmInstanceProposalMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.kms.v1.ISingleTenantHsmInstanceProposal, + protos.google.cloud.kms.v1.ICreateSingleTenantHsmInstanceProposalMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.kms.v1.ISingleTenantHsmInstanceProposal, + protos.google.cloud.kms.v1.ICreateSingleTenantHsmInstanceProposalMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-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.kms.v1.ISingleTenantHsmInstanceProposal, + protos.google.cloud.kms.v1.ICreateSingleTenantHsmInstanceProposalMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { - this._log.info('createSingleTenantHsmInstanceProposal response %j', rawResponse); + this._log.info( + 'createSingleTenantHsmInstanceProposal response %j', + rawResponse, + ); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createSingleTenantHsmInstanceProposal request %j', request); - return this.innerApiCalls.createSingleTenantHsmInstanceProposal(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createSingleTenantHsmInstanceProposal response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createSingleTenantHsmInstanceProposal(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.kms.v1.ISingleTenantHsmInstanceProposal, + protos.google.cloud.kms.v1.ICreateSingleTenantHsmInstanceProposalMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info( + 'createSingleTenantHsmInstanceProposal response %j', + rawResponse, + ); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createSingleTenantHsmInstanceProposal()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/hsm_management.create_single_tenant_hsm_instance_proposal.js - * region_tag:cloudkms_v1_generated_HsmManagement_CreateSingleTenantHsmInstanceProposal_async - */ - async checkCreateSingleTenantHsmInstanceProposalProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createSingleTenantHsmInstanceProposal()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/hsm_management.create_single_tenant_hsm_instance_proposal.js + * region_tag:cloudkms_v1_generated_HsmManagement_CreateSingleTenantHsmInstanceProposal_async + */ + async checkCreateSingleTenantHsmInstanceProposalProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal, + protos.google.cloud.kms.v1.CreateSingleTenantHsmInstanceProposalMetadata + > + > { this._log.info('createSingleTenantHsmInstanceProposal long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createSingleTenantHsmInstanceProposal, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createSingleTenantHsmInstanceProposal, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal, + protos.google.cloud.kms.v1.CreateSingleTenantHsmInstanceProposalMetadata + >; } -/** - * Executes a - * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal|SingleTenantHsmInstanceProposal} - * for a given - * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstance|SingleTenantHsmInstance}. The - * proposal must be in the - * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal.State.APPROVED|APPROVED} - * state. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The - * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal.name|name} of the - * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal|SingleTenantHsmInstanceProposal} - * to execute. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/hsm_management.execute_single_tenant_hsm_instance_proposal.js - * region_tag:cloudkms_v1_generated_HsmManagement_ExecuteSingleTenantHsmInstanceProposal_async - */ + /** + * Executes a + * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal|SingleTenantHsmInstanceProposal} + * for a given + * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstance|SingleTenantHsmInstance}. The + * proposal must be in the + * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal.State.APPROVED|APPROVED} + * state. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The + * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal.name|name} of the + * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal|SingleTenantHsmInstanceProposal} + * to execute. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/hsm_management.execute_single_tenant_hsm_instance_proposal.js + * region_tag:cloudkms_v1_generated_HsmManagement_ExecuteSingleTenantHsmInstanceProposal_async + */ executeSingleTenantHsmInstanceProposal( - request?: protos.google.cloud.kms.v1.IExecuteSingleTenantHsmInstanceProposalRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.kms.v1.IExecuteSingleTenantHsmInstanceProposalRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.kms.v1.IExecuteSingleTenantHsmInstanceProposalResponse, + protos.google.cloud.kms.v1.IExecuteSingleTenantHsmInstanceProposalMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; executeSingleTenantHsmInstanceProposal( - request: protos.google.cloud.kms.v1.IExecuteSingleTenantHsmInstanceProposalRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IExecuteSingleTenantHsmInstanceProposalRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.kms.v1.IExecuteSingleTenantHsmInstanceProposalResponse, + protos.google.cloud.kms.v1.IExecuteSingleTenantHsmInstanceProposalMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; executeSingleTenantHsmInstanceProposal( - request: protos.google.cloud.kms.v1.IExecuteSingleTenantHsmInstanceProposalRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IExecuteSingleTenantHsmInstanceProposalRequest, + callback: Callback< + LROperation< + protos.google.cloud.kms.v1.IExecuteSingleTenantHsmInstanceProposalResponse, + protos.google.cloud.kms.v1.IExecuteSingleTenantHsmInstanceProposalMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; executeSingleTenantHsmInstanceProposal( - request?: protos.google.cloud.kms.v1.IExecuteSingleTenantHsmInstanceProposalRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.kms.v1.IExecuteSingleTenantHsmInstanceProposalRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.kms.v1.IExecuteSingleTenantHsmInstanceProposalResponse, + protos.google.cloud.kms.v1.IExecuteSingleTenantHsmInstanceProposalMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.kms.v1.IExecuteSingleTenantHsmInstanceProposalResponse, + protos.google.cloud.kms.v1.IExecuteSingleTenantHsmInstanceProposalMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.kms.v1.IExecuteSingleTenantHsmInstanceProposalResponse, + protos.google.cloud.kms.v1.IExecuteSingleTenantHsmInstanceProposalMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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.kms.v1.IExecuteSingleTenantHsmInstanceProposalResponse, + protos.google.cloud.kms.v1.IExecuteSingleTenantHsmInstanceProposalMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { - this._log.info('executeSingleTenantHsmInstanceProposal response %j', rawResponse); + this._log.info( + 'executeSingleTenantHsmInstanceProposal response %j', + rawResponse, + ); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; - this._log.info('executeSingleTenantHsmInstanceProposal request %j', request); - return this.innerApiCalls.executeSingleTenantHsmInstanceProposal(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('executeSingleTenantHsmInstanceProposal response %j', rawResponse); - return [response, rawResponse, _]; - }); + this._log.info( + 'executeSingleTenantHsmInstanceProposal request %j', + request, + ); + return this.innerApiCalls + .executeSingleTenantHsmInstanceProposal(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.kms.v1.IExecuteSingleTenantHsmInstanceProposalResponse, + protos.google.cloud.kms.v1.IExecuteSingleTenantHsmInstanceProposalMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info( + 'executeSingleTenantHsmInstanceProposal response %j', + rawResponse, + ); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `executeSingleTenantHsmInstanceProposal()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/hsm_management.execute_single_tenant_hsm_instance_proposal.js - * region_tag:cloudkms_v1_generated_HsmManagement_ExecuteSingleTenantHsmInstanceProposal_async - */ - async checkExecuteSingleTenantHsmInstanceProposalProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `executeSingleTenantHsmInstanceProposal()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/hsm_management.execute_single_tenant_hsm_instance_proposal.js + * region_tag:cloudkms_v1_generated_HsmManagement_ExecuteSingleTenantHsmInstanceProposal_async + */ + async checkExecuteSingleTenantHsmInstanceProposalProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.kms.v1.ExecuteSingleTenantHsmInstanceProposalResponse, + protos.google.cloud.kms.v1.ExecuteSingleTenantHsmInstanceProposalMetadata + > + > { this._log.info('executeSingleTenantHsmInstanceProposal long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.executeSingleTenantHsmInstanceProposal, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.executeSingleTenantHsmInstanceProposal, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.kms.v1.ExecuteSingleTenantHsmInstanceProposalResponse, + protos.google.cloud.kms.v1.ExecuteSingleTenantHsmInstanceProposalMetadata + >; } - /** - * Lists - * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstance|SingleTenantHsmInstances}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the location associated with the - * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstance|SingleTenantHsmInstances} to - * list, in the format `projects/* /locations/*`. - * @param {number} [request.pageSize] - * Optional. Optional limit on the number of - * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstance|SingleTenantHsmInstances} to - * include in the response. Further - * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstance|SingleTenantHsmInstances} can - * subsequently be - * obtained by including the - * {@link protos.google.cloud.kms.v1.ListSingleTenantHsmInstancesResponse.next_page_token|ListSingleTenantHsmInstancesResponse.next_page_token} - * in a subsequent request. If unspecified, the server will pick an - * appropriate default. - * @param {string} [request.pageToken] - * Optional. Optional pagination token, returned earlier via - * {@link protos.google.cloud.kms.v1.ListSingleTenantHsmInstancesResponse.next_page_token|ListSingleTenantHsmInstancesResponse.next_page_token}. - * @param {string} [request.filter] - * Optional. Only include resources that match the filter in the response. For - * more information, see - * [Sorting and filtering list - * results](https://cloud.google.com/kms/docs/sorting-and-filtering). - * @param {string} [request.orderBy] - * Optional. Specify how the results should be sorted. If not specified, the - * results will be sorted in the default order. For more information, see - * [Sorting and filtering list - * results](https://cloud.google.com/kms/docs/sorting-and-filtering). - * @param {boolean} [request.showDeleted] - * Optional. If set to true, - * {@link protos.google.cloud.kms.v1.HsmManagement.ListSingleTenantHsmInstances|HsmManagement.ListSingleTenantHsmInstances} - * will also return - * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstance|SingleTenantHsmInstances} in - * DELETED state. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link protos.google.cloud.kms.v1.SingleTenantHsmInstance|SingleTenantHsmInstance}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listSingleTenantHsmInstancesAsync()` - * method described below for async iteration which you can stop as 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 + * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstance|SingleTenantHsmInstances}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the location associated with the + * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstance|SingleTenantHsmInstances} to + * list, in the format `projects/* /locations/*`. + * @param {number} [request.pageSize] + * Optional. Optional limit on the number of + * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstance|SingleTenantHsmInstances} to + * include in the response. Further + * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstance|SingleTenantHsmInstances} can + * subsequently be + * obtained by including the + * {@link protos.google.cloud.kms.v1.ListSingleTenantHsmInstancesResponse.next_page_token|ListSingleTenantHsmInstancesResponse.next_page_token} + * in a subsequent request. If unspecified, the server will pick an + * appropriate default. + * @param {string} [request.pageToken] + * Optional. Optional pagination token, returned earlier via + * {@link protos.google.cloud.kms.v1.ListSingleTenantHsmInstancesResponse.next_page_token|ListSingleTenantHsmInstancesResponse.next_page_token}. + * @param {string} [request.filter] + * Optional. Only include resources that match the filter in the response. For + * more information, see + * [Sorting and filtering list + * results](https://cloud.google.com/kms/docs/sorting-and-filtering). + * @param {string} [request.orderBy] + * Optional. Specify how the results should be sorted. If not specified, the + * results will be sorted in the default order. For more information, see + * [Sorting and filtering list + * results](https://cloud.google.com/kms/docs/sorting-and-filtering). + * @param {boolean} [request.showDeleted] + * Optional. If set to true, + * {@link protos.google.cloud.kms.v1.HsmManagement.ListSingleTenantHsmInstances|HsmManagement.ListSingleTenantHsmInstances} + * will also return + * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstance|SingleTenantHsmInstances} in + * DELETED state. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.kms.v1.SingleTenantHsmInstance|SingleTenantHsmInstance}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listSingleTenantHsmInstancesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listSingleTenantHsmInstances( - request?: protos.google.cloud.kms.v1.IListSingleTenantHsmInstancesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.kms.v1.ISingleTenantHsmInstance[], - protos.google.cloud.kms.v1.IListSingleTenantHsmInstancesRequest|null, - protos.google.cloud.kms.v1.IListSingleTenantHsmInstancesResponse - ]>; + request?: protos.google.cloud.kms.v1.IListSingleTenantHsmInstancesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.kms.v1.ISingleTenantHsmInstance[], + protos.google.cloud.kms.v1.IListSingleTenantHsmInstancesRequest | null, + protos.google.cloud.kms.v1.IListSingleTenantHsmInstancesResponse, + ] + >; listSingleTenantHsmInstances( - request: protos.google.cloud.kms.v1.IListSingleTenantHsmInstancesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.kms.v1.IListSingleTenantHsmInstancesRequest, - protos.google.cloud.kms.v1.IListSingleTenantHsmInstancesResponse|null|undefined, - protos.google.cloud.kms.v1.ISingleTenantHsmInstance>): void; + request: protos.google.cloud.kms.v1.IListSingleTenantHsmInstancesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.kms.v1.IListSingleTenantHsmInstancesRequest, + | protos.google.cloud.kms.v1.IListSingleTenantHsmInstancesResponse + | null + | undefined, + protos.google.cloud.kms.v1.ISingleTenantHsmInstance + >, + ): void; listSingleTenantHsmInstances( - request: protos.google.cloud.kms.v1.IListSingleTenantHsmInstancesRequest, - callback: PaginationCallback< - protos.google.cloud.kms.v1.IListSingleTenantHsmInstancesRequest, - protos.google.cloud.kms.v1.IListSingleTenantHsmInstancesResponse|null|undefined, - protos.google.cloud.kms.v1.ISingleTenantHsmInstance>): void; + request: protos.google.cloud.kms.v1.IListSingleTenantHsmInstancesRequest, + callback: PaginationCallback< + protos.google.cloud.kms.v1.IListSingleTenantHsmInstancesRequest, + | protos.google.cloud.kms.v1.IListSingleTenantHsmInstancesResponse + | null + | undefined, + protos.google.cloud.kms.v1.ISingleTenantHsmInstance + >, + ): void; listSingleTenantHsmInstances( - request?: protos.google.cloud.kms.v1.IListSingleTenantHsmInstancesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.kms.v1.IListSingleTenantHsmInstancesRequest, - protos.google.cloud.kms.v1.IListSingleTenantHsmInstancesResponse|null|undefined, - protos.google.cloud.kms.v1.ISingleTenantHsmInstance>, - callback?: PaginationCallback< + request?: protos.google.cloud.kms.v1.IListSingleTenantHsmInstancesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.kms.v1.IListSingleTenantHsmInstancesRequest, - protos.google.cloud.kms.v1.IListSingleTenantHsmInstancesResponse|null|undefined, - protos.google.cloud.kms.v1.ISingleTenantHsmInstance>): - Promise<[ - protos.google.cloud.kms.v1.ISingleTenantHsmInstance[], - protos.google.cloud.kms.v1.IListSingleTenantHsmInstancesRequest|null, - protos.google.cloud.kms.v1.IListSingleTenantHsmInstancesResponse - ]>|void { + | protos.google.cloud.kms.v1.IListSingleTenantHsmInstancesResponse + | null + | undefined, + protos.google.cloud.kms.v1.ISingleTenantHsmInstance + >, + callback?: PaginationCallback< + protos.google.cloud.kms.v1.IListSingleTenantHsmInstancesRequest, + | protos.google.cloud.kms.v1.IListSingleTenantHsmInstancesResponse + | null + | undefined, + protos.google.cloud.kms.v1.ISingleTenantHsmInstance + >, + ): Promise< + [ + protos.google.cloud.kms.v1.ISingleTenantHsmInstance[], + protos.google.cloud.kms.v1.IListSingleTenantHsmInstancesRequest | null, + protos.google.cloud.kms.v1.IListSingleTenantHsmInstancesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-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.kms.v1.IListSingleTenantHsmInstancesRequest, - protos.google.cloud.kms.v1.IListSingleTenantHsmInstancesResponse|null|undefined, - protos.google.cloud.kms.v1.ISingleTenantHsmInstance>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.kms.v1.IListSingleTenantHsmInstancesRequest, + | protos.google.cloud.kms.v1.IListSingleTenantHsmInstancesResponse + | null + | undefined, + protos.google.cloud.kms.v1.ISingleTenantHsmInstance + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listSingleTenantHsmInstances values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1317,460 +1929,501 @@ export class HsmManagementClient { this._log.info('listSingleTenantHsmInstances request %j', request); return this.innerApiCalls .listSingleTenantHsmInstances(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.kms.v1.ISingleTenantHsmInstance[], - protos.google.cloud.kms.v1.IListSingleTenantHsmInstancesRequest|null, - protos.google.cloud.kms.v1.IListSingleTenantHsmInstancesResponse - ]) => { - this._log.info('listSingleTenantHsmInstances values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.kms.v1.ISingleTenantHsmInstance[], + protos.google.cloud.kms.v1.IListSingleTenantHsmInstancesRequest | null, + protos.google.cloud.kms.v1.IListSingleTenantHsmInstancesResponse, + ]) => { + this._log.info('listSingleTenantHsmInstances values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listSingleTenantHsmInstances`, 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 location associated with the - * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstance|SingleTenantHsmInstances} to - * list, in the format `projects/* /locations/*`. - * @param {number} [request.pageSize] - * Optional. Optional limit on the number of - * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstance|SingleTenantHsmInstances} to - * include in the response. Further - * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstance|SingleTenantHsmInstances} can - * subsequently be - * obtained by including the - * {@link protos.google.cloud.kms.v1.ListSingleTenantHsmInstancesResponse.next_page_token|ListSingleTenantHsmInstancesResponse.next_page_token} - * in a subsequent request. If unspecified, the server will pick an - * appropriate default. - * @param {string} [request.pageToken] - * Optional. Optional pagination token, returned earlier via - * {@link protos.google.cloud.kms.v1.ListSingleTenantHsmInstancesResponse.next_page_token|ListSingleTenantHsmInstancesResponse.next_page_token}. - * @param {string} [request.filter] - * Optional. Only include resources that match the filter in the response. For - * more information, see - * [Sorting and filtering list - * results](https://cloud.google.com/kms/docs/sorting-and-filtering). - * @param {string} [request.orderBy] - * Optional. Specify how the results should be sorted. If not specified, the - * results will be sorted in the default order. For more information, see - * [Sorting and filtering list - * results](https://cloud.google.com/kms/docs/sorting-and-filtering). - * @param {boolean} [request.showDeleted] - * Optional. If set to true, - * {@link protos.google.cloud.kms.v1.HsmManagement.ListSingleTenantHsmInstances|HsmManagement.ListSingleTenantHsmInstances} - * will also return - * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstance|SingleTenantHsmInstances} in - * DELETED state. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.kms.v1.SingleTenantHsmInstance|SingleTenantHsmInstance} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listSingleTenantHsmInstancesAsync()` - * method described below for async iteration which you can stop as 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 `listSingleTenantHsmInstances`, 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 location associated with the + * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstance|SingleTenantHsmInstances} to + * list, in the format `projects/* /locations/*`. + * @param {number} [request.pageSize] + * Optional. Optional limit on the number of + * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstance|SingleTenantHsmInstances} to + * include in the response. Further + * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstance|SingleTenantHsmInstances} can + * subsequently be + * obtained by including the + * {@link protos.google.cloud.kms.v1.ListSingleTenantHsmInstancesResponse.next_page_token|ListSingleTenantHsmInstancesResponse.next_page_token} + * in a subsequent request. If unspecified, the server will pick an + * appropriate default. + * @param {string} [request.pageToken] + * Optional. Optional pagination token, returned earlier via + * {@link protos.google.cloud.kms.v1.ListSingleTenantHsmInstancesResponse.next_page_token|ListSingleTenantHsmInstancesResponse.next_page_token}. + * @param {string} [request.filter] + * Optional. Only include resources that match the filter in the response. For + * more information, see + * [Sorting and filtering list + * results](https://cloud.google.com/kms/docs/sorting-and-filtering). + * @param {string} [request.orderBy] + * Optional. Specify how the results should be sorted. If not specified, the + * results will be sorted in the default order. For more information, see + * [Sorting and filtering list + * results](https://cloud.google.com/kms/docs/sorting-and-filtering). + * @param {boolean} [request.showDeleted] + * Optional. If set to true, + * {@link protos.google.cloud.kms.v1.HsmManagement.ListSingleTenantHsmInstances|HsmManagement.ListSingleTenantHsmInstances} + * will also return + * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstance|SingleTenantHsmInstances} in + * DELETED state. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.kms.v1.SingleTenantHsmInstance|SingleTenantHsmInstance} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listSingleTenantHsmInstancesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listSingleTenantHsmInstancesStream( - request?: protos.google.cloud.kms.v1.IListSingleTenantHsmInstancesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.kms.v1.IListSingleTenantHsmInstancesRequest, + 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['listSingleTenantHsmInstances']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listSingleTenantHsmInstances stream %j', request); return this.descriptors.page.listSingleTenantHsmInstances.createStream( this.innerApiCalls.listSingleTenantHsmInstances as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listSingleTenantHsmInstances`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used 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 location associated with the - * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstance|SingleTenantHsmInstances} to - * list, in the format `projects/* /locations/*`. - * @param {number} [request.pageSize] - * Optional. Optional limit on the number of - * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstance|SingleTenantHsmInstances} to - * include in the response. Further - * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstance|SingleTenantHsmInstances} can - * subsequently be - * obtained by including the - * {@link protos.google.cloud.kms.v1.ListSingleTenantHsmInstancesResponse.next_page_token|ListSingleTenantHsmInstancesResponse.next_page_token} - * in a subsequent request. If unspecified, the server will pick an - * appropriate default. - * @param {string} [request.pageToken] - * Optional. Optional pagination token, returned earlier via - * {@link protos.google.cloud.kms.v1.ListSingleTenantHsmInstancesResponse.next_page_token|ListSingleTenantHsmInstancesResponse.next_page_token}. - * @param {string} [request.filter] - * Optional. Only include resources that match the filter in the response. For - * more information, see - * [Sorting and filtering list - * results](https://cloud.google.com/kms/docs/sorting-and-filtering). - * @param {string} [request.orderBy] - * Optional. Specify how the results should be sorted. If not specified, the - * results will be sorted in the default order. For more information, see - * [Sorting and filtering list - * results](https://cloud.google.com/kms/docs/sorting-and-filtering). - * @param {boolean} [request.showDeleted] - * Optional. If set to true, - * {@link protos.google.cloud.kms.v1.HsmManagement.ListSingleTenantHsmInstances|HsmManagement.ListSingleTenantHsmInstances} - * will also return - * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstance|SingleTenantHsmInstances} in - * DELETED state. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstance|SingleTenantHsmInstance}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@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/hsm_management.list_single_tenant_hsm_instances.js - * region_tag:cloudkms_v1_generated_HsmManagement_ListSingleTenantHsmInstances_async - */ + /** + * Equivalent to `listSingleTenantHsmInstances`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used 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 location associated with the + * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstance|SingleTenantHsmInstances} to + * list, in the format `projects/* /locations/*`. + * @param {number} [request.pageSize] + * Optional. Optional limit on the number of + * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstance|SingleTenantHsmInstances} to + * include in the response. Further + * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstance|SingleTenantHsmInstances} can + * subsequently be + * obtained by including the + * {@link protos.google.cloud.kms.v1.ListSingleTenantHsmInstancesResponse.next_page_token|ListSingleTenantHsmInstancesResponse.next_page_token} + * in a subsequent request. If unspecified, the server will pick an + * appropriate default. + * @param {string} [request.pageToken] + * Optional. Optional pagination token, returned earlier via + * {@link protos.google.cloud.kms.v1.ListSingleTenantHsmInstancesResponse.next_page_token|ListSingleTenantHsmInstancesResponse.next_page_token}. + * @param {string} [request.filter] + * Optional. Only include resources that match the filter in the response. For + * more information, see + * [Sorting and filtering list + * results](https://cloud.google.com/kms/docs/sorting-and-filtering). + * @param {string} [request.orderBy] + * Optional. Specify how the results should be sorted. If not specified, the + * results will be sorted in the default order. For more information, see + * [Sorting and filtering list + * results](https://cloud.google.com/kms/docs/sorting-and-filtering). + * @param {boolean} [request.showDeleted] + * Optional. If set to true, + * {@link protos.google.cloud.kms.v1.HsmManagement.ListSingleTenantHsmInstances|HsmManagement.ListSingleTenantHsmInstances} + * will also return + * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstance|SingleTenantHsmInstances} in + * DELETED state. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstance|SingleTenantHsmInstance}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@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/hsm_management.list_single_tenant_hsm_instances.js + * region_tag:cloudkms_v1_generated_HsmManagement_ListSingleTenantHsmInstances_async + */ listSingleTenantHsmInstancesAsync( - request?: protos.google.cloud.kms.v1.IListSingleTenantHsmInstancesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.kms.v1.IListSingleTenantHsmInstancesRequest, + 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['listSingleTenantHsmInstances']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listSingleTenantHsmInstances iterate %j', request); return this.descriptors.page.listSingleTenantHsmInstances.asyncIterate( this.innerApiCalls['listSingleTenantHsmInstances'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists - * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal|SingleTenantHsmInstanceProposals}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the single tenant HSM instance associated - * with the - * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal|SingleTenantHsmInstanceProposals} - * to list, in the format `projects/* /locations/* /singleTenantHsmInstances/*`. - * @param {number} [request.pageSize] - * Optional. Optional limit on the number of - * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal|SingleTenantHsmInstanceProposals} - * to include in the response. Further - * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal|SingleTenantHsmInstanceProposals} - * can subsequently be obtained by including the - * {@link protos.google.cloud.kms.v1.ListSingleTenantHsmInstanceProposalsResponse.next_page_token|ListSingleTenantHsmInstanceProposalsResponse.next_page_token} - * in a subsequent request. If unspecified, the server will pick an - * appropriate default. - * @param {string} [request.pageToken] - * Optional. Optional pagination token, returned earlier via - * {@link protos.google.cloud.kms.v1.ListSingleTenantHsmInstanceProposalsResponse.next_page_token|ListSingleTenantHsmInstanceProposalsResponse.next_page_token}. - * @param {string} [request.filter] - * Optional. Only include resources that match the filter in the response. For - * more information, see - * [Sorting and filtering list - * results](https://cloud.google.com/kms/docs/sorting-and-filtering). - * @param {string} [request.orderBy] - * Optional. Specify how the results should be sorted. If not specified, the - * results will be sorted in the default order. For more information, see - * [Sorting and filtering list - * results](https://cloud.google.com/kms/docs/sorting-and-filtering). - * @param {boolean} [request.showDeleted] - * Optional. If set to true, - * {@link protos.google.cloud.kms.v1.HsmManagement.ListSingleTenantHsmInstanceProposals|HsmManagement.ListSingleTenantHsmInstanceProposals} - * will also return - * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal|SingleTenantHsmInstanceProposals} - * in DELETED state. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal|SingleTenantHsmInstanceProposal}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listSingleTenantHsmInstanceProposalsAsync()` - * method described below for async iteration which you can stop as 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 + * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal|SingleTenantHsmInstanceProposals}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the single tenant HSM instance associated + * with the + * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal|SingleTenantHsmInstanceProposals} + * to list, in the format `projects/* /locations/* /singleTenantHsmInstances/*`. + * @param {number} [request.pageSize] + * Optional. Optional limit on the number of + * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal|SingleTenantHsmInstanceProposals} + * to include in the response. Further + * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal|SingleTenantHsmInstanceProposals} + * can subsequently be obtained by including the + * {@link protos.google.cloud.kms.v1.ListSingleTenantHsmInstanceProposalsResponse.next_page_token|ListSingleTenantHsmInstanceProposalsResponse.next_page_token} + * in a subsequent request. If unspecified, the server will pick an + * appropriate default. + * @param {string} [request.pageToken] + * Optional. Optional pagination token, returned earlier via + * {@link protos.google.cloud.kms.v1.ListSingleTenantHsmInstanceProposalsResponse.next_page_token|ListSingleTenantHsmInstanceProposalsResponse.next_page_token}. + * @param {string} [request.filter] + * Optional. Only include resources that match the filter in the response. For + * more information, see + * [Sorting and filtering list + * results](https://cloud.google.com/kms/docs/sorting-and-filtering). + * @param {string} [request.orderBy] + * Optional. Specify how the results should be sorted. If not specified, the + * results will be sorted in the default order. For more information, see + * [Sorting and filtering list + * results](https://cloud.google.com/kms/docs/sorting-and-filtering). + * @param {boolean} [request.showDeleted] + * Optional. If set to true, + * {@link protos.google.cloud.kms.v1.HsmManagement.ListSingleTenantHsmInstanceProposals|HsmManagement.ListSingleTenantHsmInstanceProposals} + * will also return + * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal|SingleTenantHsmInstanceProposals} + * in DELETED state. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal|SingleTenantHsmInstanceProposal}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listSingleTenantHsmInstanceProposalsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listSingleTenantHsmInstanceProposals( - request?: protos.google.cloud.kms.v1.IListSingleTenantHsmInstanceProposalsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.kms.v1.ISingleTenantHsmInstanceProposal[], - protos.google.cloud.kms.v1.IListSingleTenantHsmInstanceProposalsRequest|null, - protos.google.cloud.kms.v1.IListSingleTenantHsmInstanceProposalsResponse - ]>; + request?: protos.google.cloud.kms.v1.IListSingleTenantHsmInstanceProposalsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.kms.v1.ISingleTenantHsmInstanceProposal[], + protos.google.cloud.kms.v1.IListSingleTenantHsmInstanceProposalsRequest | null, + protos.google.cloud.kms.v1.IListSingleTenantHsmInstanceProposalsResponse, + ] + >; listSingleTenantHsmInstanceProposals( - request: protos.google.cloud.kms.v1.IListSingleTenantHsmInstanceProposalsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.kms.v1.IListSingleTenantHsmInstanceProposalsRequest, - protos.google.cloud.kms.v1.IListSingleTenantHsmInstanceProposalsResponse|null|undefined, - protos.google.cloud.kms.v1.ISingleTenantHsmInstanceProposal>): void; + request: protos.google.cloud.kms.v1.IListSingleTenantHsmInstanceProposalsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.kms.v1.IListSingleTenantHsmInstanceProposalsRequest, + | protos.google.cloud.kms.v1.IListSingleTenantHsmInstanceProposalsResponse + | null + | undefined, + protos.google.cloud.kms.v1.ISingleTenantHsmInstanceProposal + >, + ): void; listSingleTenantHsmInstanceProposals( - request: protos.google.cloud.kms.v1.IListSingleTenantHsmInstanceProposalsRequest, - callback: PaginationCallback< - protos.google.cloud.kms.v1.IListSingleTenantHsmInstanceProposalsRequest, - protos.google.cloud.kms.v1.IListSingleTenantHsmInstanceProposalsResponse|null|undefined, - protos.google.cloud.kms.v1.ISingleTenantHsmInstanceProposal>): void; + request: protos.google.cloud.kms.v1.IListSingleTenantHsmInstanceProposalsRequest, + callback: PaginationCallback< + protos.google.cloud.kms.v1.IListSingleTenantHsmInstanceProposalsRequest, + | protos.google.cloud.kms.v1.IListSingleTenantHsmInstanceProposalsResponse + | null + | undefined, + protos.google.cloud.kms.v1.ISingleTenantHsmInstanceProposal + >, + ): void; listSingleTenantHsmInstanceProposals( - request?: protos.google.cloud.kms.v1.IListSingleTenantHsmInstanceProposalsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.kms.v1.IListSingleTenantHsmInstanceProposalsRequest, - protos.google.cloud.kms.v1.IListSingleTenantHsmInstanceProposalsResponse|null|undefined, - protos.google.cloud.kms.v1.ISingleTenantHsmInstanceProposal>, - callback?: PaginationCallback< + request?: protos.google.cloud.kms.v1.IListSingleTenantHsmInstanceProposalsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.kms.v1.IListSingleTenantHsmInstanceProposalsRequest, - protos.google.cloud.kms.v1.IListSingleTenantHsmInstanceProposalsResponse|null|undefined, - protos.google.cloud.kms.v1.ISingleTenantHsmInstanceProposal>): - Promise<[ - protos.google.cloud.kms.v1.ISingleTenantHsmInstanceProposal[], - protos.google.cloud.kms.v1.IListSingleTenantHsmInstanceProposalsRequest|null, - protos.google.cloud.kms.v1.IListSingleTenantHsmInstanceProposalsResponse - ]>|void { + | protos.google.cloud.kms.v1.IListSingleTenantHsmInstanceProposalsResponse + | null + | undefined, + protos.google.cloud.kms.v1.ISingleTenantHsmInstanceProposal + >, + callback?: PaginationCallback< + protos.google.cloud.kms.v1.IListSingleTenantHsmInstanceProposalsRequest, + | protos.google.cloud.kms.v1.IListSingleTenantHsmInstanceProposalsResponse + | null + | undefined, + protos.google.cloud.kms.v1.ISingleTenantHsmInstanceProposal + >, + ): Promise< + [ + protos.google.cloud.kms.v1.ISingleTenantHsmInstanceProposal[], + protos.google.cloud.kms.v1.IListSingleTenantHsmInstanceProposalsRequest | null, + protos.google.cloud.kms.v1.IListSingleTenantHsmInstanceProposalsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-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.kms.v1.IListSingleTenantHsmInstanceProposalsRequest, - protos.google.cloud.kms.v1.IListSingleTenantHsmInstanceProposalsResponse|null|undefined, - protos.google.cloud.kms.v1.ISingleTenantHsmInstanceProposal>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.kms.v1.IListSingleTenantHsmInstanceProposalsRequest, + | protos.google.cloud.kms.v1.IListSingleTenantHsmInstanceProposalsResponse + | null + | undefined, + protos.google.cloud.kms.v1.ISingleTenantHsmInstanceProposal + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { - this._log.info('listSingleTenantHsmInstanceProposals values %j', values); + this._log.info( + 'listSingleTenantHsmInstanceProposals values %j', + values, + ); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. } : undefined; this._log.info('listSingleTenantHsmInstanceProposals request %j', request); return this.innerApiCalls .listSingleTenantHsmInstanceProposals(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.kms.v1.ISingleTenantHsmInstanceProposal[], - protos.google.cloud.kms.v1.IListSingleTenantHsmInstanceProposalsRequest|null, - protos.google.cloud.kms.v1.IListSingleTenantHsmInstanceProposalsResponse - ]) => { - this._log.info('listSingleTenantHsmInstanceProposals values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.kms.v1.ISingleTenantHsmInstanceProposal[], + protos.google.cloud.kms.v1.IListSingleTenantHsmInstanceProposalsRequest | null, + protos.google.cloud.kms.v1.IListSingleTenantHsmInstanceProposalsResponse, + ]) => { + this._log.info( + 'listSingleTenantHsmInstanceProposals values %j', + response, + ); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listSingleTenantHsmInstanceProposals`, 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 single tenant HSM instance associated - * with the - * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal|SingleTenantHsmInstanceProposals} - * to list, in the format `projects/* /locations/* /singleTenantHsmInstances/*`. - * @param {number} [request.pageSize] - * Optional. Optional limit on the number of - * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal|SingleTenantHsmInstanceProposals} - * to include in the response. Further - * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal|SingleTenantHsmInstanceProposals} - * can subsequently be obtained by including the - * {@link protos.google.cloud.kms.v1.ListSingleTenantHsmInstanceProposalsResponse.next_page_token|ListSingleTenantHsmInstanceProposalsResponse.next_page_token} - * in a subsequent request. If unspecified, the server will pick an - * appropriate default. - * @param {string} [request.pageToken] - * Optional. Optional pagination token, returned earlier via - * {@link protos.google.cloud.kms.v1.ListSingleTenantHsmInstanceProposalsResponse.next_page_token|ListSingleTenantHsmInstanceProposalsResponse.next_page_token}. - * @param {string} [request.filter] - * Optional. Only include resources that match the filter in the response. For - * more information, see - * [Sorting and filtering list - * results](https://cloud.google.com/kms/docs/sorting-and-filtering). - * @param {string} [request.orderBy] - * Optional. Specify how the results should be sorted. If not specified, the - * results will be sorted in the default order. For more information, see - * [Sorting and filtering list - * results](https://cloud.google.com/kms/docs/sorting-and-filtering). - * @param {boolean} [request.showDeleted] - * Optional. If set to true, - * {@link protos.google.cloud.kms.v1.HsmManagement.ListSingleTenantHsmInstanceProposals|HsmManagement.ListSingleTenantHsmInstanceProposals} - * will also return - * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal|SingleTenantHsmInstanceProposals} - * in DELETED state. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal|SingleTenantHsmInstanceProposal} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listSingleTenantHsmInstanceProposalsAsync()` - * method described below for async iteration which you can stop as 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 `listSingleTenantHsmInstanceProposals`, 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 single tenant HSM instance associated + * with the + * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal|SingleTenantHsmInstanceProposals} + * to list, in the format `projects/* /locations/* /singleTenantHsmInstances/*`. + * @param {number} [request.pageSize] + * Optional. Optional limit on the number of + * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal|SingleTenantHsmInstanceProposals} + * to include in the response. Further + * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal|SingleTenantHsmInstanceProposals} + * can subsequently be obtained by including the + * {@link protos.google.cloud.kms.v1.ListSingleTenantHsmInstanceProposalsResponse.next_page_token|ListSingleTenantHsmInstanceProposalsResponse.next_page_token} + * in a subsequent request. If unspecified, the server will pick an + * appropriate default. + * @param {string} [request.pageToken] + * Optional. Optional pagination token, returned earlier via + * {@link protos.google.cloud.kms.v1.ListSingleTenantHsmInstanceProposalsResponse.next_page_token|ListSingleTenantHsmInstanceProposalsResponse.next_page_token}. + * @param {string} [request.filter] + * Optional. Only include resources that match the filter in the response. For + * more information, see + * [Sorting and filtering list + * results](https://cloud.google.com/kms/docs/sorting-and-filtering). + * @param {string} [request.orderBy] + * Optional. Specify how the results should be sorted. If not specified, the + * results will be sorted in the default order. For more information, see + * [Sorting and filtering list + * results](https://cloud.google.com/kms/docs/sorting-and-filtering). + * @param {boolean} [request.showDeleted] + * Optional. If set to true, + * {@link protos.google.cloud.kms.v1.HsmManagement.ListSingleTenantHsmInstanceProposals|HsmManagement.ListSingleTenantHsmInstanceProposals} + * will also return + * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal|SingleTenantHsmInstanceProposals} + * in DELETED state. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal|SingleTenantHsmInstanceProposal} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listSingleTenantHsmInstanceProposalsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listSingleTenantHsmInstanceProposalsStream( - request?: protos.google.cloud.kms.v1.IListSingleTenantHsmInstanceProposalsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.kms.v1.IListSingleTenantHsmInstanceProposalsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listSingleTenantHsmInstanceProposals']; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = + this._defaults['listSingleTenantHsmInstanceProposals']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listSingleTenantHsmInstanceProposals stream %j', request); return this.descriptors.page.listSingleTenantHsmInstanceProposals.createStream( this.innerApiCalls.listSingleTenantHsmInstanceProposals as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listSingleTenantHsmInstanceProposals`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used 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 single tenant HSM instance associated - * with the - * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal|SingleTenantHsmInstanceProposals} - * to list, in the format `projects/* /locations/* /singleTenantHsmInstances/*`. - * @param {number} [request.pageSize] - * Optional. Optional limit on the number of - * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal|SingleTenantHsmInstanceProposals} - * to include in the response. Further - * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal|SingleTenantHsmInstanceProposals} - * can subsequently be obtained by including the - * {@link protos.google.cloud.kms.v1.ListSingleTenantHsmInstanceProposalsResponse.next_page_token|ListSingleTenantHsmInstanceProposalsResponse.next_page_token} - * in a subsequent request. If unspecified, the server will pick an - * appropriate default. - * @param {string} [request.pageToken] - * Optional. Optional pagination token, returned earlier via - * {@link protos.google.cloud.kms.v1.ListSingleTenantHsmInstanceProposalsResponse.next_page_token|ListSingleTenantHsmInstanceProposalsResponse.next_page_token}. - * @param {string} [request.filter] - * Optional. Only include resources that match the filter in the response. For - * more information, see - * [Sorting and filtering list - * results](https://cloud.google.com/kms/docs/sorting-and-filtering). - * @param {string} [request.orderBy] - * Optional. Specify how the results should be sorted. If not specified, the - * results will be sorted in the default order. For more information, see - * [Sorting and filtering list - * results](https://cloud.google.com/kms/docs/sorting-and-filtering). - * @param {boolean} [request.showDeleted] - * Optional. If set to true, - * {@link protos.google.cloud.kms.v1.HsmManagement.ListSingleTenantHsmInstanceProposals|HsmManagement.ListSingleTenantHsmInstanceProposals} - * will also return - * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal|SingleTenantHsmInstanceProposals} - * in DELETED state. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal|SingleTenantHsmInstanceProposal}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@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/hsm_management.list_single_tenant_hsm_instance_proposals.js - * region_tag:cloudkms_v1_generated_HsmManagement_ListSingleTenantHsmInstanceProposals_async - */ + /** + * Equivalent to `listSingleTenantHsmInstanceProposals`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used 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 single tenant HSM instance associated + * with the + * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal|SingleTenantHsmInstanceProposals} + * to list, in the format `projects/* /locations/* /singleTenantHsmInstances/*`. + * @param {number} [request.pageSize] + * Optional. Optional limit on the number of + * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal|SingleTenantHsmInstanceProposals} + * to include in the response. Further + * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal|SingleTenantHsmInstanceProposals} + * can subsequently be obtained by including the + * {@link protos.google.cloud.kms.v1.ListSingleTenantHsmInstanceProposalsResponse.next_page_token|ListSingleTenantHsmInstanceProposalsResponse.next_page_token} + * in a subsequent request. If unspecified, the server will pick an + * appropriate default. + * @param {string} [request.pageToken] + * Optional. Optional pagination token, returned earlier via + * {@link protos.google.cloud.kms.v1.ListSingleTenantHsmInstanceProposalsResponse.next_page_token|ListSingleTenantHsmInstanceProposalsResponse.next_page_token}. + * @param {string} [request.filter] + * Optional. Only include resources that match the filter in the response. For + * more information, see + * [Sorting and filtering list + * results](https://cloud.google.com/kms/docs/sorting-and-filtering). + * @param {string} [request.orderBy] + * Optional. Specify how the results should be sorted. If not specified, the + * results will be sorted in the default order. For more information, see + * [Sorting and filtering list + * results](https://cloud.google.com/kms/docs/sorting-and-filtering). + * @param {boolean} [request.showDeleted] + * Optional. If set to true, + * {@link protos.google.cloud.kms.v1.HsmManagement.ListSingleTenantHsmInstanceProposals|HsmManagement.ListSingleTenantHsmInstanceProposals} + * will also return + * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal|SingleTenantHsmInstanceProposals} + * in DELETED state. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal|SingleTenantHsmInstanceProposal}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@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/hsm_management.list_single_tenant_hsm_instance_proposals.js + * region_tag:cloudkms_v1_generated_HsmManagement_ListSingleTenantHsmInstanceProposals_async + */ listSingleTenantHsmInstanceProposalsAsync( - request?: protos.google.cloud.kms.v1.IListSingleTenantHsmInstanceProposalsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.kms.v1.IListSingleTenantHsmInstanceProposalsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); - const defaultCallSettings = this._defaults['listSingleTenantHsmInstanceProposals']; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + const defaultCallSettings = + this._defaults['listSingleTenantHsmInstanceProposals']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listSingleTenantHsmInstanceProposals iterate %j', request); return this.descriptors.page.listSingleTenantHsmInstanceProposals.asyncIterate( this.innerApiCalls['listSingleTenantHsmInstanceProposals'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** - * Gets the access control policy for a resource. Returns an empty policy - * if the resource exists and does not have a policy set. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {Object} [request.options] - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. This field is only used by Cloud IAM. - * - * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Gets the access control policy for a resource. Returns an empty policy + * if the resource exists and does not have a policy set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {Object} [request.options] + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. This field is only used by Cloud IAM. + * + * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ getIamPolicy( request: IamProtos.google.iam.v1.GetIamPolicyRequest, options?: @@ -1784,40 +2437,40 @@ export class HsmManagementClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.getIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ setIamPolicy( request: IamProtos.google.iam.v1.SetIamPolicyRequest, options?: @@ -1831,41 +2484,41 @@ export class HsmManagementClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.setIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + */ testIamPermissions( request: IamProtos.google.iam.v1.TestIamPermissionsRequest, options?: @@ -1879,12 +2532,12 @@ export class HsmManagementClient { IamProtos.google.iam.v1.TestIamPermissionsResponse, IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { + >, + ): Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { return this.iamClient.testIamPermissions(request, options, callback); } -/** + /** * Gets information about a location. * * @param {Object} request @@ -1919,12 +2572,11 @@ export class HsmManagementClient { | 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. @@ -1957,12 +2609,12 @@ export class HsmManagementClient { */ 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. @@ -2005,22 +2657,22 @@ export class HsmManagementClient { 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); } /** @@ -2055,15 +2707,15 @@ export class HsmManagementClient { */ 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); } /** @@ -2097,7 +2749,7 @@ export class HsmManagementClient { * await client.cancelOperation({name: ''}); * ``` */ - cancelOperation( + cancelOperation( request: protos.google.longrunning.CancelOperationRequest, optionsOrCallback?: | gax.CallOptions @@ -2110,25 +2762,24 @@ export class HsmManagementClient { 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 @@ -2167,22 +2818,22 @@ export class HsmManagementClient { 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); } @@ -2199,7 +2850,12 @@ export class HsmManagementClient { * @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, @@ -2216,7 +2872,8 @@ export class HsmManagementClient { * @returns {string} A string representing the project. */ matchProjectFromCryptoKeyName(cryptoKeyName: string) { - return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName).project; + return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName) + .project; } /** @@ -2227,7 +2884,8 @@ export class HsmManagementClient { * @returns {string} A string representing the location. */ matchLocationFromCryptoKeyName(cryptoKeyName: string) { - return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName).location; + return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName) + .location; } /** @@ -2238,7 +2896,8 @@ export class HsmManagementClient { * @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; } /** @@ -2249,7 +2908,8 @@ export class HsmManagementClient { * @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; } /** @@ -2262,7 +2922,13 @@ export class HsmManagementClient { * @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, @@ -2280,7 +2946,9 @@ export class HsmManagementClient { * @returns {string} A string representing the project. */ matchProjectFromCryptoKeyVersionName(cryptoKeyVersionName: string) { - return this.pathTemplates.cryptoKeyVersionPathTemplate.match(cryptoKeyVersionName).project; + return this.pathTemplates.cryptoKeyVersionPathTemplate.match( + cryptoKeyVersionName, + ).project; } /** @@ -2291,7 +2959,9 @@ export class HsmManagementClient { * @returns {string} A string representing the location. */ matchLocationFromCryptoKeyVersionName(cryptoKeyVersionName: string) { - return this.pathTemplates.cryptoKeyVersionPathTemplate.match(cryptoKeyVersionName).location; + return this.pathTemplates.cryptoKeyVersionPathTemplate.match( + cryptoKeyVersionName, + ).location; } /** @@ -2302,7 +2972,9 @@ export class HsmManagementClient { * @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; } /** @@ -2313,7 +2985,9 @@ export class HsmManagementClient { * @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; } /** @@ -2324,7 +2998,9 @@ export class HsmManagementClient { * @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; } /** @@ -2334,7 +3010,7 @@ export class HsmManagementClient { * @param {string} location * @returns {string} Resource name string. */ - ekmConfigPath(project:string,location:string) { + ekmConfigPath(project: string, location: string) { return this.pathTemplates.ekmConfigPathTemplate.render({ project: project, location: location, @@ -2349,7 +3025,8 @@ export class HsmManagementClient { * @returns {string} A string representing the project. */ matchProjectFromEkmConfigName(ekmConfigName: string) { - return this.pathTemplates.ekmConfigPathTemplate.match(ekmConfigName).project; + return this.pathTemplates.ekmConfigPathTemplate.match(ekmConfigName) + .project; } /** @@ -2360,7 +3037,8 @@ export class HsmManagementClient { * @returns {string} A string representing the location. */ matchLocationFromEkmConfigName(ekmConfigName: string) { - return this.pathTemplates.ekmConfigPathTemplate.match(ekmConfigName).location; + return this.pathTemplates.ekmConfigPathTemplate.match(ekmConfigName) + .location; } /** @@ -2371,7 +3049,7 @@ export class HsmManagementClient { * @param {string} ekm_connection * @returns {string} Resource name string. */ - ekmConnectionPath(project:string,location:string,ekmConnection:string) { + ekmConnectionPath(project: string, location: string, ekmConnection: string) { return this.pathTemplates.ekmConnectionPathTemplate.render({ project: project, location: location, @@ -2387,7 +3065,8 @@ export class HsmManagementClient { * @returns {string} A string representing the project. */ matchProjectFromEkmConnectionName(ekmConnectionName: string) { - return this.pathTemplates.ekmConnectionPathTemplate.match(ekmConnectionName).project; + return this.pathTemplates.ekmConnectionPathTemplate.match(ekmConnectionName) + .project; } /** @@ -2398,7 +3077,8 @@ export class HsmManagementClient { * @returns {string} A string representing the location. */ matchLocationFromEkmConnectionName(ekmConnectionName: string) { - return this.pathTemplates.ekmConnectionPathTemplate.match(ekmConnectionName).location; + return this.pathTemplates.ekmConnectionPathTemplate.match(ekmConnectionName) + .location; } /** @@ -2409,7 +3089,8 @@ export class HsmManagementClient { * @returns {string} A string representing the ekm_connection. */ matchEkmConnectionFromEkmConnectionName(ekmConnectionName: string) { - return this.pathTemplates.ekmConnectionPathTemplate.match(ekmConnectionName).ekm_connection; + return this.pathTemplates.ekmConnectionPathTemplate.match(ekmConnectionName) + .ekm_connection; } /** @@ -2418,7 +3099,7 @@ export class HsmManagementClient { * @param {string} folder * @returns {string} Resource name string. */ - folderAutokeyConfigPath(folder:string) { + folderAutokeyConfigPath(folder: string) { return this.pathTemplates.folderAutokeyConfigPathTemplate.render({ folder: folder, }); @@ -2432,7 +3113,9 @@ export class HsmManagementClient { * @returns {string} A string representing the folder. */ matchFolderFromFolderAutokeyConfigName(folderAutokeyConfigName: string) { - return this.pathTemplates.folderAutokeyConfigPathTemplate.match(folderAutokeyConfigName).folder; + return this.pathTemplates.folderAutokeyConfigPathTemplate.match( + folderAutokeyConfigName, + ).folder; } /** @@ -2444,7 +3127,12 @@ export class HsmManagementClient { * @param {string} import_job * @returns {string} Resource name string. */ - importJobPath(project:string,location:string,keyRing:string,importJob:string) { + importJobPath( + project: string, + location: string, + keyRing: string, + importJob: string, + ) { return this.pathTemplates.importJobPathTemplate.render({ project: project, location: location, @@ -2461,7 +3149,8 @@ export class HsmManagementClient { * @returns {string} A string representing the project. */ matchProjectFromImportJobName(importJobName: string) { - return this.pathTemplates.importJobPathTemplate.match(importJobName).project; + return this.pathTemplates.importJobPathTemplate.match(importJobName) + .project; } /** @@ -2472,7 +3161,8 @@ export class HsmManagementClient { * @returns {string} A string representing the location. */ matchLocationFromImportJobName(importJobName: string) { - return this.pathTemplates.importJobPathTemplate.match(importJobName).location; + return this.pathTemplates.importJobPathTemplate.match(importJobName) + .location; } /** @@ -2483,7 +3173,8 @@ export class HsmManagementClient { * @returns {string} A string representing the key_ring. */ matchKeyRingFromImportJobName(importJobName: string) { - return this.pathTemplates.importJobPathTemplate.match(importJobName).key_ring; + return this.pathTemplates.importJobPathTemplate.match(importJobName) + .key_ring; } /** @@ -2494,7 +3185,8 @@ export class HsmManagementClient { * @returns {string} A string representing the import_job. */ matchImportJobFromImportJobName(importJobName: string) { - return this.pathTemplates.importJobPathTemplate.match(importJobName).import_job; + return this.pathTemplates.importJobPathTemplate.match(importJobName) + .import_job; } /** @@ -2505,7 +3197,7 @@ export class HsmManagementClient { * @param {string} key_handle * @returns {string} Resource name string. */ - keyHandlePath(project:string,location:string,keyHandle:string) { + keyHandlePath(project: string, location: string, keyHandle: string) { return this.pathTemplates.keyHandlePathTemplate.render({ project: project, location: location, @@ -2521,7 +3213,8 @@ export class HsmManagementClient { * @returns {string} A string representing the project. */ matchProjectFromKeyHandleName(keyHandleName: string) { - return this.pathTemplates.keyHandlePathTemplate.match(keyHandleName).project; + return this.pathTemplates.keyHandlePathTemplate.match(keyHandleName) + .project; } /** @@ -2532,7 +3225,8 @@ export class HsmManagementClient { * @returns {string} A string representing the location. */ matchLocationFromKeyHandleName(keyHandleName: string) { - return this.pathTemplates.keyHandlePathTemplate.match(keyHandleName).location; + return this.pathTemplates.keyHandlePathTemplate.match(keyHandleName) + .location; } /** @@ -2543,7 +3237,8 @@ export class HsmManagementClient { * @returns {string} A string representing the key_handle. */ matchKeyHandleFromKeyHandleName(keyHandleName: string) { - return this.pathTemplates.keyHandlePathTemplate.match(keyHandleName).key_handle; + return this.pathTemplates.keyHandlePathTemplate.match(keyHandleName) + .key_handle; } /** @@ -2554,7 +3249,7 @@ export class HsmManagementClient { * @param {string} key_ring * @returns {string} Resource name string. */ - keyRingPath(project:string,location:string,keyRing:string) { + keyRingPath(project: string, location: string, keyRing: string) { return this.pathTemplates.keyRingPathTemplate.render({ project: project, location: location, @@ -2602,7 +3297,7 @@ export class HsmManagementClient { * @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 +3332,7 @@ export class HsmManagementClient { * @param {string} project * @returns {string} Resource name string. */ - projectAutokeyConfigPath(project:string) { + projectAutokeyConfigPath(project: string) { return this.pathTemplates.projectAutokeyConfigPathTemplate.render({ project: project, }); @@ -2651,7 +3346,9 @@ export class HsmManagementClient { * @returns {string} A string representing the project. */ matchProjectFromProjectAutokeyConfigName(projectAutokeyConfigName: string) { - return this.pathTemplates.projectAutokeyConfigPathTemplate.match(projectAutokeyConfigName).project; + return this.pathTemplates.projectAutokeyConfigPathTemplate.match( + projectAutokeyConfigName, + ).project; } /** @@ -2664,7 +3361,13 @@ export class HsmManagementClient { * @param {string} crypto_key_version * @returns {string} Resource name string. */ - publicKeyPath(project:string,location:string,keyRing:string,cryptoKey:string,cryptoKeyVersion:string) { + publicKeyPath( + project: string, + location: string, + keyRing: string, + cryptoKey: string, + cryptoKeyVersion: string, + ) { return this.pathTemplates.publicKeyPathTemplate.render({ project: project, location: location, @@ -2682,7 +3385,8 @@ export class HsmManagementClient { * @returns {string} A string representing the project. */ matchProjectFromPublicKeyName(publicKeyName: string) { - return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName).project; + return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName) + .project; } /** @@ -2693,7 +3397,8 @@ export class HsmManagementClient { * @returns {string} A string representing the location. */ matchLocationFromPublicKeyName(publicKeyName: string) { - return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName).location; + return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName) + .location; } /** @@ -2704,7 +3409,8 @@ export class HsmManagementClient { * @returns {string} A string representing the key_ring. */ matchKeyRingFromPublicKeyName(publicKeyName: string) { - return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName).key_ring; + return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName) + .key_ring; } /** @@ -2715,7 +3421,8 @@ export class HsmManagementClient { * @returns {string} A string representing the crypto_key. */ matchCryptoKeyFromPublicKeyName(publicKeyName: string) { - return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName).crypto_key; + return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName) + .crypto_key; } /** @@ -2726,7 +3433,8 @@ export class HsmManagementClient { * @returns {string} A string representing the crypto_key_version. */ matchCryptoKeyVersionFromPublicKeyName(publicKeyName: string) { - return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName).crypto_key_version; + return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName) + .crypto_key_version; } /** @@ -2737,7 +3445,11 @@ export class HsmManagementClient { * @param {string} retired_resource * @returns {string} Resource name string. */ - retiredResourcePath(project:string,location:string,retiredResource:string) { + retiredResourcePath( + project: string, + location: string, + retiredResource: string, + ) { return this.pathTemplates.retiredResourcePathTemplate.render({ project: project, location: location, @@ -2753,7 +3465,9 @@ export class HsmManagementClient { * @returns {string} A string representing the project. */ matchProjectFromRetiredResourceName(retiredResourceName: string) { - return this.pathTemplates.retiredResourcePathTemplate.match(retiredResourceName).project; + return this.pathTemplates.retiredResourcePathTemplate.match( + retiredResourceName, + ).project; } /** @@ -2764,7 +3478,9 @@ export class HsmManagementClient { * @returns {string} A string representing the location. */ matchLocationFromRetiredResourceName(retiredResourceName: string) { - return this.pathTemplates.retiredResourcePathTemplate.match(retiredResourceName).location; + return this.pathTemplates.retiredResourcePathTemplate.match( + retiredResourceName, + ).location; } /** @@ -2775,7 +3491,9 @@ export class HsmManagementClient { * @returns {string} A string representing the retired_resource. */ matchRetiredResourceFromRetiredResourceName(retiredResourceName: string) { - return this.pathTemplates.retiredResourcePathTemplate.match(retiredResourceName).retired_resource; + return this.pathTemplates.retiredResourcePathTemplate.match( + retiredResourceName, + ).retired_resource; } /** @@ -2786,7 +3504,11 @@ export class HsmManagementClient { * @param {string} single_tenant_hsm_instance * @returns {string} Resource name string. */ - singleTenantHsmInstancePath(project:string,location:string,singleTenantHsmInstance:string) { + singleTenantHsmInstancePath( + project: string, + location: string, + singleTenantHsmInstance: string, + ) { return this.pathTemplates.singleTenantHsmInstancePathTemplate.render({ project: project, location: location, @@ -2801,8 +3523,12 @@ export class HsmManagementClient { * A fully-qualified path representing SingleTenantHsmInstance resource. * @returns {string} A string representing the project. */ - matchProjectFromSingleTenantHsmInstanceName(singleTenantHsmInstanceName: string) { - return this.pathTemplates.singleTenantHsmInstancePathTemplate.match(singleTenantHsmInstanceName).project; + matchProjectFromSingleTenantHsmInstanceName( + singleTenantHsmInstanceName: string, + ) { + return this.pathTemplates.singleTenantHsmInstancePathTemplate.match( + singleTenantHsmInstanceName, + ).project; } /** @@ -2812,8 +3538,12 @@ export class HsmManagementClient { * A fully-qualified path representing SingleTenantHsmInstance resource. * @returns {string} A string representing the location. */ - matchLocationFromSingleTenantHsmInstanceName(singleTenantHsmInstanceName: string) { - return this.pathTemplates.singleTenantHsmInstancePathTemplate.match(singleTenantHsmInstanceName).location; + matchLocationFromSingleTenantHsmInstanceName( + singleTenantHsmInstanceName: string, + ) { + return this.pathTemplates.singleTenantHsmInstancePathTemplate.match( + singleTenantHsmInstanceName, + ).location; } /** @@ -2823,8 +3553,12 @@ export class HsmManagementClient { * A fully-qualified path representing SingleTenantHsmInstance resource. * @returns {string} A string representing the single_tenant_hsm_instance. */ - matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceName(singleTenantHsmInstanceName: string) { - return this.pathTemplates.singleTenantHsmInstancePathTemplate.match(singleTenantHsmInstanceName).single_tenant_hsm_instance; + matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceName( + singleTenantHsmInstanceName: string, + ) { + return this.pathTemplates.singleTenantHsmInstancePathTemplate.match( + singleTenantHsmInstanceName, + ).single_tenant_hsm_instance; } /** @@ -2836,13 +3570,20 @@ export class HsmManagementClient { * @param {string} proposal * @returns {string} Resource name string. */ - singleTenantHsmInstanceProposalPath(project:string,location:string,singleTenantHsmInstance:string,proposal:string) { - return this.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.render({ - project: project, - location: location, - single_tenant_hsm_instance: singleTenantHsmInstance, - proposal: proposal, - }); + singleTenantHsmInstanceProposalPath( + project: string, + location: string, + singleTenantHsmInstance: string, + proposal: string, + ) { + return this.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.render( + { + project: project, + location: location, + single_tenant_hsm_instance: singleTenantHsmInstance, + proposal: proposal, + }, + ); } /** @@ -2852,8 +3593,12 @@ export class HsmManagementClient { * A fully-qualified path representing SingleTenantHsmInstanceProposal resource. * @returns {string} A string representing the project. */ - matchProjectFromSingleTenantHsmInstanceProposalName(singleTenantHsmInstanceProposalName: string) { - return this.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match(singleTenantHsmInstanceProposalName).project; + matchProjectFromSingleTenantHsmInstanceProposalName( + singleTenantHsmInstanceProposalName: string, + ) { + return this.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match( + singleTenantHsmInstanceProposalName, + ).project; } /** @@ -2863,8 +3608,12 @@ export class HsmManagementClient { * A fully-qualified path representing SingleTenantHsmInstanceProposal resource. * @returns {string} A string representing the location. */ - matchLocationFromSingleTenantHsmInstanceProposalName(singleTenantHsmInstanceProposalName: string) { - return this.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match(singleTenantHsmInstanceProposalName).location; + matchLocationFromSingleTenantHsmInstanceProposalName( + singleTenantHsmInstanceProposalName: string, + ) { + return this.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match( + singleTenantHsmInstanceProposalName, + ).location; } /** @@ -2874,8 +3623,12 @@ export class HsmManagementClient { * A fully-qualified path representing SingleTenantHsmInstanceProposal resource. * @returns {string} A string representing the single_tenant_hsm_instance. */ - matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceProposalName(singleTenantHsmInstanceProposalName: string) { - return this.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match(singleTenantHsmInstanceProposalName).single_tenant_hsm_instance; + matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceProposalName( + singleTenantHsmInstanceProposalName: string, + ) { + return this.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match( + singleTenantHsmInstanceProposalName, + ).single_tenant_hsm_instance; } /** @@ -2885,8 +3638,12 @@ export class HsmManagementClient { * A fully-qualified path representing SingleTenantHsmInstanceProposal resource. * @returns {string} A string representing the proposal. */ - matchProposalFromSingleTenantHsmInstanceProposalName(singleTenantHsmInstanceProposalName: string) { - return this.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match(singleTenantHsmInstanceProposalName).proposal; + matchProposalFromSingleTenantHsmInstanceProposalName( + singleTenantHsmInstanceProposalName: string, + ) { + return this.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match( + singleTenantHsmInstanceProposalName, + ).proposal; } /** @@ -2897,15 +3654,19 @@ export class HsmManagementClient { */ close(): Promise { if (this.hsmManagementStub && !this._terminated) { - return this.hsmManagementStub.then(stub => { + return this.hsmManagementStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); - this.iamClient.close().catch(err => {throw err}); - this.locationsClient.close().catch(err => {throw err}); + this.iamClient.close().catch((err) => { + throw err; + }); + this.locationsClient.close().catch((err) => { + throw err; + }); void this.operationsClient.close(); }); } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-kms/src/v1/index.ts b/packages/google-cloud-kms/src/v1/index.ts index ff4f54322dd3..4ec8fd3bdb94 100644 --- a/packages/google-cloud-kms/src/v1/index.ts +++ b/packages/google-cloud-kms/src/v1/index.ts @@ -16,8 +16,8 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {AutokeyClient} from './autokey_client'; -export {AutokeyAdminClient} from './autokey_admin_client'; -export {EkmServiceClient} from './ekm_service_client'; -export {HsmManagementClient} from './hsm_management_client'; -export {KeyManagementServiceClient} from './key_management_service_client'; +export { AutokeyClient } from './autokey_client'; +export { AutokeyAdminClient } from './autokey_admin_client'; +export { EkmServiceClient } from './ekm_service_client'; +export { HsmManagementClient } from './hsm_management_client'; +export { KeyManagementServiceClient } from './key_management_service_client'; diff --git a/packages/google-cloud-kms/src/v1/key_management_service_client.ts b/packages/google-cloud-kms/src/v1/key_management_service_client.ts index 1c094158565e..2548039d306c 100644 --- a/packages/google-cloud-kms/src/v1/key_management_service_client.ts +++ b/packages/google-cloud-kms/src/v1/key_management_service_client.ts @@ -18,11 +18,24 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, IamClient, IamProtos, LocationsClient, LocationProtos} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, + PaginationCallback, + GaxCall, + IamClient, + IamProtos, + LocationsClient, + LocationProtos, +} from 'google-gax'; +import { Transform } from 'stream'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); -import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; +import { loggingUtils as logging, decodeAnyProtosInArray } from 'google-gax'; /** * Client JSON configuration object, loaded from @@ -55,7 +68,7 @@ export class KeyManagementServiceClient { 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('kms'); @@ -68,12 +81,12 @@ export class KeyManagementServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; iamClient: IamClient; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; + pathTemplates: { [name: string]: gax.PathTemplate }; operationsClient: gax.OperationsClient; - keyManagementServiceStub?: Promise<{[name: string]: Function}>; + keyManagementServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of KeyManagementServiceClient. @@ -114,21 +127,42 @@ export class KeyManagementServiceClient { * const client = new KeyManagementServiceClient({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 KeyManagementServiceClient; - 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 = 'cloudkms.' + 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; @@ -153,7 +187,7 @@ export class KeyManagementServiceClient { 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; @@ -166,18 +200,14 @@ export class KeyManagementServiceClient { this.auth.defaultScopes = staticMembers.scopes; } this.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); - + this.locationsClient = new this._gaxModule.LocationsClient( this._gaxGrpc, - opts + opts, ); - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process === 'object' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -199,66 +229,82 @@ export class KeyManagementServiceClient { // Create useful helper objects for these. this.pathTemplates = { 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}', ), ekmConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/ekmConfig' + 'projects/{project}/locations/{location}/ekmConfig', ), ekmConnectionPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/ekmConnections/{ekm_connection}' + 'projects/{project}/locations/{location}/ekmConnections/{ekm_connection}', ), folderAutokeyConfigPathTemplate: new this._gaxModule.PathTemplate( - 'folders/{folder}/autokeyConfig' + 'folders/{folder}/autokeyConfig', ), importJobPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/keyRings/{key_ring}/importJobs/{import_job}' + 'projects/{project}/locations/{location}/keyRings/{key_ring}/importJobs/{import_job}', ), keyHandlePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/keyHandles/{key_handle}' + 'projects/{project}/locations/{location}/keyHandles/{key_handle}', ), keyRingPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/keyRings/{key_ring}' + 'projects/{project}/locations/{location}/keyRings/{key_ring}', ), locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' + 'projects/{project}/locations/{location}', ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' + 'projects/{project}', ), projectAutokeyConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/autokeyConfig' + 'projects/{project}/autokeyConfig', ), publicKeyPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}/publicKey' + 'projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{crypto_key_version}/publicKey', ), retiredResourcePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/retiredResources/{retired_resource}' + 'projects/{project}/locations/{location}/retiredResources/{retired_resource}', ), singleTenantHsmInstancePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/singleTenantHsmInstances/{single_tenant_hsm_instance}' - ), - singleTenantHsmInstanceProposalPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/singleTenantHsmInstances/{single_tenant_hsm_instance}/proposals/{proposal}' + 'projects/{project}/locations/{location}/singleTenantHsmInstances/{single_tenant_hsm_instance}', ), + singleTenantHsmInstanceProposalPathTemplate: + new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/singleTenantHsmInstances/{single_tenant_hsm_instance}/proposals/{proposal}', + ), }; // Some of the methods on this service return "paged" results, // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listKeyRings: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'keyRings'), - listCryptoKeys: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'cryptoKeys'), - listCryptoKeyVersions: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'cryptoKeyVersions'), - listImportJobs: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'importJobs'), - listRetiredResources: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'retiredResources') + listKeyRings: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'keyRings', + ), + listCryptoKeys: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'cryptoKeys', + ), + listCryptoKeyVersions: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'cryptoKeyVersions', + ), + listImportJobs: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'importJobs', + ), + listRetiredResources: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'retiredResources', + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -267,40 +313,129 @@ export class KeyManagementServiceClient { // rather than holding a request open. const lroOptions: GrpcClientOptions = { auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; if (opts.fallback) { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v1/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v1/{name=projects/*}/locations',},{selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',get: '/v1/{resource=projects/*/locations/*/keyRings/*}:getIamPolicy',additional_bindings: [{get: '/v1/{resource=projects/*/locations/*/keyRings/*/cryptoKeys/*}:getIamPolicy',},{get: '/v1/{resource=projects/*/locations/*/keyRings/*/importJobs/*}:getIamPolicy',},{get: '/v1/{resource=projects/*/locations/*/ekmConfig}:getIamPolicy',},{get: '/v1/{resource=projects/*/locations/*/ekmConnections/*}:getIamPolicy',}], - },{selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',post: '/v1/{resource=projects/*/locations/*/keyRings/*}:setIamPolicy',body: '*',additional_bindings: [{post: '/v1/{resource=projects/*/locations/*/keyRings/*/cryptoKeys/*}:setIamPolicy',body: '*',},{post: '/v1/{resource=projects/*/locations/*/keyRings/*/importJobs/*}:setIamPolicy',body: '*',},{post: '/v1/{resource=projects/*/locations/*/ekmConfig}:setIamPolicy',body: '*',},{post: '/v1/{resource=projects/*/locations/*/ekmConnections/*}:setIamPolicy',body: '*',}], - },{selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',post: '/v1/{resource=projects/*/locations/*/keyRings/*}:testIamPermissions',body: '*',additional_bindings: [{post: '/v1/{resource=projects/*/locations/*/keyRings/*/cryptoKeys/*}:testIamPermissions',body: '*',},{post: '/v1/{resource=projects/*/locations/*/keyRings/*/importJobs/*}:testIamPermissions',body: '*',},{post: '/v1/{resource=projects/*/locations/*/ekmConfig}:testIamPermissions',body: '*',},{post: '/v1/{resource=projects/*/locations/*/ekmConnections/*}:testIamPermissions',body: '*',}], - },{selector: 'google.longrunning.Operations.GetOperation',get: '/v1/{name=projects/*/locations/*/operations/*}',}]; + lroOptions.httpRules = [ + { + selector: 'google.cloud.location.Locations.GetLocation', + get: '/v1/{name=projects/*/locations/*}', + }, + { + selector: 'google.cloud.location.Locations.ListLocations', + get: '/v1/{name=projects/*}/locations', + }, + { + selector: 'google.iam.v1.IAMPolicy.GetIamPolicy', + get: '/v1/{resource=projects/*/locations/*/keyRings/*}:getIamPolicy', + additional_bindings: [ + { + get: '/v1/{resource=projects/*/locations/*/keyRings/*/cryptoKeys/*}:getIamPolicy', + }, + { + get: '/v1/{resource=projects/*/locations/*/keyRings/*/importJobs/*}:getIamPolicy', + }, + { + get: '/v1/{resource=projects/*/locations/*/ekmConfig}:getIamPolicy', + }, + { + get: '/v1/{resource=projects/*/locations/*/ekmConnections/*}:getIamPolicy', + }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.SetIamPolicy', + post: '/v1/{resource=projects/*/locations/*/keyRings/*}:setIamPolicy', + body: '*', + additional_bindings: [ + { + post: '/v1/{resource=projects/*/locations/*/keyRings/*/cryptoKeys/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/keyRings/*/importJobs/*}:setIamPolicy', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/ekmConfig}:setIamPolicy', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/ekmConnections/*}:setIamPolicy', + body: '*', + }, + ], + }, + { + selector: 'google.iam.v1.IAMPolicy.TestIamPermissions', + post: '/v1/{resource=projects/*/locations/*/keyRings/*}:testIamPermissions', + body: '*', + additional_bindings: [ + { + post: '/v1/{resource=projects/*/locations/*/keyRings/*/cryptoKeys/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/keyRings/*/importJobs/*}:testIamPermissions', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/ekmConfig}:testIamPermissions', + body: '*', + }, + { + post: '/v1/{resource=projects/*/locations/*/ekmConnections/*}:testIamPermissions', + body: '*', + }, + ], + }, + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v1/{name=projects/*/locations/*/operations/*}', + }, + ]; } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); const deleteCryptoKeyResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteCryptoKeyMetadata = protoFilesRoot.lookup( - '.google.cloud.kms.v1.DeleteCryptoKeyMetadata') as gax.protobuf.Type; + '.google.cloud.kms.v1.DeleteCryptoKeyMetadata', + ) as gax.protobuf.Type; const deleteCryptoKeyVersionResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteCryptoKeyVersionMetadata = protoFilesRoot.lookup( - '.google.cloud.kms.v1.DeleteCryptoKeyVersionMetadata') as gax.protobuf.Type; + '.google.cloud.kms.v1.DeleteCryptoKeyVersionMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { deleteCryptoKey: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteCryptoKeyResponse.decode.bind(deleteCryptoKeyResponse), - deleteCryptoKeyMetadata.decode.bind(deleteCryptoKeyMetadata)), + deleteCryptoKeyMetadata.decode.bind(deleteCryptoKeyMetadata), + ), deleteCryptoKeyVersion: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - deleteCryptoKeyVersionResponse.decode.bind(deleteCryptoKeyVersionResponse), - deleteCryptoKeyVersionMetadata.decode.bind(deleteCryptoKeyVersionMetadata)) + deleteCryptoKeyVersionResponse.decode.bind( + deleteCryptoKeyVersionResponse, + ), + deleteCryptoKeyVersionMetadata.decode.bind( + deleteCryptoKeyVersionMetadata, + ), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.kms.v1.KeyManagementService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.kms.v1.KeyManagementService', + 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 @@ -331,28 +466,67 @@ export class KeyManagementServiceClient { // Put together the "service stub" for // google.cloud.kms.v1.KeyManagementService. this.keyManagementServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.kms.v1.KeyManagementService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.kms.v1.KeyManagementService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.kms.v1.KeyManagementService, - 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 keyManagementServiceStubMethods = - ['listKeyRings', 'listCryptoKeys', 'listCryptoKeyVersions', 'listImportJobs', 'listRetiredResources', 'getKeyRing', 'getCryptoKey', 'getCryptoKeyVersion', 'getPublicKey', 'getImportJob', 'getRetiredResource', 'createKeyRing', 'createCryptoKey', 'createCryptoKeyVersion', 'deleteCryptoKey', 'deleteCryptoKeyVersion', 'importCryptoKeyVersion', 'createImportJob', 'updateCryptoKey', 'updateCryptoKeyVersion', 'updateCryptoKeyPrimaryVersion', 'destroyCryptoKeyVersion', 'restoreCryptoKeyVersion', 'encrypt', 'decrypt', 'rawEncrypt', 'rawDecrypt', 'asymmetricSign', 'asymmetricDecrypt', 'macSign', 'macVerify', 'decapsulate', 'generateRandomBytes']; + const keyManagementServiceStubMethods = [ + 'listKeyRings', + 'listCryptoKeys', + 'listCryptoKeyVersions', + 'listImportJobs', + 'listRetiredResources', + 'getKeyRing', + 'getCryptoKey', + 'getCryptoKeyVersion', + 'getPublicKey', + 'getImportJob', + 'getRetiredResource', + 'createKeyRing', + 'createCryptoKey', + 'createCryptoKeyVersion', + 'deleteCryptoKey', + 'deleteCryptoKeyVersion', + 'importCryptoKeyVersion', + 'createImportJob', + 'updateCryptoKey', + 'updateCryptoKeyVersion', + 'updateCryptoKeyPrimaryVersion', + 'destroyCryptoKeyVersion', + 'restoreCryptoKeyVersion', + 'encrypt', + 'decrypt', + 'rawEncrypt', + 'rawDecrypt', + 'asymmetricSign', + 'asymmetricDecrypt', + 'macSign', + 'macVerify', + 'decapsulate', + 'generateRandomBytes', + ]; for (const methodName of keyManagementServiceStubMethods) { const callPromise = this.keyManagementServiceStub.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] || @@ -362,7 +536,7 @@ export class KeyManagementServiceClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -377,8 +551,14 @@ export class KeyManagementServiceClient { * @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 'cloudkms.googleapis.com'; } @@ -389,8 +569,14 @@ export class KeyManagementServiceClient { * @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 'cloudkms.googleapis.com'; } @@ -423,7 +609,7 @@ export class KeyManagementServiceClient { static get scopes() { return [ 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/cloudkms' + 'https://www.googleapis.com/auth/cloudkms', ]; } @@ -433,8 +619,9 @@ export class KeyManagementServiceClient { * 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; @@ -445,3486 +632,4496 @@ export class KeyManagementServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Returns metadata for a given {@link protos.google.cloud.kms.v1.KeyRing|KeyRing}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The {@link protos.google.cloud.kms.v1.KeyRing.name|name} of the - * {@link protos.google.cloud.kms.v1.KeyRing|KeyRing} 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.kms.v1.KeyRing|KeyRing}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/key_management_service.get_key_ring.js - * region_tag:cloudkms_v1_generated_KeyManagementService_GetKeyRing_async - */ + /** + * Returns metadata for a given {@link protos.google.cloud.kms.v1.KeyRing|KeyRing}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The {@link protos.google.cloud.kms.v1.KeyRing.name|name} of the + * {@link protos.google.cloud.kms.v1.KeyRing|KeyRing} 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.kms.v1.KeyRing|KeyRing}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/key_management_service.get_key_ring.js + * region_tag:cloudkms_v1_generated_KeyManagementService_GetKeyRing_async + */ getKeyRing( - request?: protos.google.cloud.kms.v1.IGetKeyRingRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.kms.v1.IKeyRing, - protos.google.cloud.kms.v1.IGetKeyRingRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.kms.v1.IGetKeyRingRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.kms.v1.IKeyRing, + protos.google.cloud.kms.v1.IGetKeyRingRequest | undefined, + {} | undefined, + ] + >; getKeyRing( - request: protos.google.cloud.kms.v1.IGetKeyRingRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.kms.v1.IKeyRing, - protos.google.cloud.kms.v1.IGetKeyRingRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IGetKeyRingRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.kms.v1.IKeyRing, + protos.google.cloud.kms.v1.IGetKeyRingRequest | null | undefined, + {} | null | undefined + >, + ): void; getKeyRing( - request: protos.google.cloud.kms.v1.IGetKeyRingRequest, - callback: Callback< - protos.google.cloud.kms.v1.IKeyRing, - protos.google.cloud.kms.v1.IGetKeyRingRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IGetKeyRingRequest, + callback: Callback< + protos.google.cloud.kms.v1.IKeyRing, + protos.google.cloud.kms.v1.IGetKeyRingRequest | null | undefined, + {} | null | undefined + >, + ): void; getKeyRing( - request?: protos.google.cloud.kms.v1.IGetKeyRingRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.kms.v1.IKeyRing, - protos.google.cloud.kms.v1.IGetKeyRingRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.kms.v1.IGetKeyRingRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.kms.v1.IKeyRing, - protos.google.cloud.kms.v1.IGetKeyRingRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.kms.v1.IKeyRing, - protos.google.cloud.kms.v1.IGetKeyRingRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.kms.v1.IGetKeyRingRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.kms.v1.IKeyRing, + protos.google.cloud.kms.v1.IGetKeyRingRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.kms.v1.IKeyRing, + protos.google.cloud.kms.v1.IGetKeyRingRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getKeyRing request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.kms.v1.IKeyRing, - protos.google.cloud.kms.v1.IGetKeyRingRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.kms.v1.IKeyRing, + protos.google.cloud.kms.v1.IGetKeyRingRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getKeyRing response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getKeyRing(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.kms.v1.IKeyRing, - protos.google.cloud.kms.v1.IGetKeyRingRequest|undefined, - {}|undefined - ]) => { - this._log.info('getKeyRing response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getKeyRing(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.kms.v1.IKeyRing, + protos.google.cloud.kms.v1.IGetKeyRingRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getKeyRing response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 metadata for a given {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey}, as - * well as its {@link protos.google.cloud.kms.v1.CryptoKey.primary|primary} - * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The {@link protos.google.cloud.kms.v1.CryptoKey.name|name} of the - * {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey} 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.kms.v1.CryptoKey|CryptoKey}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/key_management_service.get_crypto_key.js - * region_tag:cloudkms_v1_generated_KeyManagementService_GetCryptoKey_async - */ + /** + * Returns metadata for a given {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey}, as + * well as its {@link protos.google.cloud.kms.v1.CryptoKey.primary|primary} + * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The {@link protos.google.cloud.kms.v1.CryptoKey.name|name} of the + * {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey} 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.kms.v1.CryptoKey|CryptoKey}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/key_management_service.get_crypto_key.js + * region_tag:cloudkms_v1_generated_KeyManagementService_GetCryptoKey_async + */ getCryptoKey( - request?: protos.google.cloud.kms.v1.IGetCryptoKeyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.kms.v1.ICryptoKey, - protos.google.cloud.kms.v1.IGetCryptoKeyRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.kms.v1.IGetCryptoKeyRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.kms.v1.ICryptoKey, + protos.google.cloud.kms.v1.IGetCryptoKeyRequest | undefined, + {} | undefined, + ] + >; getCryptoKey( - request: protos.google.cloud.kms.v1.IGetCryptoKeyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.kms.v1.ICryptoKey, - protos.google.cloud.kms.v1.IGetCryptoKeyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IGetCryptoKeyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.kms.v1.ICryptoKey, + protos.google.cloud.kms.v1.IGetCryptoKeyRequest | null | undefined, + {} | null | undefined + >, + ): void; getCryptoKey( - request: protos.google.cloud.kms.v1.IGetCryptoKeyRequest, - callback: Callback< - protos.google.cloud.kms.v1.ICryptoKey, - protos.google.cloud.kms.v1.IGetCryptoKeyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IGetCryptoKeyRequest, + callback: Callback< + protos.google.cloud.kms.v1.ICryptoKey, + protos.google.cloud.kms.v1.IGetCryptoKeyRequest | null | undefined, + {} | null | undefined + >, + ): void; getCryptoKey( - request?: protos.google.cloud.kms.v1.IGetCryptoKeyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.kms.v1.ICryptoKey, - protos.google.cloud.kms.v1.IGetCryptoKeyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.kms.v1.IGetCryptoKeyRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.kms.v1.ICryptoKey, - protos.google.cloud.kms.v1.IGetCryptoKeyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.kms.v1.ICryptoKey, - protos.google.cloud.kms.v1.IGetCryptoKeyRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.kms.v1.IGetCryptoKeyRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.kms.v1.ICryptoKey, + protos.google.cloud.kms.v1.IGetCryptoKeyRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.kms.v1.ICryptoKey, + protos.google.cloud.kms.v1.IGetCryptoKeyRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getCryptoKey request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.kms.v1.ICryptoKey, - protos.google.cloud.kms.v1.IGetCryptoKeyRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.kms.v1.ICryptoKey, + protos.google.cloud.kms.v1.IGetCryptoKeyRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getCryptoKey response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getCryptoKey(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.kms.v1.ICryptoKey, - protos.google.cloud.kms.v1.IGetCryptoKeyRequest|undefined, - {}|undefined - ]) => { - this._log.info('getCryptoKey response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getCryptoKey(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.kms.v1.ICryptoKey, + protos.google.cloud.kms.v1.IGetCryptoKeyRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getCryptoKey response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 metadata for a given - * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The {@link protos.google.cloud.kms.v1.CryptoKeyVersion.name|name} of the - * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} 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.kms.v1.CryptoKeyVersion|CryptoKeyVersion}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/key_management_service.get_crypto_key_version.js - * region_tag:cloudkms_v1_generated_KeyManagementService_GetCryptoKeyVersion_async - */ + /** + * Returns metadata for a given + * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The {@link protos.google.cloud.kms.v1.CryptoKeyVersion.name|name} of the + * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} 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.kms.v1.CryptoKeyVersion|CryptoKeyVersion}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/key_management_service.get_crypto_key_version.js + * region_tag:cloudkms_v1_generated_KeyManagementService_GetCryptoKeyVersion_async + */ getCryptoKeyVersion( - request?: protos.google.cloud.kms.v1.IGetCryptoKeyVersionRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IGetCryptoKeyVersionRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.kms.v1.IGetCryptoKeyVersionRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.kms.v1.ICryptoKeyVersion, + protos.google.cloud.kms.v1.IGetCryptoKeyVersionRequest | undefined, + {} | undefined, + ] + >; getCryptoKeyVersion( - request: protos.google.cloud.kms.v1.IGetCryptoKeyVersionRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IGetCryptoKeyVersionRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IGetCryptoKeyVersionRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.kms.v1.ICryptoKeyVersion, + protos.google.cloud.kms.v1.IGetCryptoKeyVersionRequest | null | undefined, + {} | null | undefined + >, + ): void; getCryptoKeyVersion( - request: protos.google.cloud.kms.v1.IGetCryptoKeyVersionRequest, - callback: Callback< - protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IGetCryptoKeyVersionRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IGetCryptoKeyVersionRequest, + callback: Callback< + protos.google.cloud.kms.v1.ICryptoKeyVersion, + protos.google.cloud.kms.v1.IGetCryptoKeyVersionRequest | null | undefined, + {} | null | undefined + >, + ): void; getCryptoKeyVersion( - request?: protos.google.cloud.kms.v1.IGetCryptoKeyVersionRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IGetCryptoKeyVersionRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.kms.v1.IGetCryptoKeyVersionRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IGetCryptoKeyVersionRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IGetCryptoKeyVersionRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.kms.v1.IGetCryptoKeyVersionRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.kms.v1.ICryptoKeyVersion, + protos.google.cloud.kms.v1.IGetCryptoKeyVersionRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.kms.v1.ICryptoKeyVersion, + protos.google.cloud.kms.v1.IGetCryptoKeyVersionRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getCryptoKeyVersion request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IGetCryptoKeyVersionRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.kms.v1.ICryptoKeyVersion, + | protos.google.cloud.kms.v1.IGetCryptoKeyVersionRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getCryptoKeyVersion response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getCryptoKeyVersion(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IGetCryptoKeyVersionRequest|undefined, - {}|undefined - ]) => { - this._log.info('getCryptoKeyVersion response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getCryptoKeyVersion(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.kms.v1.ICryptoKeyVersion, + protos.google.cloud.kms.v1.IGetCryptoKeyVersionRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getCryptoKeyVersion response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 public key for the given - * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion}. The - * {@link protos.google.cloud.kms.v1.CryptoKey.purpose|CryptoKey.purpose} must be - * {@link protos.google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.ASYMMETRIC_SIGN|ASYMMETRIC_SIGN} - * or - * {@link protos.google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.ASYMMETRIC_DECRYPT|ASYMMETRIC_DECRYPT}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The {@link protos.google.cloud.kms.v1.CryptoKeyVersion.name|name} of the - * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} public key to get. - * @param {google.cloud.kms.v1.PublicKey.PublicKeyFormat} [request.publicKeyFormat] - * Optional. The {@link protos.google.cloud.kms.v1.PublicKey|PublicKey} format specified - * by the user. This field is required for PQC algorithms. If specified, the - * public key will be exported through the - * {@link protos.google.cloud.kms.v1.PublicKey.public_key|public_key} field in the - * requested format. Otherwise, the {@link protos.google.cloud.kms.v1.PublicKey.pem|pem} - * field will be populated for non-PQC algorithms, and an error will be - * returned for PQC algorithms. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.kms.v1.PublicKey|PublicKey}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/key_management_service.get_public_key.js - * region_tag:cloudkms_v1_generated_KeyManagementService_GetPublicKey_async - */ + /** + * Returns the public key for the given + * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion}. The + * {@link protos.google.cloud.kms.v1.CryptoKey.purpose|CryptoKey.purpose} must be + * {@link protos.google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.ASYMMETRIC_SIGN|ASYMMETRIC_SIGN} + * or + * {@link protos.google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.ASYMMETRIC_DECRYPT|ASYMMETRIC_DECRYPT}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The {@link protos.google.cloud.kms.v1.CryptoKeyVersion.name|name} of the + * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} public key to get. + * @param {google.cloud.kms.v1.PublicKey.PublicKeyFormat} [request.publicKeyFormat] + * Optional. The {@link protos.google.cloud.kms.v1.PublicKey|PublicKey} format specified + * by the user. This field is required for PQC algorithms. If specified, the + * public key will be exported through the + * {@link protos.google.cloud.kms.v1.PublicKey.public_key|public_key} field in the + * requested format. Otherwise, the {@link protos.google.cloud.kms.v1.PublicKey.pem|pem} + * field will be populated for non-PQC algorithms, and an error will be + * returned for PQC algorithms. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.kms.v1.PublicKey|PublicKey}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/key_management_service.get_public_key.js + * region_tag:cloudkms_v1_generated_KeyManagementService_GetPublicKey_async + */ getPublicKey( - request?: protos.google.cloud.kms.v1.IGetPublicKeyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.kms.v1.IPublicKey, - protos.google.cloud.kms.v1.IGetPublicKeyRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.kms.v1.IGetPublicKeyRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.kms.v1.IPublicKey, + protos.google.cloud.kms.v1.IGetPublicKeyRequest | undefined, + {} | undefined, + ] + >; getPublicKey( - request: protos.google.cloud.kms.v1.IGetPublicKeyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.kms.v1.IPublicKey, - protos.google.cloud.kms.v1.IGetPublicKeyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IGetPublicKeyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.kms.v1.IPublicKey, + protos.google.cloud.kms.v1.IGetPublicKeyRequest | null | undefined, + {} | null | undefined + >, + ): void; getPublicKey( - request: protos.google.cloud.kms.v1.IGetPublicKeyRequest, - callback: Callback< - protos.google.cloud.kms.v1.IPublicKey, - protos.google.cloud.kms.v1.IGetPublicKeyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IGetPublicKeyRequest, + callback: Callback< + protos.google.cloud.kms.v1.IPublicKey, + protos.google.cloud.kms.v1.IGetPublicKeyRequest | null | undefined, + {} | null | undefined + >, + ): void; getPublicKey( - request?: protos.google.cloud.kms.v1.IGetPublicKeyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.kms.v1.IPublicKey, - protos.google.cloud.kms.v1.IGetPublicKeyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.kms.v1.IGetPublicKeyRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.kms.v1.IPublicKey, - protos.google.cloud.kms.v1.IGetPublicKeyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.kms.v1.IPublicKey, - protos.google.cloud.kms.v1.IGetPublicKeyRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.kms.v1.IGetPublicKeyRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.kms.v1.IPublicKey, + protos.google.cloud.kms.v1.IGetPublicKeyRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.kms.v1.IPublicKey, + protos.google.cloud.kms.v1.IGetPublicKeyRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getPublicKey request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.kms.v1.IPublicKey, - protos.google.cloud.kms.v1.IGetPublicKeyRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.kms.v1.IPublicKey, + protos.google.cloud.kms.v1.IGetPublicKeyRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getPublicKey response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getPublicKey(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.kms.v1.IPublicKey, - protos.google.cloud.kms.v1.IGetPublicKeyRequest|undefined, - {}|undefined - ]) => { - this._log.info('getPublicKey response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getPublicKey(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.kms.v1.IPublicKey, + protos.google.cloud.kms.v1.IGetPublicKeyRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getPublicKey response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 metadata for a given {@link protos.google.cloud.kms.v1.ImportJob|ImportJob}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The {@link protos.google.cloud.kms.v1.ImportJob.name|name} of the - * {@link protos.google.cloud.kms.v1.ImportJob|ImportJob} 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.kms.v1.ImportJob|ImportJob}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/key_management_service.get_import_job.js - * region_tag:cloudkms_v1_generated_KeyManagementService_GetImportJob_async - */ + /** + * Returns metadata for a given {@link protos.google.cloud.kms.v1.ImportJob|ImportJob}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The {@link protos.google.cloud.kms.v1.ImportJob.name|name} of the + * {@link protos.google.cloud.kms.v1.ImportJob|ImportJob} 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.kms.v1.ImportJob|ImportJob}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/key_management_service.get_import_job.js + * region_tag:cloudkms_v1_generated_KeyManagementService_GetImportJob_async + */ getImportJob( - request?: protos.google.cloud.kms.v1.IGetImportJobRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.kms.v1.IImportJob, - protos.google.cloud.kms.v1.IGetImportJobRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.kms.v1.IGetImportJobRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.kms.v1.IImportJob, + protos.google.cloud.kms.v1.IGetImportJobRequest | undefined, + {} | undefined, + ] + >; getImportJob( - request: protos.google.cloud.kms.v1.IGetImportJobRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.kms.v1.IImportJob, - protos.google.cloud.kms.v1.IGetImportJobRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IGetImportJobRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.kms.v1.IImportJob, + protos.google.cloud.kms.v1.IGetImportJobRequest | null | undefined, + {} | null | undefined + >, + ): void; getImportJob( - request: protos.google.cloud.kms.v1.IGetImportJobRequest, - callback: Callback< - protos.google.cloud.kms.v1.IImportJob, - protos.google.cloud.kms.v1.IGetImportJobRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IGetImportJobRequest, + callback: Callback< + protos.google.cloud.kms.v1.IImportJob, + protos.google.cloud.kms.v1.IGetImportJobRequest | null | undefined, + {} | null | undefined + >, + ): void; getImportJob( - request?: protos.google.cloud.kms.v1.IGetImportJobRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.kms.v1.IImportJob, - protos.google.cloud.kms.v1.IGetImportJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.kms.v1.IGetImportJobRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.kms.v1.IImportJob, - protos.google.cloud.kms.v1.IGetImportJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.kms.v1.IImportJob, - protos.google.cloud.kms.v1.IGetImportJobRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.kms.v1.IGetImportJobRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.kms.v1.IImportJob, + protos.google.cloud.kms.v1.IGetImportJobRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.kms.v1.IImportJob, + protos.google.cloud.kms.v1.IGetImportJobRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getImportJob request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.kms.v1.IImportJob, - protos.google.cloud.kms.v1.IGetImportJobRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.kms.v1.IImportJob, + protos.google.cloud.kms.v1.IGetImportJobRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getImportJob response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getImportJob(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.kms.v1.IImportJob, - protos.google.cloud.kms.v1.IGetImportJobRequest|undefined, - {}|undefined - ]) => { - this._log.info('getImportJob response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getImportJob(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.kms.v1.IImportJob, + protos.google.cloud.kms.v1.IGetImportJobRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getImportJob response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Retrieves a specific {@link protos.google.cloud.kms.v1.RetiredResource|RetiredResource} - * resource, which represents the record of a deleted - * {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The {@link protos.google.cloud.kms.v1.RetiredResource.name|name} of the - * {@link protos.google.cloud.kms.v1.RetiredResource|RetiredResource} 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.kms.v1.RetiredResource|RetiredResource}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/key_management_service.get_retired_resource.js - * region_tag:cloudkms_v1_generated_KeyManagementService_GetRetiredResource_async - */ + /** + * Retrieves a specific {@link protos.google.cloud.kms.v1.RetiredResource|RetiredResource} + * resource, which represents the record of a deleted + * {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The {@link protos.google.cloud.kms.v1.RetiredResource.name|name} of the + * {@link protos.google.cloud.kms.v1.RetiredResource|RetiredResource} 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.kms.v1.RetiredResource|RetiredResource}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/key_management_service.get_retired_resource.js + * region_tag:cloudkms_v1_generated_KeyManagementService_GetRetiredResource_async + */ getRetiredResource( - request?: protos.google.cloud.kms.v1.IGetRetiredResourceRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.kms.v1.IRetiredResource, - protos.google.cloud.kms.v1.IGetRetiredResourceRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.kms.v1.IGetRetiredResourceRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.kms.v1.IRetiredResource, + protos.google.cloud.kms.v1.IGetRetiredResourceRequest | undefined, + {} | undefined, + ] + >; getRetiredResource( - request: protos.google.cloud.kms.v1.IGetRetiredResourceRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.kms.v1.IRetiredResource, - protos.google.cloud.kms.v1.IGetRetiredResourceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IGetRetiredResourceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.kms.v1.IRetiredResource, + protos.google.cloud.kms.v1.IGetRetiredResourceRequest | null | undefined, + {} | null | undefined + >, + ): void; getRetiredResource( - request: protos.google.cloud.kms.v1.IGetRetiredResourceRequest, - callback: Callback< - protos.google.cloud.kms.v1.IRetiredResource, - protos.google.cloud.kms.v1.IGetRetiredResourceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IGetRetiredResourceRequest, + callback: Callback< + protos.google.cloud.kms.v1.IRetiredResource, + protos.google.cloud.kms.v1.IGetRetiredResourceRequest | null | undefined, + {} | null | undefined + >, + ): void; getRetiredResource( - request?: protos.google.cloud.kms.v1.IGetRetiredResourceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.kms.v1.IRetiredResource, - protos.google.cloud.kms.v1.IGetRetiredResourceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.kms.v1.IGetRetiredResourceRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.kms.v1.IRetiredResource, - protos.google.cloud.kms.v1.IGetRetiredResourceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.kms.v1.IRetiredResource, - protos.google.cloud.kms.v1.IGetRetiredResourceRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.kms.v1.IGetRetiredResourceRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.kms.v1.IRetiredResource, + protos.google.cloud.kms.v1.IGetRetiredResourceRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.kms.v1.IRetiredResource, + protos.google.cloud.kms.v1.IGetRetiredResourceRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getRetiredResource request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.kms.v1.IRetiredResource, - protos.google.cloud.kms.v1.IGetRetiredResourceRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.kms.v1.IRetiredResource, + | protos.google.cloud.kms.v1.IGetRetiredResourceRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getRetiredResource response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getRetiredResource(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.kms.v1.IRetiredResource, - protos.google.cloud.kms.v1.IGetRetiredResourceRequest|undefined, - {}|undefined - ]) => { - this._log.info('getRetiredResource response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getRetiredResource(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.kms.v1.IRetiredResource, + protos.google.cloud.kms.v1.IGetRetiredResourceRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getRetiredResource response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 {@link protos.google.cloud.kms.v1.KeyRing|KeyRing} in a given Project and - * Location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the location associated with the - * {@link protos.google.cloud.kms.v1.KeyRing|KeyRings}, in the format - * `projects/* /locations/*`. - * @param {string} request.keyRingId - * Required. It must be unique within a location and match the regular - * expression `[a-zA-Z0-9_-]{1,63}` - * @param {google.cloud.kms.v1.KeyRing} request.keyRing - * Required. A {@link protos.google.cloud.kms.v1.KeyRing|KeyRing} with initial field - * values. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.kms.v1.KeyRing|KeyRing}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/key_management_service.create_key_ring.js - * region_tag:cloudkms_v1_generated_KeyManagementService_CreateKeyRing_async - */ - createKeyRing( - request?: protos.google.cloud.kms.v1.ICreateKeyRingRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.kms.v1.IKeyRing, - protos.google.cloud.kms.v1.ICreateKeyRingRequest|undefined, {}|undefined - ]>; - createKeyRing( - request: protos.google.cloud.kms.v1.ICreateKeyRingRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.kms.v1.IKeyRing, - protos.google.cloud.kms.v1.ICreateKeyRingRequest|null|undefined, - {}|null|undefined>): void; - createKeyRing( - request: protos.google.cloud.kms.v1.ICreateKeyRingRequest, - callback: Callback< - protos.google.cloud.kms.v1.IKeyRing, - protos.google.cloud.kms.v1.ICreateKeyRingRequest|null|undefined, - {}|null|undefined>): void; - createKeyRing( - request?: protos.google.cloud.kms.v1.ICreateKeyRingRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.kms.v1.IKeyRing, - protos.google.cloud.kms.v1.ICreateKeyRingRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.kms.v1.IKeyRing, - protos.google.cloud.kms.v1.ICreateKeyRingRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.kms.v1.IKeyRing, - protos.google.cloud.kms.v1.ICreateKeyRingRequest|undefined, {}|undefined - ]>|void { - request = request || {}; + /** + * Create a new {@link protos.google.cloud.kms.v1.KeyRing|KeyRing} in a given Project and + * Location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the location associated with the + * {@link protos.google.cloud.kms.v1.KeyRing|KeyRings}, in the format + * `projects/* /locations/*`. + * @param {string} request.keyRingId + * Required. It must be unique within a location and match the regular + * expression `[a-zA-Z0-9_-]{1,63}` + * @param {google.cloud.kms.v1.KeyRing} request.keyRing + * Required. A {@link protos.google.cloud.kms.v1.KeyRing|KeyRing} with initial field + * values. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.kms.v1.KeyRing|KeyRing}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/key_management_service.create_key_ring.js + * region_tag:cloudkms_v1_generated_KeyManagementService_CreateKeyRing_async + */ + createKeyRing( + request?: protos.google.cloud.kms.v1.ICreateKeyRingRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.kms.v1.IKeyRing, + protos.google.cloud.kms.v1.ICreateKeyRingRequest | undefined, + {} | undefined, + ] + >; + createKeyRing( + request: protos.google.cloud.kms.v1.ICreateKeyRingRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.kms.v1.IKeyRing, + protos.google.cloud.kms.v1.ICreateKeyRingRequest | null | undefined, + {} | null | undefined + >, + ): void; + createKeyRing( + request: protos.google.cloud.kms.v1.ICreateKeyRingRequest, + callback: Callback< + protos.google.cloud.kms.v1.IKeyRing, + protos.google.cloud.kms.v1.ICreateKeyRingRequest | null | undefined, + {} | null | undefined + >, + ): void; + createKeyRing( + request?: protos.google.cloud.kms.v1.ICreateKeyRingRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.kms.v1.IKeyRing, + protos.google.cloud.kms.v1.ICreateKeyRingRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.kms.v1.IKeyRing, + protos.google.cloud.kms.v1.ICreateKeyRingRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.kms.v1.IKeyRing, + protos.google.cloud.kms.v1.ICreateKeyRingRequest | undefined, + {} | undefined, + ] + > | void { + request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.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('createKeyRing request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.kms.v1.IKeyRing, - protos.google.cloud.kms.v1.ICreateKeyRingRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.kms.v1.IKeyRing, + protos.google.cloud.kms.v1.ICreateKeyRingRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('createKeyRing response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.createKeyRing(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.kms.v1.IKeyRing, - protos.google.cloud.kms.v1.ICreateKeyRingRequest|undefined, - {}|undefined - ]) => { - this._log.info('createKeyRing response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .createKeyRing(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.kms.v1.IKeyRing, + protos.google.cloud.kms.v1.ICreateKeyRingRequest | undefined, + {} | undefined, + ]) => { + this._log.info('createKeyRing response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey} within a - * {@link protos.google.cloud.kms.v1.KeyRing|KeyRing}. - * - * {@link protos.google.cloud.kms.v1.CryptoKey.purpose|CryptoKey.purpose} and - * {@link protos.google.cloud.kms.v1.CryptoKeyVersionTemplate.algorithm|CryptoKey.version_template.algorithm} - * are required. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The {@link protos.google.cloud.kms.v1.KeyRing.name|name} of the KeyRing - * associated with the {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKeys}. - * @param {string} request.cryptoKeyId - * Required. It must be unique within a KeyRing and match the regular - * expression `[a-zA-Z0-9_-]{1,63}` - * @param {google.cloud.kms.v1.CryptoKey} request.cryptoKey - * Required. A {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey} with initial field - * values. - * @param {boolean} request.skipInitialVersionCreation - * If set to true, the request will create a - * {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey} without any - * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersions}. You must - * manually call - * {@link protos.google.cloud.kms.v1.KeyManagementService.CreateCryptoKeyVersion|CreateCryptoKeyVersion} - * or - * {@link protos.google.cloud.kms.v1.KeyManagementService.ImportCryptoKeyVersion|ImportCryptoKeyVersion} - * before you can use this {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey}. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/key_management_service.create_crypto_key.js - * region_tag:cloudkms_v1_generated_KeyManagementService_CreateCryptoKey_async - */ + /** + * Create a new {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey} within a + * {@link protos.google.cloud.kms.v1.KeyRing|KeyRing}. + * + * {@link protos.google.cloud.kms.v1.CryptoKey.purpose|CryptoKey.purpose} and + * {@link protos.google.cloud.kms.v1.CryptoKeyVersionTemplate.algorithm|CryptoKey.version_template.algorithm} + * are required. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The {@link protos.google.cloud.kms.v1.KeyRing.name|name} of the KeyRing + * associated with the {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKeys}. + * @param {string} request.cryptoKeyId + * Required. It must be unique within a KeyRing and match the regular + * expression `[a-zA-Z0-9_-]{1,63}` + * @param {google.cloud.kms.v1.CryptoKey} request.cryptoKey + * Required. A {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey} with initial field + * values. + * @param {boolean} request.skipInitialVersionCreation + * If set to true, the request will create a + * {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey} without any + * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersions}. You must + * manually call + * {@link protos.google.cloud.kms.v1.KeyManagementService.CreateCryptoKeyVersion|CreateCryptoKeyVersion} + * or + * {@link protos.google.cloud.kms.v1.KeyManagementService.ImportCryptoKeyVersion|ImportCryptoKeyVersion} + * before you can use this {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey}. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/key_management_service.create_crypto_key.js + * region_tag:cloudkms_v1_generated_KeyManagementService_CreateCryptoKey_async + */ createCryptoKey( - request?: protos.google.cloud.kms.v1.ICreateCryptoKeyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.kms.v1.ICryptoKey, - protos.google.cloud.kms.v1.ICreateCryptoKeyRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.kms.v1.ICreateCryptoKeyRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.kms.v1.ICryptoKey, + protos.google.cloud.kms.v1.ICreateCryptoKeyRequest | undefined, + {} | undefined, + ] + >; createCryptoKey( - request: protos.google.cloud.kms.v1.ICreateCryptoKeyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.kms.v1.ICryptoKey, - protos.google.cloud.kms.v1.ICreateCryptoKeyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.ICreateCryptoKeyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.kms.v1.ICryptoKey, + protos.google.cloud.kms.v1.ICreateCryptoKeyRequest | null | undefined, + {} | null | undefined + >, + ): void; createCryptoKey( - request: protos.google.cloud.kms.v1.ICreateCryptoKeyRequest, - callback: Callback< - protos.google.cloud.kms.v1.ICryptoKey, - protos.google.cloud.kms.v1.ICreateCryptoKeyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.ICreateCryptoKeyRequest, + callback: Callback< + protos.google.cloud.kms.v1.ICryptoKey, + protos.google.cloud.kms.v1.ICreateCryptoKeyRequest | null | undefined, + {} | null | undefined + >, + ): void; createCryptoKey( - request?: protos.google.cloud.kms.v1.ICreateCryptoKeyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.kms.v1.ICryptoKey, - protos.google.cloud.kms.v1.ICreateCryptoKeyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.kms.v1.ICreateCryptoKeyRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.kms.v1.ICryptoKey, - protos.google.cloud.kms.v1.ICreateCryptoKeyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.kms.v1.ICryptoKey, - protos.google.cloud.kms.v1.ICreateCryptoKeyRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.kms.v1.ICreateCryptoKeyRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.kms.v1.ICryptoKey, + protos.google.cloud.kms.v1.ICreateCryptoKeyRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.kms.v1.ICryptoKey, + protos.google.cloud.kms.v1.ICreateCryptoKeyRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.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('createCryptoKey request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.kms.v1.ICryptoKey, - protos.google.cloud.kms.v1.ICreateCryptoKeyRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.kms.v1.ICryptoKey, + protos.google.cloud.kms.v1.ICreateCryptoKeyRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('createCryptoKey response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.createCryptoKey(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.kms.v1.ICryptoKey, - protos.google.cloud.kms.v1.ICreateCryptoKeyRequest|undefined, - {}|undefined - ]) => { - this._log.info('createCryptoKey response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .createCryptoKey(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.kms.v1.ICryptoKey, + protos.google.cloud.kms.v1.ICreateCryptoKeyRequest | undefined, + {} | undefined, + ]) => { + this._log.info('createCryptoKey response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} in a - * {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey}. - * - * The server will assign the next sequential id. If unset, - * {@link protos.google.cloud.kms.v1.CryptoKeyVersion.state|state} will be set to - * {@link protos.google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.ENABLED|ENABLED}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The {@link protos.google.cloud.kms.v1.CryptoKey.name|name} of the - * {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey} associated with the - * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersions}. - * @param {google.cloud.kms.v1.CryptoKeyVersion} request.cryptoKeyVersion - * Required. A {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} with - * initial field values. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/key_management_service.create_crypto_key_version.js - * region_tag:cloudkms_v1_generated_KeyManagementService_CreateCryptoKeyVersion_async - */ + /** + * Create a new {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} in a + * {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey}. + * + * The server will assign the next sequential id. If unset, + * {@link protos.google.cloud.kms.v1.CryptoKeyVersion.state|state} will be set to + * {@link protos.google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.ENABLED|ENABLED}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The {@link protos.google.cloud.kms.v1.CryptoKey.name|name} of the + * {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey} associated with the + * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersions}. + * @param {google.cloud.kms.v1.CryptoKeyVersion} request.cryptoKeyVersion + * Required. A {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} with + * initial field values. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/key_management_service.create_crypto_key_version.js + * region_tag:cloudkms_v1_generated_KeyManagementService_CreateCryptoKeyVersion_async + */ createCryptoKeyVersion( - request?: protos.google.cloud.kms.v1.ICreateCryptoKeyVersionRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.ICreateCryptoKeyVersionRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.kms.v1.ICreateCryptoKeyVersionRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.kms.v1.ICryptoKeyVersion, + protos.google.cloud.kms.v1.ICreateCryptoKeyVersionRequest | undefined, + {} | undefined, + ] + >; createCryptoKeyVersion( - request: protos.google.cloud.kms.v1.ICreateCryptoKeyVersionRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.ICreateCryptoKeyVersionRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.ICreateCryptoKeyVersionRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.kms.v1.ICryptoKeyVersion, + | protos.google.cloud.kms.v1.ICreateCryptoKeyVersionRequest + | null + | undefined, + {} | null | undefined + >, + ): void; createCryptoKeyVersion( - request: protos.google.cloud.kms.v1.ICreateCryptoKeyVersionRequest, - callback: Callback< - protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.ICreateCryptoKeyVersionRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.ICreateCryptoKeyVersionRequest, + callback: Callback< + protos.google.cloud.kms.v1.ICryptoKeyVersion, + | protos.google.cloud.kms.v1.ICreateCryptoKeyVersionRequest + | null + | undefined, + {} | null | undefined + >, + ): void; createCryptoKeyVersion( - request?: protos.google.cloud.kms.v1.ICreateCryptoKeyVersionRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.ICreateCryptoKeyVersionRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.kms.v1.ICreateCryptoKeyVersionRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.ICreateCryptoKeyVersionRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.ICreateCryptoKeyVersionRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.kms.v1.ICreateCryptoKeyVersionRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.kms.v1.ICryptoKeyVersion, + | protos.google.cloud.kms.v1.ICreateCryptoKeyVersionRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.kms.v1.ICryptoKeyVersion, + protos.google.cloud.kms.v1.ICreateCryptoKeyVersionRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.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('createCryptoKeyVersion request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.ICreateCryptoKeyVersionRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.kms.v1.ICryptoKeyVersion, + | protos.google.cloud.kms.v1.ICreateCryptoKeyVersionRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('createCryptoKeyVersion response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.createCryptoKeyVersion(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.ICreateCryptoKeyVersionRequest|undefined, - {}|undefined - ]) => { - this._log.info('createCryptoKeyVersion response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .createCryptoKeyVersion(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.kms.v1.ICryptoKeyVersion, + protos.google.cloud.kms.v1.ICreateCryptoKeyVersionRequest | undefined, + {} | undefined, + ]) => { + this._log.info('createCryptoKeyVersion response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Import wrapped key material into a - * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion}. - * - * All requests must specify a {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey}. If - * a {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} is additionally - * specified in the request, key material will be reimported into that - * version. Otherwise, a new version will be created, and will be assigned the - * next sequential id within the {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The {@link protos.google.cloud.kms.v1.CryptoKey.name|name} of the - * {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey} to be imported into. - * - * The create permission is only required on this key when creating a new - * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion}. - * @param {string} [request.cryptoKeyVersion] - * Optional. The optional {@link protos.google.cloud.kms.v1.CryptoKeyVersion.name|name} of - * an existing {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} to - * target for an import operation. If this field is not present, a new - * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} containing the - * supplied key material is created. - * - * If this field is present, the supplied key material is imported into - * the existing {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion}. To - * import into an existing - * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion}, the - * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} must be a child of - * {@link protos.google.cloud.kms.v1.ImportCryptoKeyVersionRequest.parent|ImportCryptoKeyVersionRequest.parent}, - * have been previously created via - * {@link protos.google.cloud.kms.v1.KeyManagementService.ImportCryptoKeyVersion|ImportCryptoKeyVersion}, - * and be in - * {@link protos.google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROYED|DESTROYED} - * or - * {@link protos.google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.IMPORT_FAILED|IMPORT_FAILED} - * state. The key material and algorithm must match the previous - * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} exactly if the - * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} has ever contained - * key material. - * @param {google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionAlgorithm} request.algorithm - * Required. The - * {@link protos.google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionAlgorithm|algorithm} - * of the key being imported. This does not need to match the - * {@link protos.google.cloud.kms.v1.CryptoKey.version_template|version_template} of the - * {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey} this version imports into. - * @param {string} request.importJob - * Required. The {@link protos.google.cloud.kms.v1.ImportJob.name|name} of the - * {@link protos.google.cloud.kms.v1.ImportJob|ImportJob} that was used to wrap this key - * material. - * @param {Buffer} [request.wrappedKey] - * Optional. The wrapped key material to import. - * - * Before wrapping, key material must be formatted. If importing symmetric key - * material, the expected key material format is plain bytes. If importing - * asymmetric key material, the expected key material format is PKCS#8-encoded - * DER (the PrivateKeyInfo structure from RFC 5208). - * - * When wrapping with import methods - * ({@link protos.google.cloud.kms.v1.ImportJob.ImportMethod.RSA_OAEP_3072_SHA1_AES_256|RSA_OAEP_3072_SHA1_AES_256} - * or - * {@link protos.google.cloud.kms.v1.ImportJob.ImportMethod.RSA_OAEP_4096_SHA1_AES_256|RSA_OAEP_4096_SHA1_AES_256} - * or - * {@link protos.google.cloud.kms.v1.ImportJob.ImportMethod.RSA_OAEP_3072_SHA256_AES_256|RSA_OAEP_3072_SHA256_AES_256} - * or - * {@link protos.google.cloud.kms.v1.ImportJob.ImportMethod.RSA_OAEP_4096_SHA256_AES_256|RSA_OAEP_4096_SHA256_AES_256}), - * - * this field must contain the concatenation of: - *
    - *
  1. An ephemeral AES-256 wrapping key wrapped with the - * {@link protos.google.cloud.kms.v1.ImportJob.public_key|public_key} using - * RSAES-OAEP with SHA-1/SHA-256, MGF1 with SHA-1/SHA-256, and an empty - * label. - *
  2. - *
  3. The formatted key to be imported, wrapped with the ephemeral AES-256 - * key using AES-KWP (RFC 5649). - *
  4. - *
- * - * This format is the same as the format produced by PKCS#11 mechanism - * CKM_RSA_AES_KEY_WRAP. - * - * When wrapping with import methods - * ({@link protos.google.cloud.kms.v1.ImportJob.ImportMethod.RSA_OAEP_3072_SHA256|RSA_OAEP_3072_SHA256} - * or - * {@link protos.google.cloud.kms.v1.ImportJob.ImportMethod.RSA_OAEP_4096_SHA256|RSA_OAEP_4096_SHA256}), - * - * this field must contain the formatted key to be imported, wrapped with the - * {@link protos.google.cloud.kms.v1.ImportJob.public_key|public_key} using RSAES-OAEP - * with SHA-256, MGF1 with SHA-256, and an empty label. - * @param {Buffer} [request.rsaAesWrappedKey] - * Optional. This field has the same meaning as - * {@link protos.google.cloud.kms.v1.ImportCryptoKeyVersionRequest.wrapped_key|wrapped_key}. - * Prefer to use that field in new work. Either that field or this field - * (but not both) must be 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 an object representing {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/key_management_service.import_crypto_key_version.js - * region_tag:cloudkms_v1_generated_KeyManagementService_ImportCryptoKeyVersion_async - */ + /** + * Import wrapped key material into a + * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion}. + * + * All requests must specify a {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey}. If + * a {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} is additionally + * specified in the request, key material will be reimported into that + * version. Otherwise, a new version will be created, and will be assigned the + * next sequential id within the {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The {@link protos.google.cloud.kms.v1.CryptoKey.name|name} of the + * {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey} to be imported into. + * + * The create permission is only required on this key when creating a new + * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion}. + * @param {string} [request.cryptoKeyVersion] + * Optional. The optional {@link protos.google.cloud.kms.v1.CryptoKeyVersion.name|name} of + * an existing {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} to + * target for an import operation. If this field is not present, a new + * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} containing the + * supplied key material is created. + * + * If this field is present, the supplied key material is imported into + * the existing {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion}. To + * import into an existing + * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion}, the + * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} must be a child of + * {@link protos.google.cloud.kms.v1.ImportCryptoKeyVersionRequest.parent|ImportCryptoKeyVersionRequest.parent}, + * have been previously created via + * {@link protos.google.cloud.kms.v1.KeyManagementService.ImportCryptoKeyVersion|ImportCryptoKeyVersion}, + * and be in + * {@link protos.google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROYED|DESTROYED} + * or + * {@link protos.google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.IMPORT_FAILED|IMPORT_FAILED} + * state. The key material and algorithm must match the previous + * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} exactly if the + * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} has ever contained + * key material. + * @param {google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionAlgorithm} request.algorithm + * Required. The + * {@link protos.google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionAlgorithm|algorithm} + * of the key being imported. This does not need to match the + * {@link protos.google.cloud.kms.v1.CryptoKey.version_template|version_template} of the + * {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey} this version imports into. + * @param {string} request.importJob + * Required. The {@link protos.google.cloud.kms.v1.ImportJob.name|name} of the + * {@link protos.google.cloud.kms.v1.ImportJob|ImportJob} that was used to wrap this key + * material. + * @param {Buffer} [request.wrappedKey] + * Optional. The wrapped key material to import. + * + * Before wrapping, key material must be formatted. If importing symmetric key + * material, the expected key material format is plain bytes. If importing + * asymmetric key material, the expected key material format is PKCS#8-encoded + * DER (the PrivateKeyInfo structure from RFC 5208). + * + * When wrapping with import methods + * ({@link protos.google.cloud.kms.v1.ImportJob.ImportMethod.RSA_OAEP_3072_SHA1_AES_256|RSA_OAEP_3072_SHA1_AES_256} + * or + * {@link protos.google.cloud.kms.v1.ImportJob.ImportMethod.RSA_OAEP_4096_SHA1_AES_256|RSA_OAEP_4096_SHA1_AES_256} + * or + * {@link protos.google.cloud.kms.v1.ImportJob.ImportMethod.RSA_OAEP_3072_SHA256_AES_256|RSA_OAEP_3072_SHA256_AES_256} + * or + * {@link protos.google.cloud.kms.v1.ImportJob.ImportMethod.RSA_OAEP_4096_SHA256_AES_256|RSA_OAEP_4096_SHA256_AES_256}), + * + * this field must contain the concatenation of: + *
    + *
  1. An ephemeral AES-256 wrapping key wrapped with the + * {@link protos.google.cloud.kms.v1.ImportJob.public_key|public_key} using + * RSAES-OAEP with SHA-1/SHA-256, MGF1 with SHA-1/SHA-256, and an empty + * label. + *
  2. + *
  3. The formatted key to be imported, wrapped with the ephemeral AES-256 + * key using AES-KWP (RFC 5649). + *
  4. + *
+ * + * This format is the same as the format produced by PKCS#11 mechanism + * CKM_RSA_AES_KEY_WRAP. + * + * When wrapping with import methods + * ({@link protos.google.cloud.kms.v1.ImportJob.ImportMethod.RSA_OAEP_3072_SHA256|RSA_OAEP_3072_SHA256} + * or + * {@link protos.google.cloud.kms.v1.ImportJob.ImportMethod.RSA_OAEP_4096_SHA256|RSA_OAEP_4096_SHA256}), + * + * this field must contain the formatted key to be imported, wrapped with the + * {@link protos.google.cloud.kms.v1.ImportJob.public_key|public_key} using RSAES-OAEP + * with SHA-256, MGF1 with SHA-256, and an empty label. + * @param {Buffer} [request.rsaAesWrappedKey] + * Optional. This field has the same meaning as + * {@link protos.google.cloud.kms.v1.ImportCryptoKeyVersionRequest.wrapped_key|wrapped_key}. + * Prefer to use that field in new work. Either that field or this field + * (but not both) must be 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 an object representing {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/key_management_service.import_crypto_key_version.js + * region_tag:cloudkms_v1_generated_KeyManagementService_ImportCryptoKeyVersion_async + */ importCryptoKeyVersion( - request?: protos.google.cloud.kms.v1.IImportCryptoKeyVersionRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IImportCryptoKeyVersionRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.kms.v1.IImportCryptoKeyVersionRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.kms.v1.ICryptoKeyVersion, + protos.google.cloud.kms.v1.IImportCryptoKeyVersionRequest | undefined, + {} | undefined, + ] + >; importCryptoKeyVersion( - request: protos.google.cloud.kms.v1.IImportCryptoKeyVersionRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IImportCryptoKeyVersionRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IImportCryptoKeyVersionRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.kms.v1.ICryptoKeyVersion, + | protos.google.cloud.kms.v1.IImportCryptoKeyVersionRequest + | null + | undefined, + {} | null | undefined + >, + ): void; importCryptoKeyVersion( - request: protos.google.cloud.kms.v1.IImportCryptoKeyVersionRequest, - callback: Callback< - protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IImportCryptoKeyVersionRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IImportCryptoKeyVersionRequest, + callback: Callback< + protos.google.cloud.kms.v1.ICryptoKeyVersion, + | protos.google.cloud.kms.v1.IImportCryptoKeyVersionRequest + | null + | undefined, + {} | null | undefined + >, + ): void; importCryptoKeyVersion( - request?: protos.google.cloud.kms.v1.IImportCryptoKeyVersionRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IImportCryptoKeyVersionRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.kms.v1.IImportCryptoKeyVersionRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IImportCryptoKeyVersionRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IImportCryptoKeyVersionRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.kms.v1.IImportCryptoKeyVersionRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.kms.v1.ICryptoKeyVersion, + | protos.google.cloud.kms.v1.IImportCryptoKeyVersionRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.kms.v1.ICryptoKeyVersion, + protos.google.cloud.kms.v1.IImportCryptoKeyVersionRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.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('importCryptoKeyVersion request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IImportCryptoKeyVersionRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.kms.v1.ICryptoKeyVersion, + | protos.google.cloud.kms.v1.IImportCryptoKeyVersionRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('importCryptoKeyVersion response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.importCryptoKeyVersion(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IImportCryptoKeyVersionRequest|undefined, - {}|undefined - ]) => { - this._log.info('importCryptoKeyVersion response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .importCryptoKeyVersion(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.kms.v1.ICryptoKeyVersion, + protos.google.cloud.kms.v1.IImportCryptoKeyVersionRequest | undefined, + {} | undefined, + ]) => { + this._log.info('importCryptoKeyVersion response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 {@link protos.google.cloud.kms.v1.ImportJob|ImportJob} within a - * {@link protos.google.cloud.kms.v1.KeyRing|KeyRing}. - * - * {@link protos.google.cloud.kms.v1.ImportJob.import_method|ImportJob.import_method} is - * required. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The {@link protos.google.cloud.kms.v1.KeyRing.name|name} of the - * {@link protos.google.cloud.kms.v1.KeyRing|KeyRing} associated with the - * {@link protos.google.cloud.kms.v1.ImportJob|ImportJobs}. - * @param {string} request.importJobId - * Required. It must be unique within a KeyRing and match the regular - * expression `[a-zA-Z0-9_-]{1,63}` - * @param {google.cloud.kms.v1.ImportJob} request.importJob - * Required. An {@link protos.google.cloud.kms.v1.ImportJob|ImportJob} with initial field - * values. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.kms.v1.ImportJob|ImportJob}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/key_management_service.create_import_job.js - * region_tag:cloudkms_v1_generated_KeyManagementService_CreateImportJob_async - */ + /** + * Create a new {@link protos.google.cloud.kms.v1.ImportJob|ImportJob} within a + * {@link protos.google.cloud.kms.v1.KeyRing|KeyRing}. + * + * {@link protos.google.cloud.kms.v1.ImportJob.import_method|ImportJob.import_method} is + * required. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The {@link protos.google.cloud.kms.v1.KeyRing.name|name} of the + * {@link protos.google.cloud.kms.v1.KeyRing|KeyRing} associated with the + * {@link protos.google.cloud.kms.v1.ImportJob|ImportJobs}. + * @param {string} request.importJobId + * Required. It must be unique within a KeyRing and match the regular + * expression `[a-zA-Z0-9_-]{1,63}` + * @param {google.cloud.kms.v1.ImportJob} request.importJob + * Required. An {@link protos.google.cloud.kms.v1.ImportJob|ImportJob} with initial field + * values. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.kms.v1.ImportJob|ImportJob}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/key_management_service.create_import_job.js + * region_tag:cloudkms_v1_generated_KeyManagementService_CreateImportJob_async + */ createImportJob( - request?: protos.google.cloud.kms.v1.ICreateImportJobRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.kms.v1.IImportJob, - protos.google.cloud.kms.v1.ICreateImportJobRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.kms.v1.ICreateImportJobRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.kms.v1.IImportJob, + protos.google.cloud.kms.v1.ICreateImportJobRequest | undefined, + {} | undefined, + ] + >; createImportJob( - request: protos.google.cloud.kms.v1.ICreateImportJobRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.kms.v1.IImportJob, - protos.google.cloud.kms.v1.ICreateImportJobRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.ICreateImportJobRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.kms.v1.IImportJob, + protos.google.cloud.kms.v1.ICreateImportJobRequest | null | undefined, + {} | null | undefined + >, + ): void; createImportJob( - request: protos.google.cloud.kms.v1.ICreateImportJobRequest, - callback: Callback< - protos.google.cloud.kms.v1.IImportJob, - protos.google.cloud.kms.v1.ICreateImportJobRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.ICreateImportJobRequest, + callback: Callback< + protos.google.cloud.kms.v1.IImportJob, + protos.google.cloud.kms.v1.ICreateImportJobRequest | null | undefined, + {} | null | undefined + >, + ): void; createImportJob( - request?: protos.google.cloud.kms.v1.ICreateImportJobRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.kms.v1.IImportJob, - protos.google.cloud.kms.v1.ICreateImportJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.kms.v1.ICreateImportJobRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.kms.v1.IImportJob, - protos.google.cloud.kms.v1.ICreateImportJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.kms.v1.IImportJob, - protos.google.cloud.kms.v1.ICreateImportJobRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.kms.v1.ICreateImportJobRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.kms.v1.IImportJob, + protos.google.cloud.kms.v1.ICreateImportJobRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.kms.v1.IImportJob, + protos.google.cloud.kms.v1.ICreateImportJobRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.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('createImportJob request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.kms.v1.IImportJob, - protos.google.cloud.kms.v1.ICreateImportJobRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.kms.v1.IImportJob, + protos.google.cloud.kms.v1.ICreateImportJobRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('createImportJob response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.createImportJob(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.kms.v1.IImportJob, - protos.google.cloud.kms.v1.ICreateImportJobRequest|undefined, - {}|undefined - ]) => { - this._log.info('createImportJob response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .createImportJob(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.kms.v1.IImportJob, + protos.google.cloud.kms.v1.ICreateImportJobRequest | undefined, + {} | undefined, + ]) => { + this._log.info('createImportJob response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey}. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.kms.v1.CryptoKey} request.cryptoKey - * Required. {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey} with updated values. - * @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.kms.v1.CryptoKey|CryptoKey}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/key_management_service.update_crypto_key.js - * region_tag:cloudkms_v1_generated_KeyManagementService_UpdateCryptoKey_async - */ + /** + * Update a {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey}. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.kms.v1.CryptoKey} request.cryptoKey + * Required. {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey} with updated values. + * @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.kms.v1.CryptoKey|CryptoKey}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/key_management_service.update_crypto_key.js + * region_tag:cloudkms_v1_generated_KeyManagementService_UpdateCryptoKey_async + */ updateCryptoKey( - request?: protos.google.cloud.kms.v1.IUpdateCryptoKeyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.kms.v1.ICryptoKey, - protos.google.cloud.kms.v1.IUpdateCryptoKeyRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.kms.v1.IUpdateCryptoKeyRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.kms.v1.ICryptoKey, + protos.google.cloud.kms.v1.IUpdateCryptoKeyRequest | undefined, + {} | undefined, + ] + >; updateCryptoKey( - request: protos.google.cloud.kms.v1.IUpdateCryptoKeyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.kms.v1.ICryptoKey, - protos.google.cloud.kms.v1.IUpdateCryptoKeyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IUpdateCryptoKeyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.kms.v1.ICryptoKey, + protos.google.cloud.kms.v1.IUpdateCryptoKeyRequest | null | undefined, + {} | null | undefined + >, + ): void; updateCryptoKey( - request: protos.google.cloud.kms.v1.IUpdateCryptoKeyRequest, - callback: Callback< - protos.google.cloud.kms.v1.ICryptoKey, - protos.google.cloud.kms.v1.IUpdateCryptoKeyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IUpdateCryptoKeyRequest, + callback: Callback< + protos.google.cloud.kms.v1.ICryptoKey, + protos.google.cloud.kms.v1.IUpdateCryptoKeyRequest | null | undefined, + {} | null | undefined + >, + ): void; updateCryptoKey( - request?: protos.google.cloud.kms.v1.IUpdateCryptoKeyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.kms.v1.ICryptoKey, - protos.google.cloud.kms.v1.IUpdateCryptoKeyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.kms.v1.IUpdateCryptoKeyRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.kms.v1.ICryptoKey, - protos.google.cloud.kms.v1.IUpdateCryptoKeyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.kms.v1.ICryptoKey, - protos.google.cloud.kms.v1.IUpdateCryptoKeyRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.kms.v1.IUpdateCryptoKeyRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.kms.v1.ICryptoKey, + protos.google.cloud.kms.v1.IUpdateCryptoKeyRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.kms.v1.ICryptoKey, + protos.google.cloud.kms.v1.IUpdateCryptoKeyRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'crypto_key.name': request.cryptoKey!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'crypto_key.name': request.cryptoKey!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('updateCryptoKey request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.kms.v1.ICryptoKey, - protos.google.cloud.kms.v1.IUpdateCryptoKeyRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.kms.v1.ICryptoKey, + protos.google.cloud.kms.v1.IUpdateCryptoKeyRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('updateCryptoKey response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.updateCryptoKey(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.kms.v1.ICryptoKey, - protos.google.cloud.kms.v1.IUpdateCryptoKeyRequest|undefined, - {}|undefined - ]) => { - this._log.info('updateCryptoKey response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .updateCryptoKey(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.kms.v1.ICryptoKey, + protos.google.cloud.kms.v1.IUpdateCryptoKeyRequest | undefined, + {} | undefined, + ]) => { + this._log.info('updateCryptoKey response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion}'s - * metadata. - * - * {@link protos.google.cloud.kms.v1.CryptoKeyVersion.state|state} may be changed between - * {@link protos.google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.ENABLED|ENABLED} - * and - * {@link protos.google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DISABLED|DISABLED} - * using this method. See - * {@link protos.google.cloud.kms.v1.KeyManagementService.DestroyCryptoKeyVersion|DestroyCryptoKeyVersion} - * and - * {@link protos.google.cloud.kms.v1.KeyManagementService.RestoreCryptoKeyVersion|RestoreCryptoKeyVersion} - * to move between other states. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.kms.v1.CryptoKeyVersion} request.cryptoKeyVersion - * Required. {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} with - * updated values. - * @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.kms.v1.CryptoKeyVersion|CryptoKeyVersion}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/key_management_service.update_crypto_key_version.js - * region_tag:cloudkms_v1_generated_KeyManagementService_UpdateCryptoKeyVersion_async - */ + /** + * Update a {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion}'s + * metadata. + * + * {@link protos.google.cloud.kms.v1.CryptoKeyVersion.state|state} may be changed between + * {@link protos.google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.ENABLED|ENABLED} + * and + * {@link protos.google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DISABLED|DISABLED} + * using this method. See + * {@link protos.google.cloud.kms.v1.KeyManagementService.DestroyCryptoKeyVersion|DestroyCryptoKeyVersion} + * and + * {@link protos.google.cloud.kms.v1.KeyManagementService.RestoreCryptoKeyVersion|RestoreCryptoKeyVersion} + * to move between other states. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.kms.v1.CryptoKeyVersion} request.cryptoKeyVersion + * Required. {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} with + * updated values. + * @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.kms.v1.CryptoKeyVersion|CryptoKeyVersion}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/key_management_service.update_crypto_key_version.js + * region_tag:cloudkms_v1_generated_KeyManagementService_UpdateCryptoKeyVersion_async + */ updateCryptoKeyVersion( - request?: protos.google.cloud.kms.v1.IUpdateCryptoKeyVersionRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IUpdateCryptoKeyVersionRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.kms.v1.IUpdateCryptoKeyVersionRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.kms.v1.ICryptoKeyVersion, + protos.google.cloud.kms.v1.IUpdateCryptoKeyVersionRequest | undefined, + {} | undefined, + ] + >; updateCryptoKeyVersion( - request: protos.google.cloud.kms.v1.IUpdateCryptoKeyVersionRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IUpdateCryptoKeyVersionRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IUpdateCryptoKeyVersionRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.kms.v1.ICryptoKeyVersion, + | protos.google.cloud.kms.v1.IUpdateCryptoKeyVersionRequest + | null + | undefined, + {} | null | undefined + >, + ): void; updateCryptoKeyVersion( - request: protos.google.cloud.kms.v1.IUpdateCryptoKeyVersionRequest, - callback: Callback< - protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IUpdateCryptoKeyVersionRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IUpdateCryptoKeyVersionRequest, + callback: Callback< + protos.google.cloud.kms.v1.ICryptoKeyVersion, + | protos.google.cloud.kms.v1.IUpdateCryptoKeyVersionRequest + | null + | undefined, + {} | null | undefined + >, + ): void; updateCryptoKeyVersion( - request?: protos.google.cloud.kms.v1.IUpdateCryptoKeyVersionRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IUpdateCryptoKeyVersionRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.kms.v1.IUpdateCryptoKeyVersionRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IUpdateCryptoKeyVersionRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IUpdateCryptoKeyVersionRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.kms.v1.IUpdateCryptoKeyVersionRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.kms.v1.ICryptoKeyVersion, + | protos.google.cloud.kms.v1.IUpdateCryptoKeyVersionRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.kms.v1.ICryptoKeyVersion, + protos.google.cloud.kms.v1.IUpdateCryptoKeyVersionRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'crypto_key_version.name': request.cryptoKeyVersion!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'crypto_key_version.name': request.cryptoKeyVersion!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('updateCryptoKeyVersion request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IUpdateCryptoKeyVersionRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.kms.v1.ICryptoKeyVersion, + | protos.google.cloud.kms.v1.IUpdateCryptoKeyVersionRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('updateCryptoKeyVersion response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.updateCryptoKeyVersion(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IUpdateCryptoKeyVersionRequest|undefined, - {}|undefined - ]) => { - this._log.info('updateCryptoKeyVersion response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .updateCryptoKeyVersion(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.kms.v1.ICryptoKeyVersion, + protos.google.cloud.kms.v1.IUpdateCryptoKeyVersionRequest | undefined, + {} | undefined, + ]) => { + this._log.info('updateCryptoKeyVersion response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 the version of a {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey} that - * will be used in - * {@link protos.google.cloud.kms.v1.KeyManagementService.Encrypt|Encrypt}. - * - * Returns an error if called on a key whose purpose is not - * {@link protos.google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.ENCRYPT_DECRYPT|ENCRYPT_DECRYPT}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the - * {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey} to update. - * @param {string} request.cryptoKeyVersionId - * Required. The id of the child - * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} to use as primary. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/key_management_service.update_crypto_key_primary_version.js - * region_tag:cloudkms_v1_generated_KeyManagementService_UpdateCryptoKeyPrimaryVersion_async - */ + /** + * Update the version of a {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey} that + * will be used in + * {@link protos.google.cloud.kms.v1.KeyManagementService.Encrypt|Encrypt}. + * + * Returns an error if called on a key whose purpose is not + * {@link protos.google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.ENCRYPT_DECRYPT|ENCRYPT_DECRYPT}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the + * {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey} to update. + * @param {string} request.cryptoKeyVersionId + * Required. The id of the child + * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} to use as primary. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/key_management_service.update_crypto_key_primary_version.js + * region_tag:cloudkms_v1_generated_KeyManagementService_UpdateCryptoKeyPrimaryVersion_async + */ updateCryptoKeyPrimaryVersion( - request?: protos.google.cloud.kms.v1.IUpdateCryptoKeyPrimaryVersionRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.kms.v1.ICryptoKey, - protos.google.cloud.kms.v1.IUpdateCryptoKeyPrimaryVersionRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.kms.v1.IUpdateCryptoKeyPrimaryVersionRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.kms.v1.ICryptoKey, + ( + | protos.google.cloud.kms.v1.IUpdateCryptoKeyPrimaryVersionRequest + | undefined + ), + {} | undefined, + ] + >; updateCryptoKeyPrimaryVersion( - request: protos.google.cloud.kms.v1.IUpdateCryptoKeyPrimaryVersionRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.kms.v1.ICryptoKey, - protos.google.cloud.kms.v1.IUpdateCryptoKeyPrimaryVersionRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IUpdateCryptoKeyPrimaryVersionRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.kms.v1.ICryptoKey, + | protos.google.cloud.kms.v1.IUpdateCryptoKeyPrimaryVersionRequest + | null + | undefined, + {} | null | undefined + >, + ): void; updateCryptoKeyPrimaryVersion( - request: protos.google.cloud.kms.v1.IUpdateCryptoKeyPrimaryVersionRequest, - callback: Callback< - protos.google.cloud.kms.v1.ICryptoKey, - protos.google.cloud.kms.v1.IUpdateCryptoKeyPrimaryVersionRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IUpdateCryptoKeyPrimaryVersionRequest, + callback: Callback< + protos.google.cloud.kms.v1.ICryptoKey, + | protos.google.cloud.kms.v1.IUpdateCryptoKeyPrimaryVersionRequest + | null + | undefined, + {} | null | undefined + >, + ): void; updateCryptoKeyPrimaryVersion( - request?: protos.google.cloud.kms.v1.IUpdateCryptoKeyPrimaryVersionRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.kms.v1.ICryptoKey, - protos.google.cloud.kms.v1.IUpdateCryptoKeyPrimaryVersionRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.kms.v1.IUpdateCryptoKeyPrimaryVersionRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.kms.v1.ICryptoKey, - protos.google.cloud.kms.v1.IUpdateCryptoKeyPrimaryVersionRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.kms.v1.ICryptoKey, - protos.google.cloud.kms.v1.IUpdateCryptoKeyPrimaryVersionRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.kms.v1.IUpdateCryptoKeyPrimaryVersionRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.kms.v1.ICryptoKey, + | protos.google.cloud.kms.v1.IUpdateCryptoKeyPrimaryVersionRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.kms.v1.ICryptoKey, + ( + | protos.google.cloud.kms.v1.IUpdateCryptoKeyPrimaryVersionRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('updateCryptoKeyPrimaryVersion request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.kms.v1.ICryptoKey, - protos.google.cloud.kms.v1.IUpdateCryptoKeyPrimaryVersionRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.kms.v1.ICryptoKey, + | protos.google.cloud.kms.v1.IUpdateCryptoKeyPrimaryVersionRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('updateCryptoKeyPrimaryVersion response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.updateCryptoKeyPrimaryVersion(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.kms.v1.ICryptoKey, - protos.google.cloud.kms.v1.IUpdateCryptoKeyPrimaryVersionRequest|undefined, - {}|undefined - ]) => { - this._log.info('updateCryptoKeyPrimaryVersion response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .updateCryptoKeyPrimaryVersion(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.kms.v1.ICryptoKey, + ( + | protos.google.cloud.kms.v1.IUpdateCryptoKeyPrimaryVersionRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('updateCryptoKeyPrimaryVersion response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Schedule a {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} for - * destruction. - * - * Upon calling this method, - * {@link protos.google.cloud.kms.v1.CryptoKeyVersion.state|CryptoKeyVersion.state} will - * be set to - * {@link protos.google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROY_SCHEDULED|DESTROY_SCHEDULED}, - * and {@link protos.google.cloud.kms.v1.CryptoKeyVersion.destroy_time|destroy_time} will - * be set to the time - * {@link protos.google.cloud.kms.v1.CryptoKey.destroy_scheduled_duration|destroy_scheduled_duration} - * in the future. At that time, the - * {@link protos.google.cloud.kms.v1.CryptoKeyVersion.state|state} will automatically - * change to - * {@link protos.google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROYED|DESTROYED}, - * and the key material will be irrevocably destroyed. - * - * Before the - * {@link protos.google.cloud.kms.v1.CryptoKeyVersion.destroy_time|destroy_time} is - * reached, - * {@link protos.google.cloud.kms.v1.KeyManagementService.RestoreCryptoKeyVersion|RestoreCryptoKeyVersion} - * may be called to reverse the process. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the - * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} to destroy. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/key_management_service.destroy_crypto_key_version.js - * region_tag:cloudkms_v1_generated_KeyManagementService_DestroyCryptoKeyVersion_async - */ + /** + * Schedule a {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} for + * destruction. + * + * Upon calling this method, + * {@link protos.google.cloud.kms.v1.CryptoKeyVersion.state|CryptoKeyVersion.state} will + * be set to + * {@link protos.google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROY_SCHEDULED|DESTROY_SCHEDULED}, + * and {@link protos.google.cloud.kms.v1.CryptoKeyVersion.destroy_time|destroy_time} will + * be set to the time + * {@link protos.google.cloud.kms.v1.CryptoKey.destroy_scheduled_duration|destroy_scheduled_duration} + * in the future. At that time, the + * {@link protos.google.cloud.kms.v1.CryptoKeyVersion.state|state} will automatically + * change to + * {@link protos.google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROYED|DESTROYED}, + * and the key material will be irrevocably destroyed. + * + * Before the + * {@link protos.google.cloud.kms.v1.CryptoKeyVersion.destroy_time|destroy_time} is + * reached, + * {@link protos.google.cloud.kms.v1.KeyManagementService.RestoreCryptoKeyVersion|RestoreCryptoKeyVersion} + * may be called to reverse the process. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the + * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} to destroy. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/key_management_service.destroy_crypto_key_version.js + * region_tag:cloudkms_v1_generated_KeyManagementService_DestroyCryptoKeyVersion_async + */ destroyCryptoKeyVersion( - request?: protos.google.cloud.kms.v1.IDestroyCryptoKeyVersionRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IDestroyCryptoKeyVersionRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.kms.v1.IDestroyCryptoKeyVersionRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.kms.v1.ICryptoKeyVersion, + protos.google.cloud.kms.v1.IDestroyCryptoKeyVersionRequest | undefined, + {} | undefined, + ] + >; destroyCryptoKeyVersion( - request: protos.google.cloud.kms.v1.IDestroyCryptoKeyVersionRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IDestroyCryptoKeyVersionRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IDestroyCryptoKeyVersionRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.kms.v1.ICryptoKeyVersion, + | protos.google.cloud.kms.v1.IDestroyCryptoKeyVersionRequest + | null + | undefined, + {} | null | undefined + >, + ): void; destroyCryptoKeyVersion( - request: protos.google.cloud.kms.v1.IDestroyCryptoKeyVersionRequest, - callback: Callback< - protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IDestroyCryptoKeyVersionRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IDestroyCryptoKeyVersionRequest, + callback: Callback< + protos.google.cloud.kms.v1.ICryptoKeyVersion, + | protos.google.cloud.kms.v1.IDestroyCryptoKeyVersionRequest + | null + | undefined, + {} | null | undefined + >, + ): void; destroyCryptoKeyVersion( - request?: protos.google.cloud.kms.v1.IDestroyCryptoKeyVersionRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IDestroyCryptoKeyVersionRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.kms.v1.IDestroyCryptoKeyVersionRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IDestroyCryptoKeyVersionRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IDestroyCryptoKeyVersionRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.kms.v1.IDestroyCryptoKeyVersionRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.kms.v1.ICryptoKeyVersion, + | protos.google.cloud.kms.v1.IDestroyCryptoKeyVersionRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.kms.v1.ICryptoKeyVersion, + protos.google.cloud.kms.v1.IDestroyCryptoKeyVersionRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('destroyCryptoKeyVersion request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IDestroyCryptoKeyVersionRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.kms.v1.ICryptoKeyVersion, + | protos.google.cloud.kms.v1.IDestroyCryptoKeyVersionRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('destroyCryptoKeyVersion response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.destroyCryptoKeyVersion(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IDestroyCryptoKeyVersionRequest|undefined, - {}|undefined - ]) => { - this._log.info('destroyCryptoKeyVersion response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .destroyCryptoKeyVersion(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.kms.v1.ICryptoKeyVersion, + ( + | protos.google.cloud.kms.v1.IDestroyCryptoKeyVersionRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('destroyCryptoKeyVersion response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Restore a {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} in the - * {@link protos.google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROY_SCHEDULED|DESTROY_SCHEDULED} - * state. - * - * Upon restoration of the CryptoKeyVersion, - * {@link protos.google.cloud.kms.v1.CryptoKeyVersion.state|state} will be set to - * {@link protos.google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DISABLED|DISABLED}, - * and {@link protos.google.cloud.kms.v1.CryptoKeyVersion.destroy_time|destroy_time} will - * be cleared. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the - * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} to restore. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/key_management_service.restore_crypto_key_version.js - * region_tag:cloudkms_v1_generated_KeyManagementService_RestoreCryptoKeyVersion_async - */ + /** + * Restore a {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} in the + * {@link protos.google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROY_SCHEDULED|DESTROY_SCHEDULED} + * state. + * + * Upon restoration of the CryptoKeyVersion, + * {@link protos.google.cloud.kms.v1.CryptoKeyVersion.state|state} will be set to + * {@link protos.google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DISABLED|DISABLED}, + * and {@link protos.google.cloud.kms.v1.CryptoKeyVersion.destroy_time|destroy_time} will + * be cleared. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the + * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} to restore. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/key_management_service.restore_crypto_key_version.js + * region_tag:cloudkms_v1_generated_KeyManagementService_RestoreCryptoKeyVersion_async + */ restoreCryptoKeyVersion( - request?: protos.google.cloud.kms.v1.IRestoreCryptoKeyVersionRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IRestoreCryptoKeyVersionRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.kms.v1.IRestoreCryptoKeyVersionRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.kms.v1.ICryptoKeyVersion, + protos.google.cloud.kms.v1.IRestoreCryptoKeyVersionRequest | undefined, + {} | undefined, + ] + >; restoreCryptoKeyVersion( - request: protos.google.cloud.kms.v1.IRestoreCryptoKeyVersionRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IRestoreCryptoKeyVersionRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IRestoreCryptoKeyVersionRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.kms.v1.ICryptoKeyVersion, + | protos.google.cloud.kms.v1.IRestoreCryptoKeyVersionRequest + | null + | undefined, + {} | null | undefined + >, + ): void; restoreCryptoKeyVersion( - request: protos.google.cloud.kms.v1.IRestoreCryptoKeyVersionRequest, - callback: Callback< - protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IRestoreCryptoKeyVersionRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IRestoreCryptoKeyVersionRequest, + callback: Callback< + protos.google.cloud.kms.v1.ICryptoKeyVersion, + | protos.google.cloud.kms.v1.IRestoreCryptoKeyVersionRequest + | null + | undefined, + {} | null | undefined + >, + ): void; restoreCryptoKeyVersion( - request?: protos.google.cloud.kms.v1.IRestoreCryptoKeyVersionRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IRestoreCryptoKeyVersionRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.kms.v1.IRestoreCryptoKeyVersionRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IRestoreCryptoKeyVersionRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IRestoreCryptoKeyVersionRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.kms.v1.IRestoreCryptoKeyVersionRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.kms.v1.ICryptoKeyVersion, + | protos.google.cloud.kms.v1.IRestoreCryptoKeyVersionRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.kms.v1.ICryptoKeyVersion, + protos.google.cloud.kms.v1.IRestoreCryptoKeyVersionRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('restoreCryptoKeyVersion request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IRestoreCryptoKeyVersionRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.kms.v1.ICryptoKeyVersion, + | protos.google.cloud.kms.v1.IRestoreCryptoKeyVersionRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('restoreCryptoKeyVersion response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.restoreCryptoKeyVersion(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IRestoreCryptoKeyVersionRequest|undefined, - {}|undefined - ]) => { - this._log.info('restoreCryptoKeyVersion response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .restoreCryptoKeyVersion(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.kms.v1.ICryptoKeyVersion, + ( + | protos.google.cloud.kms.v1.IRestoreCryptoKeyVersionRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('restoreCryptoKeyVersion response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Encrypts data, so that it can only be recovered by a call to - * {@link protos.google.cloud.kms.v1.KeyManagementService.Decrypt|Decrypt}. The - * {@link protos.google.cloud.kms.v1.CryptoKey.purpose|CryptoKey.purpose} must be - * {@link protos.google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.ENCRYPT_DECRYPT|ENCRYPT_DECRYPT}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the - * {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey} or - * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} to use for - * encryption. - * - * If a {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey} is specified, the server - * will use its {@link protos.google.cloud.kms.v1.CryptoKey.primary|primary version}. - * @param {Buffer} request.plaintext - * Required. The data to encrypt. Must be no larger than 64KiB. - * - * The maximum size depends on the key version's - * {@link protos.google.cloud.kms.v1.CryptoKeyVersionTemplate.protection_level|protection_level}. - * For {@link protos.google.cloud.kms.v1.ProtectionLevel.SOFTWARE|SOFTWARE}, - * {@link protos.google.cloud.kms.v1.ProtectionLevel.EXTERNAL|EXTERNAL}, and - * {@link protos.google.cloud.kms.v1.ProtectionLevel.EXTERNAL_VPC|EXTERNAL_VPC} keys, the - * plaintext must be no larger than 64KiB. For - * {@link protos.google.cloud.kms.v1.ProtectionLevel.HSM|HSM} keys, the combined length of - * the plaintext and additional_authenticated_data fields must be no larger - * than 8KiB. - * @param {Buffer} [request.additionalAuthenticatedData] - * Optional. Optional data that, if specified, must also be provided during - * decryption through - * {@link protos.google.cloud.kms.v1.DecryptRequest.additional_authenticated_data|DecryptRequest.additional_authenticated_data}. - * - * The maximum size depends on the key version's - * {@link protos.google.cloud.kms.v1.CryptoKeyVersionTemplate.protection_level|protection_level}. - * For {@link protos.google.cloud.kms.v1.ProtectionLevel.SOFTWARE|SOFTWARE}, - * {@link protos.google.cloud.kms.v1.ProtectionLevel.EXTERNAL|EXTERNAL}, and - * {@link protos.google.cloud.kms.v1.ProtectionLevel.EXTERNAL_VPC|EXTERNAL_VPC} keys the - * AAD must be no larger than 64KiB. For - * {@link protos.google.cloud.kms.v1.ProtectionLevel.HSM|HSM} keys, the combined length of - * the plaintext and additional_authenticated_data fields must be no larger - * than 8KiB. - * @param {google.protobuf.Int64Value} [request.plaintextCrc32c] - * Optional. An optional CRC32C checksum of the - * {@link protos.google.cloud.kms.v1.EncryptRequest.plaintext|EncryptRequest.plaintext}. - * If specified, - * {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} will - * verify the integrity of the received - * {@link protos.google.cloud.kms.v1.EncryptRequest.plaintext|EncryptRequest.plaintext} - * using this checksum. - * {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} will - * report an error if the checksum verification fails. If you receive a - * checksum error, your client should verify that - * CRC32C({@link protos.google.cloud.kms.v1.EncryptRequest.plaintext|EncryptRequest.plaintext}) - * is equal to - * {@link protos.google.cloud.kms.v1.EncryptRequest.plaintext_crc32c|EncryptRequest.plaintext_crc32c}, - * and if so, perform a limited number of retries. A persistent mismatch may - * indicate an issue in your computation of the CRC32C checksum. Note: This - * field is defined as int64 for reasons of compatibility across different - * languages. However, it is a non-negative integer, which will never exceed - * 2^32-1, and can be safely downconverted to uint32 in languages that support - * this type. - * @param {google.protobuf.Int64Value} [request.additionalAuthenticatedDataCrc32c] - * Optional. An optional CRC32C checksum of the - * {@link protos.google.cloud.kms.v1.EncryptRequest.additional_authenticated_data|EncryptRequest.additional_authenticated_data}. - * If specified, - * {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} will - * verify the integrity of the received - * {@link protos.google.cloud.kms.v1.EncryptRequest.additional_authenticated_data|EncryptRequest.additional_authenticated_data} - * using this checksum. - * {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} will - * report an error if the checksum verification fails. If you receive a - * checksum error, your client should verify that - * CRC32C({@link protos.google.cloud.kms.v1.EncryptRequest.additional_authenticated_data|EncryptRequest.additional_authenticated_data}) - * is equal to - * {@link protos.google.cloud.kms.v1.EncryptRequest.additional_authenticated_data_crc32c|EncryptRequest.additional_authenticated_data_crc32c}, - * and if so, perform a limited number of retries. A persistent mismatch may - * indicate an issue in your computation of the CRC32C checksum. Note: This - * field is defined as int64 for reasons of compatibility across different - * languages. However, it is a non-negative integer, which will never exceed - * 2^32-1, and can be safely downconverted to uint32 in languages that support - * this type. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.kms.v1.EncryptResponse|EncryptResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/key_management_service.encrypt.js - * region_tag:cloudkms_v1_generated_KeyManagementService_Encrypt_async - */ + /** + * Encrypts data, so that it can only be recovered by a call to + * {@link protos.google.cloud.kms.v1.KeyManagementService.Decrypt|Decrypt}. The + * {@link protos.google.cloud.kms.v1.CryptoKey.purpose|CryptoKey.purpose} must be + * {@link protos.google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.ENCRYPT_DECRYPT|ENCRYPT_DECRYPT}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the + * {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey} or + * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} to use for + * encryption. + * + * If a {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey} is specified, the server + * will use its {@link protos.google.cloud.kms.v1.CryptoKey.primary|primary version}. + * @param {Buffer} request.plaintext + * Required. The data to encrypt. Must be no larger than 64KiB. + * + * The maximum size depends on the key version's + * {@link protos.google.cloud.kms.v1.CryptoKeyVersionTemplate.protection_level|protection_level}. + * For {@link protos.google.cloud.kms.v1.ProtectionLevel.SOFTWARE|SOFTWARE}, + * {@link protos.google.cloud.kms.v1.ProtectionLevel.EXTERNAL|EXTERNAL}, and + * {@link protos.google.cloud.kms.v1.ProtectionLevel.EXTERNAL_VPC|EXTERNAL_VPC} keys, the + * plaintext must be no larger than 64KiB. For + * {@link protos.google.cloud.kms.v1.ProtectionLevel.HSM|HSM} keys, the combined length of + * the plaintext and additional_authenticated_data fields must be no larger + * than 8KiB. + * @param {Buffer} [request.additionalAuthenticatedData] + * Optional. Optional data that, if specified, must also be provided during + * decryption through + * {@link protos.google.cloud.kms.v1.DecryptRequest.additional_authenticated_data|DecryptRequest.additional_authenticated_data}. + * + * The maximum size depends on the key version's + * {@link protos.google.cloud.kms.v1.CryptoKeyVersionTemplate.protection_level|protection_level}. + * For {@link protos.google.cloud.kms.v1.ProtectionLevel.SOFTWARE|SOFTWARE}, + * {@link protos.google.cloud.kms.v1.ProtectionLevel.EXTERNAL|EXTERNAL}, and + * {@link protos.google.cloud.kms.v1.ProtectionLevel.EXTERNAL_VPC|EXTERNAL_VPC} keys the + * AAD must be no larger than 64KiB. For + * {@link protos.google.cloud.kms.v1.ProtectionLevel.HSM|HSM} keys, the combined length of + * the plaintext and additional_authenticated_data fields must be no larger + * than 8KiB. + * @param {google.protobuf.Int64Value} [request.plaintextCrc32c] + * Optional. An optional CRC32C checksum of the + * {@link protos.google.cloud.kms.v1.EncryptRequest.plaintext|EncryptRequest.plaintext}. + * If specified, + * {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} will + * verify the integrity of the received + * {@link protos.google.cloud.kms.v1.EncryptRequest.plaintext|EncryptRequest.plaintext} + * using this checksum. + * {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} will + * report an error if the checksum verification fails. If you receive a + * checksum error, your client should verify that + * CRC32C({@link protos.google.cloud.kms.v1.EncryptRequest.plaintext|EncryptRequest.plaintext}) + * is equal to + * {@link protos.google.cloud.kms.v1.EncryptRequest.plaintext_crc32c|EncryptRequest.plaintext_crc32c}, + * and if so, perform a limited number of retries. A persistent mismatch may + * indicate an issue in your computation of the CRC32C checksum. Note: This + * field is defined as int64 for reasons of compatibility across different + * languages. However, it is a non-negative integer, which will never exceed + * 2^32-1, and can be safely downconverted to uint32 in languages that support + * this type. + * @param {google.protobuf.Int64Value} [request.additionalAuthenticatedDataCrc32c] + * Optional. An optional CRC32C checksum of the + * {@link protos.google.cloud.kms.v1.EncryptRequest.additional_authenticated_data|EncryptRequest.additional_authenticated_data}. + * If specified, + * {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} will + * verify the integrity of the received + * {@link protos.google.cloud.kms.v1.EncryptRequest.additional_authenticated_data|EncryptRequest.additional_authenticated_data} + * using this checksum. + * {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} will + * report an error if the checksum verification fails. If you receive a + * checksum error, your client should verify that + * CRC32C({@link protos.google.cloud.kms.v1.EncryptRequest.additional_authenticated_data|EncryptRequest.additional_authenticated_data}) + * is equal to + * {@link protos.google.cloud.kms.v1.EncryptRequest.additional_authenticated_data_crc32c|EncryptRequest.additional_authenticated_data_crc32c}, + * and if so, perform a limited number of retries. A persistent mismatch may + * indicate an issue in your computation of the CRC32C checksum. Note: This + * field is defined as int64 for reasons of compatibility across different + * languages. However, it is a non-negative integer, which will never exceed + * 2^32-1, and can be safely downconverted to uint32 in languages that support + * this type. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.kms.v1.EncryptResponse|EncryptResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/key_management_service.encrypt.js + * region_tag:cloudkms_v1_generated_KeyManagementService_Encrypt_async + */ encrypt( - request?: protos.google.cloud.kms.v1.IEncryptRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.kms.v1.IEncryptResponse, - protos.google.cloud.kms.v1.IEncryptRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.kms.v1.IEncryptRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.kms.v1.IEncryptResponse, + protos.google.cloud.kms.v1.IEncryptRequest | undefined, + {} | undefined, + ] + >; encrypt( - request: protos.google.cloud.kms.v1.IEncryptRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.kms.v1.IEncryptResponse, - protos.google.cloud.kms.v1.IEncryptRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IEncryptRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.kms.v1.IEncryptResponse, + protos.google.cloud.kms.v1.IEncryptRequest | null | undefined, + {} | null | undefined + >, + ): void; encrypt( - request: protos.google.cloud.kms.v1.IEncryptRequest, - callback: Callback< - protos.google.cloud.kms.v1.IEncryptResponse, - protos.google.cloud.kms.v1.IEncryptRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IEncryptRequest, + callback: Callback< + protos.google.cloud.kms.v1.IEncryptResponse, + protos.google.cloud.kms.v1.IEncryptRequest | null | undefined, + {} | null | undefined + >, + ): void; encrypt( - request?: protos.google.cloud.kms.v1.IEncryptRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.kms.v1.IEncryptResponse, - protos.google.cloud.kms.v1.IEncryptRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.kms.v1.IEncryptRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.kms.v1.IEncryptResponse, - protos.google.cloud.kms.v1.IEncryptRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.kms.v1.IEncryptResponse, - protos.google.cloud.kms.v1.IEncryptRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.kms.v1.IEncryptRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.kms.v1.IEncryptResponse, + protos.google.cloud.kms.v1.IEncryptRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.kms.v1.IEncryptResponse, + protos.google.cloud.kms.v1.IEncryptRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('encrypt request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.kms.v1.IEncryptResponse, - protos.google.cloud.kms.v1.IEncryptRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.kms.v1.IEncryptResponse, + protos.google.cloud.kms.v1.IEncryptRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('encrypt response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.encrypt(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.kms.v1.IEncryptResponse, - protos.google.cloud.kms.v1.IEncryptRequest|undefined, - {}|undefined - ]) => { - this._log.info('encrypt response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .encrypt(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.kms.v1.IEncryptResponse, + protos.google.cloud.kms.v1.IEncryptRequest | undefined, + {} | undefined, + ]) => { + this._log.info('encrypt response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Decrypts data that was protected by - * {@link protos.google.cloud.kms.v1.KeyManagementService.Encrypt|Encrypt}. The - * {@link protos.google.cloud.kms.v1.CryptoKey.purpose|CryptoKey.purpose} must be - * {@link protos.google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.ENCRYPT_DECRYPT|ENCRYPT_DECRYPT}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the - * {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey} to use for decryption. The - * server will choose the appropriate version. - * @param {Buffer} request.ciphertext - * Required. The encrypted data originally returned in - * {@link protos.google.cloud.kms.v1.EncryptResponse.ciphertext|EncryptResponse.ciphertext}. - * @param {Buffer} [request.additionalAuthenticatedData] - * Optional. Optional data that must match the data originally supplied in - * {@link protos.google.cloud.kms.v1.EncryptRequest.additional_authenticated_data|EncryptRequest.additional_authenticated_data}. - * @param {google.protobuf.Int64Value} [request.ciphertextCrc32c] - * Optional. An optional CRC32C checksum of the - * {@link protos.google.cloud.kms.v1.DecryptRequest.ciphertext|DecryptRequest.ciphertext}. - * If specified, - * {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} will - * verify the integrity of the received - * {@link protos.google.cloud.kms.v1.DecryptRequest.ciphertext|DecryptRequest.ciphertext} - * using this checksum. - * {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} will - * report an error if the checksum verification fails. If you receive a - * checksum error, your client should verify that - * CRC32C({@link protos.google.cloud.kms.v1.DecryptRequest.ciphertext|DecryptRequest.ciphertext}) - * is equal to - * {@link protos.google.cloud.kms.v1.DecryptRequest.ciphertext_crc32c|DecryptRequest.ciphertext_crc32c}, - * and if so, perform a limited number of retries. A persistent mismatch may - * indicate an issue in your computation of the CRC32C checksum. Note: This - * field is defined as int64 for reasons of compatibility across different - * languages. However, it is a non-negative integer, which will never exceed - * 2^32-1, and can be safely downconverted to uint32 in languages that support - * this type. - * @param {google.protobuf.Int64Value} [request.additionalAuthenticatedDataCrc32c] - * Optional. An optional CRC32C checksum of the - * {@link protos.google.cloud.kms.v1.DecryptRequest.additional_authenticated_data|DecryptRequest.additional_authenticated_data}. - * If specified, - * {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} will - * verify the integrity of the received - * {@link protos.google.cloud.kms.v1.DecryptRequest.additional_authenticated_data|DecryptRequest.additional_authenticated_data} - * using this checksum. - * {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} will - * report an error if the checksum verification fails. If you receive a - * checksum error, your client should verify that - * CRC32C({@link protos.google.cloud.kms.v1.DecryptRequest.additional_authenticated_data|DecryptRequest.additional_authenticated_data}) - * is equal to - * {@link protos.google.cloud.kms.v1.DecryptRequest.additional_authenticated_data_crc32c|DecryptRequest.additional_authenticated_data_crc32c}, - * and if so, perform a limited number of retries. A persistent mismatch may - * indicate an issue in your computation of the CRC32C checksum. Note: This - * field is defined as int64 for reasons of compatibility across different - * languages. However, it is a non-negative integer, which will never exceed - * 2^32-1, and can be safely downconverted to uint32 in languages that support - * this type. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.kms.v1.DecryptResponse|DecryptResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/key_management_service.decrypt.js - * region_tag:cloudkms_v1_generated_KeyManagementService_Decrypt_async - */ + /** + * Decrypts data that was protected by + * {@link protos.google.cloud.kms.v1.KeyManagementService.Encrypt|Encrypt}. The + * {@link protos.google.cloud.kms.v1.CryptoKey.purpose|CryptoKey.purpose} must be + * {@link protos.google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.ENCRYPT_DECRYPT|ENCRYPT_DECRYPT}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the + * {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey} to use for decryption. The + * server will choose the appropriate version. + * @param {Buffer} request.ciphertext + * Required. The encrypted data originally returned in + * {@link protos.google.cloud.kms.v1.EncryptResponse.ciphertext|EncryptResponse.ciphertext}. + * @param {Buffer} [request.additionalAuthenticatedData] + * Optional. Optional data that must match the data originally supplied in + * {@link protos.google.cloud.kms.v1.EncryptRequest.additional_authenticated_data|EncryptRequest.additional_authenticated_data}. + * @param {google.protobuf.Int64Value} [request.ciphertextCrc32c] + * Optional. An optional CRC32C checksum of the + * {@link protos.google.cloud.kms.v1.DecryptRequest.ciphertext|DecryptRequest.ciphertext}. + * If specified, + * {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} will + * verify the integrity of the received + * {@link protos.google.cloud.kms.v1.DecryptRequest.ciphertext|DecryptRequest.ciphertext} + * using this checksum. + * {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} will + * report an error if the checksum verification fails. If you receive a + * checksum error, your client should verify that + * CRC32C({@link protos.google.cloud.kms.v1.DecryptRequest.ciphertext|DecryptRequest.ciphertext}) + * is equal to + * {@link protos.google.cloud.kms.v1.DecryptRequest.ciphertext_crc32c|DecryptRequest.ciphertext_crc32c}, + * and if so, perform a limited number of retries. A persistent mismatch may + * indicate an issue in your computation of the CRC32C checksum. Note: This + * field is defined as int64 for reasons of compatibility across different + * languages. However, it is a non-negative integer, which will never exceed + * 2^32-1, and can be safely downconverted to uint32 in languages that support + * this type. + * @param {google.protobuf.Int64Value} [request.additionalAuthenticatedDataCrc32c] + * Optional. An optional CRC32C checksum of the + * {@link protos.google.cloud.kms.v1.DecryptRequest.additional_authenticated_data|DecryptRequest.additional_authenticated_data}. + * If specified, + * {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} will + * verify the integrity of the received + * {@link protos.google.cloud.kms.v1.DecryptRequest.additional_authenticated_data|DecryptRequest.additional_authenticated_data} + * using this checksum. + * {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} will + * report an error if the checksum verification fails. If you receive a + * checksum error, your client should verify that + * CRC32C({@link protos.google.cloud.kms.v1.DecryptRequest.additional_authenticated_data|DecryptRequest.additional_authenticated_data}) + * is equal to + * {@link protos.google.cloud.kms.v1.DecryptRequest.additional_authenticated_data_crc32c|DecryptRequest.additional_authenticated_data_crc32c}, + * and if so, perform a limited number of retries. A persistent mismatch may + * indicate an issue in your computation of the CRC32C checksum. Note: This + * field is defined as int64 for reasons of compatibility across different + * languages. However, it is a non-negative integer, which will never exceed + * 2^32-1, and can be safely downconverted to uint32 in languages that support + * this type. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.kms.v1.DecryptResponse|DecryptResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/key_management_service.decrypt.js + * region_tag:cloudkms_v1_generated_KeyManagementService_Decrypt_async + */ decrypt( - request?: protos.google.cloud.kms.v1.IDecryptRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.kms.v1.IDecryptResponse, - protos.google.cloud.kms.v1.IDecryptRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.kms.v1.IDecryptRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.kms.v1.IDecryptResponse, + protos.google.cloud.kms.v1.IDecryptRequest | undefined, + {} | undefined, + ] + >; decrypt( - request: protos.google.cloud.kms.v1.IDecryptRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.kms.v1.IDecryptResponse, - protos.google.cloud.kms.v1.IDecryptRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IDecryptRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.kms.v1.IDecryptResponse, + protos.google.cloud.kms.v1.IDecryptRequest | null | undefined, + {} | null | undefined + >, + ): void; decrypt( - request: protos.google.cloud.kms.v1.IDecryptRequest, - callback: Callback< - protos.google.cloud.kms.v1.IDecryptResponse, - protos.google.cloud.kms.v1.IDecryptRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IDecryptRequest, + callback: Callback< + protos.google.cloud.kms.v1.IDecryptResponse, + protos.google.cloud.kms.v1.IDecryptRequest | null | undefined, + {} | null | undefined + >, + ): void; decrypt( - request?: protos.google.cloud.kms.v1.IDecryptRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.kms.v1.IDecryptResponse, - protos.google.cloud.kms.v1.IDecryptRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.kms.v1.IDecryptRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.kms.v1.IDecryptResponse, - protos.google.cloud.kms.v1.IDecryptRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.kms.v1.IDecryptResponse, - protos.google.cloud.kms.v1.IDecryptRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.kms.v1.IDecryptRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.kms.v1.IDecryptResponse, + protos.google.cloud.kms.v1.IDecryptRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.kms.v1.IDecryptResponse, + protos.google.cloud.kms.v1.IDecryptRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('decrypt request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.kms.v1.IDecryptResponse, - protos.google.cloud.kms.v1.IDecryptRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.kms.v1.IDecryptResponse, + protos.google.cloud.kms.v1.IDecryptRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('decrypt response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.decrypt(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.kms.v1.IDecryptResponse, - protos.google.cloud.kms.v1.IDecryptRequest|undefined, - {}|undefined - ]) => { - this._log.info('decrypt response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .decrypt(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.kms.v1.IDecryptResponse, + protos.google.cloud.kms.v1.IDecryptRequest | undefined, + {} | undefined, + ]) => { + this._log.info('decrypt response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Encrypts data using portable cryptographic primitives. Most users should - * choose {@link protos.google.cloud.kms.v1.KeyManagementService.Encrypt|Encrypt} and - * {@link protos.google.cloud.kms.v1.KeyManagementService.Decrypt|Decrypt} rather than - * their raw counterparts. The - * {@link protos.google.cloud.kms.v1.CryptoKey.purpose|CryptoKey.purpose} must be - * {@link protos.google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.RAW_ENCRYPT_DECRYPT|RAW_ENCRYPT_DECRYPT}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the - * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} to use for - * encryption. - * @param {Buffer} request.plaintext - * Required. The data to encrypt. Must be no larger than 64KiB. - * - * The maximum size depends on the key version's - * {@link protos.google.cloud.kms.v1.CryptoKeyVersionTemplate.protection_level|protection_level}. - * For {@link protos.google.cloud.kms.v1.ProtectionLevel.SOFTWARE|SOFTWARE} keys, the - * plaintext must be no larger than 64KiB. For - * {@link protos.google.cloud.kms.v1.ProtectionLevel.HSM|HSM} keys, the combined length of - * the plaintext and additional_authenticated_data fields must be no larger - * than 8KiB. - * @param {Buffer} [request.additionalAuthenticatedData] - * Optional. Optional data that, if specified, must also be provided during - * decryption through - * {@link protos.google.cloud.kms.v1.RawDecryptRequest.additional_authenticated_data|RawDecryptRequest.additional_authenticated_data}. - * - * This field may only be used in conjunction with an - * {@link protos.google.cloud.kms.v1.CryptoKeyVersion.algorithm|algorithm} that accepts - * additional authenticated data (for example, AES-GCM). - * - * The maximum size depends on the key version's - * {@link protos.google.cloud.kms.v1.CryptoKeyVersionTemplate.protection_level|protection_level}. - * For {@link protos.google.cloud.kms.v1.ProtectionLevel.SOFTWARE|SOFTWARE} keys, the - * plaintext must be no larger than 64KiB. For - * {@link protos.google.cloud.kms.v1.ProtectionLevel.HSM|HSM} keys, the combined length of - * the plaintext and additional_authenticated_data fields must be no larger - * than 8KiB. - * @param {google.protobuf.Int64Value} [request.plaintextCrc32c] - * Optional. An optional CRC32C checksum of the - * {@link protos.google.cloud.kms.v1.RawEncryptRequest.plaintext|RawEncryptRequest.plaintext}. - * If specified, - * {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} will - * verify the integrity of the received plaintext using this checksum. - * {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} will - * report an error if the checksum verification fails. If you receive a - * checksum error, your client should verify that CRC32C(plaintext) is equal - * to plaintext_crc32c, and if so, perform a limited number of retries. A - * persistent mismatch may indicate an issue in your computation of the CRC32C - * checksum. Note: This field is defined as int64 for reasons of compatibility - * across different languages. However, it is a non-negative integer, which - * will never exceed 2^32-1, and can be safely downconverted to uint32 in - * languages that support this type. - * @param {google.protobuf.Int64Value} [request.additionalAuthenticatedDataCrc32c] - * Optional. An optional CRC32C checksum of the - * {@link protos.google.cloud.kms.v1.RawEncryptRequest.additional_authenticated_data|RawEncryptRequest.additional_authenticated_data}. - * If specified, - * {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} will - * verify the integrity of the received additional_authenticated_data using - * this checksum. - * {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} will - * report an error if the checksum verification fails. If you receive a - * checksum error, your client should verify that - * CRC32C(additional_authenticated_data) is equal to - * additional_authenticated_data_crc32c, and if so, perform - * a limited number of retries. A persistent mismatch may indicate an issue in - * your computation of the CRC32C checksum. - * Note: This field is defined as int64 for reasons of compatibility across - * different languages. However, it is a non-negative integer, which will - * never exceed 2^32-1, and can be safely downconverted to uint32 in languages - * that support this type. - * @param {Buffer} [request.initializationVector] - * Optional. A customer-supplied initialization vector that will be used for - * encryption. If it is not provided for AES-CBC and AES-CTR, one will be - * generated. It will be returned in - * {@link protos.google.cloud.kms.v1.RawEncryptResponse.initialization_vector|RawEncryptResponse.initialization_vector}. - * @param {google.protobuf.Int64Value} [request.initializationVectorCrc32c] - * Optional. An optional CRC32C checksum of the - * {@link protos.google.cloud.kms.v1.RawEncryptRequest.initialization_vector|RawEncryptRequest.initialization_vector}. - * If specified, - * {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} will - * verify the integrity of the received initialization_vector using this - * checksum. {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} - * will report an error if the checksum verification fails. If you receive a - * checksum error, your client should verify that - * CRC32C(initialization_vector) is equal to - * initialization_vector_crc32c, and if so, perform - * a limited number of retries. A persistent mismatch may indicate an issue in - * your computation of the CRC32C checksum. - * Note: This field is defined as int64 for reasons of compatibility across - * different languages. However, it is a non-negative integer, which will - * never exceed 2^32-1, and can be safely downconverted to uint32 in languages - * that support this type. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.kms.v1.RawEncryptResponse|RawEncryptResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/key_management_service.raw_encrypt.js - * region_tag:cloudkms_v1_generated_KeyManagementService_RawEncrypt_async - */ + /** + * Encrypts data using portable cryptographic primitives. Most users should + * choose {@link protos.google.cloud.kms.v1.KeyManagementService.Encrypt|Encrypt} and + * {@link protos.google.cloud.kms.v1.KeyManagementService.Decrypt|Decrypt} rather than + * their raw counterparts. The + * {@link protos.google.cloud.kms.v1.CryptoKey.purpose|CryptoKey.purpose} must be + * {@link protos.google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.RAW_ENCRYPT_DECRYPT|RAW_ENCRYPT_DECRYPT}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the + * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} to use for + * encryption. + * @param {Buffer} request.plaintext + * Required. The data to encrypt. Must be no larger than 64KiB. + * + * The maximum size depends on the key version's + * {@link protos.google.cloud.kms.v1.CryptoKeyVersionTemplate.protection_level|protection_level}. + * For {@link protos.google.cloud.kms.v1.ProtectionLevel.SOFTWARE|SOFTWARE} keys, the + * plaintext must be no larger than 64KiB. For + * {@link protos.google.cloud.kms.v1.ProtectionLevel.HSM|HSM} keys, the combined length of + * the plaintext and additional_authenticated_data fields must be no larger + * than 8KiB. + * @param {Buffer} [request.additionalAuthenticatedData] + * Optional. Optional data that, if specified, must also be provided during + * decryption through + * {@link protos.google.cloud.kms.v1.RawDecryptRequest.additional_authenticated_data|RawDecryptRequest.additional_authenticated_data}. + * + * This field may only be used in conjunction with an + * {@link protos.google.cloud.kms.v1.CryptoKeyVersion.algorithm|algorithm} that accepts + * additional authenticated data (for example, AES-GCM). + * + * The maximum size depends on the key version's + * {@link protos.google.cloud.kms.v1.CryptoKeyVersionTemplate.protection_level|protection_level}. + * For {@link protos.google.cloud.kms.v1.ProtectionLevel.SOFTWARE|SOFTWARE} keys, the + * plaintext must be no larger than 64KiB. For + * {@link protos.google.cloud.kms.v1.ProtectionLevel.HSM|HSM} keys, the combined length of + * the plaintext and additional_authenticated_data fields must be no larger + * than 8KiB. + * @param {google.protobuf.Int64Value} [request.plaintextCrc32c] + * Optional. An optional CRC32C checksum of the + * {@link protos.google.cloud.kms.v1.RawEncryptRequest.plaintext|RawEncryptRequest.plaintext}. + * If specified, + * {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} will + * verify the integrity of the received plaintext using this checksum. + * {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} will + * report an error if the checksum verification fails. If you receive a + * checksum error, your client should verify that CRC32C(plaintext) is equal + * to plaintext_crc32c, and if so, perform a limited number of retries. A + * persistent mismatch may indicate an issue in your computation of the CRC32C + * checksum. Note: This field is defined as int64 for reasons of compatibility + * across different languages. However, it is a non-negative integer, which + * will never exceed 2^32-1, and can be safely downconverted to uint32 in + * languages that support this type. + * @param {google.protobuf.Int64Value} [request.additionalAuthenticatedDataCrc32c] + * Optional. An optional CRC32C checksum of the + * {@link protos.google.cloud.kms.v1.RawEncryptRequest.additional_authenticated_data|RawEncryptRequest.additional_authenticated_data}. + * If specified, + * {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} will + * verify the integrity of the received additional_authenticated_data using + * this checksum. + * {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} will + * report an error if the checksum verification fails. If you receive a + * checksum error, your client should verify that + * CRC32C(additional_authenticated_data) is equal to + * additional_authenticated_data_crc32c, and if so, perform + * a limited number of retries. A persistent mismatch may indicate an issue in + * your computation of the CRC32C checksum. + * Note: This field is defined as int64 for reasons of compatibility across + * different languages. However, it is a non-negative integer, which will + * never exceed 2^32-1, and can be safely downconverted to uint32 in languages + * that support this type. + * @param {Buffer} [request.initializationVector] + * Optional. A customer-supplied initialization vector that will be used for + * encryption. If it is not provided for AES-CBC and AES-CTR, one will be + * generated. It will be returned in + * {@link protos.google.cloud.kms.v1.RawEncryptResponse.initialization_vector|RawEncryptResponse.initialization_vector}. + * @param {google.protobuf.Int64Value} [request.initializationVectorCrc32c] + * Optional. An optional CRC32C checksum of the + * {@link protos.google.cloud.kms.v1.RawEncryptRequest.initialization_vector|RawEncryptRequest.initialization_vector}. + * If specified, + * {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} will + * verify the integrity of the received initialization_vector using this + * checksum. {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} + * will report an error if the checksum verification fails. If you receive a + * checksum error, your client should verify that + * CRC32C(initialization_vector) is equal to + * initialization_vector_crc32c, and if so, perform + * a limited number of retries. A persistent mismatch may indicate an issue in + * your computation of the CRC32C checksum. + * Note: This field is defined as int64 for reasons of compatibility across + * different languages. However, it is a non-negative integer, which will + * never exceed 2^32-1, and can be safely downconverted to uint32 in languages + * that support this type. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.kms.v1.RawEncryptResponse|RawEncryptResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/key_management_service.raw_encrypt.js + * region_tag:cloudkms_v1_generated_KeyManagementService_RawEncrypt_async + */ rawEncrypt( - request?: protos.google.cloud.kms.v1.IRawEncryptRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.kms.v1.IRawEncryptResponse, - protos.google.cloud.kms.v1.IRawEncryptRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.kms.v1.IRawEncryptRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.kms.v1.IRawEncryptResponse, + protos.google.cloud.kms.v1.IRawEncryptRequest | undefined, + {} | undefined, + ] + >; rawEncrypt( - request: protos.google.cloud.kms.v1.IRawEncryptRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.kms.v1.IRawEncryptResponse, - protos.google.cloud.kms.v1.IRawEncryptRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IRawEncryptRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.kms.v1.IRawEncryptResponse, + protos.google.cloud.kms.v1.IRawEncryptRequest | null | undefined, + {} | null | undefined + >, + ): void; rawEncrypt( - request: protos.google.cloud.kms.v1.IRawEncryptRequest, - callback: Callback< - protos.google.cloud.kms.v1.IRawEncryptResponse, - protos.google.cloud.kms.v1.IRawEncryptRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IRawEncryptRequest, + callback: Callback< + protos.google.cloud.kms.v1.IRawEncryptResponse, + protos.google.cloud.kms.v1.IRawEncryptRequest | null | undefined, + {} | null | undefined + >, + ): void; rawEncrypt( - request?: protos.google.cloud.kms.v1.IRawEncryptRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.kms.v1.IRawEncryptResponse, - protos.google.cloud.kms.v1.IRawEncryptRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.kms.v1.IRawEncryptRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.kms.v1.IRawEncryptResponse, - protos.google.cloud.kms.v1.IRawEncryptRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.kms.v1.IRawEncryptResponse, - protos.google.cloud.kms.v1.IRawEncryptRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.kms.v1.IRawEncryptRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.kms.v1.IRawEncryptResponse, + protos.google.cloud.kms.v1.IRawEncryptRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.kms.v1.IRawEncryptResponse, + protos.google.cloud.kms.v1.IRawEncryptRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('rawEncrypt request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.kms.v1.IRawEncryptResponse, - protos.google.cloud.kms.v1.IRawEncryptRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.kms.v1.IRawEncryptResponse, + protos.google.cloud.kms.v1.IRawEncryptRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('rawEncrypt response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.rawEncrypt(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.kms.v1.IRawEncryptResponse, - protos.google.cloud.kms.v1.IRawEncryptRequest|undefined, - {}|undefined - ]) => { - this._log.info('rawEncrypt response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .rawEncrypt(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.kms.v1.IRawEncryptResponse, + protos.google.cloud.kms.v1.IRawEncryptRequest | undefined, + {} | undefined, + ]) => { + this._log.info('rawEncrypt response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Decrypts data that was originally encrypted using a raw cryptographic - * mechanism. The {@link protos.google.cloud.kms.v1.CryptoKey.purpose|CryptoKey.purpose} - * must be - * {@link protos.google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.RAW_ENCRYPT_DECRYPT|RAW_ENCRYPT_DECRYPT}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the - * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} to use for - * decryption. - * @param {Buffer} request.ciphertext - * Required. The encrypted data originally returned in - * {@link protos.google.cloud.kms.v1.RawEncryptResponse.ciphertext|RawEncryptResponse.ciphertext}. - * @param {Buffer} [request.additionalAuthenticatedData] - * Optional. Optional data that must match the data originally supplied in - * {@link protos.google.cloud.kms.v1.RawEncryptRequest.additional_authenticated_data|RawEncryptRequest.additional_authenticated_data}. - * @param {Buffer} request.initializationVector - * Required. The initialization vector (IV) used during encryption, which must - * match the data originally provided in - * {@link protos.google.cloud.kms.v1.RawEncryptResponse.initialization_vector|RawEncryptResponse.initialization_vector}. - * @param {number} request.tagLength - * The length of the authentication tag that is appended to the end of - * the ciphertext. If unspecified (0), the default value for the key's - * algorithm will be used (for AES-GCM, the default value is 16). - * @param {google.protobuf.Int64Value} [request.ciphertextCrc32c] - * Optional. An optional CRC32C checksum of the - * {@link protos.google.cloud.kms.v1.RawDecryptRequest.ciphertext|RawDecryptRequest.ciphertext}. - * If specified, - * {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} will - * verify the integrity of the received ciphertext using this checksum. - * {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} will - * report an error if the checksum verification fails. If you receive a - * checksum error, your client should verify that CRC32C(ciphertext) is equal - * to ciphertext_crc32c, and if so, perform a limited number of retries. A - * persistent mismatch may indicate an issue in your computation of the CRC32C - * checksum. Note: This field is defined as int64 for reasons of compatibility - * across different languages. However, it is a non-negative integer, which - * will never exceed 2^32-1, and can be safely downconverted to uint32 in - * languages that support this type. - * @param {google.protobuf.Int64Value} [request.additionalAuthenticatedDataCrc32c] - * Optional. An optional CRC32C checksum of the - * {@link protos.google.cloud.kms.v1.RawDecryptRequest.additional_authenticated_data|RawDecryptRequest.additional_authenticated_data}. - * If specified, - * {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} will - * verify the integrity of the received additional_authenticated_data using - * this checksum. - * {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} will - * report an error if the checksum verification fails. If you receive a - * checksum error, your client should verify that - * CRC32C(additional_authenticated_data) is equal to - * additional_authenticated_data_crc32c, and if so, perform - * a limited number of retries. A persistent mismatch may indicate an issue in - * your computation of the CRC32C checksum. - * Note: This field is defined as int64 for reasons of compatibility across - * different languages. However, it is a non-negative integer, which will - * never exceed 2^32-1, and can be safely downconverted to uint32 in languages - * that support this type. - * @param {google.protobuf.Int64Value} [request.initializationVectorCrc32c] - * Optional. An optional CRC32C checksum of the - * {@link protos.google.cloud.kms.v1.RawDecryptRequest.initialization_vector|RawDecryptRequest.initialization_vector}. - * If specified, - * {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} will - * verify the integrity of the received initialization_vector using this - * checksum. {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} - * will report an error if the checksum verification fails. If you receive a - * checksum error, your client should verify that - * CRC32C(initialization_vector) is equal to initialization_vector_crc32c, and - * if so, perform a limited number of retries. A persistent mismatch may - * indicate an issue in your computation of the CRC32C checksum. - * Note: This field is defined as int64 for reasons of compatibility across - * different languages. However, it is a non-negative integer, which will - * never exceed 2^32-1, and can be safely downconverted to uint32 in languages - * that support this type. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.kms.v1.RawDecryptResponse|RawDecryptResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/key_management_service.raw_decrypt.js - * region_tag:cloudkms_v1_generated_KeyManagementService_RawDecrypt_async - */ + /** + * Decrypts data that was originally encrypted using a raw cryptographic + * mechanism. The {@link protos.google.cloud.kms.v1.CryptoKey.purpose|CryptoKey.purpose} + * must be + * {@link protos.google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.RAW_ENCRYPT_DECRYPT|RAW_ENCRYPT_DECRYPT}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the + * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} to use for + * decryption. + * @param {Buffer} request.ciphertext + * Required. The encrypted data originally returned in + * {@link protos.google.cloud.kms.v1.RawEncryptResponse.ciphertext|RawEncryptResponse.ciphertext}. + * @param {Buffer} [request.additionalAuthenticatedData] + * Optional. Optional data that must match the data originally supplied in + * {@link protos.google.cloud.kms.v1.RawEncryptRequest.additional_authenticated_data|RawEncryptRequest.additional_authenticated_data}. + * @param {Buffer} request.initializationVector + * Required. The initialization vector (IV) used during encryption, which must + * match the data originally provided in + * {@link protos.google.cloud.kms.v1.RawEncryptResponse.initialization_vector|RawEncryptResponse.initialization_vector}. + * @param {number} request.tagLength + * The length of the authentication tag that is appended to the end of + * the ciphertext. If unspecified (0), the default value for the key's + * algorithm will be used (for AES-GCM, the default value is 16). + * @param {google.protobuf.Int64Value} [request.ciphertextCrc32c] + * Optional. An optional CRC32C checksum of the + * {@link protos.google.cloud.kms.v1.RawDecryptRequest.ciphertext|RawDecryptRequest.ciphertext}. + * If specified, + * {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} will + * verify the integrity of the received ciphertext using this checksum. + * {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} will + * report an error if the checksum verification fails. If you receive a + * checksum error, your client should verify that CRC32C(ciphertext) is equal + * to ciphertext_crc32c, and if so, perform a limited number of retries. A + * persistent mismatch may indicate an issue in your computation of the CRC32C + * checksum. Note: This field is defined as int64 for reasons of compatibility + * across different languages. However, it is a non-negative integer, which + * will never exceed 2^32-1, and can be safely downconverted to uint32 in + * languages that support this type. + * @param {google.protobuf.Int64Value} [request.additionalAuthenticatedDataCrc32c] + * Optional. An optional CRC32C checksum of the + * {@link protos.google.cloud.kms.v1.RawDecryptRequest.additional_authenticated_data|RawDecryptRequest.additional_authenticated_data}. + * If specified, + * {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} will + * verify the integrity of the received additional_authenticated_data using + * this checksum. + * {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} will + * report an error if the checksum verification fails. If you receive a + * checksum error, your client should verify that + * CRC32C(additional_authenticated_data) is equal to + * additional_authenticated_data_crc32c, and if so, perform + * a limited number of retries. A persistent mismatch may indicate an issue in + * your computation of the CRC32C checksum. + * Note: This field is defined as int64 for reasons of compatibility across + * different languages. However, it is a non-negative integer, which will + * never exceed 2^32-1, and can be safely downconverted to uint32 in languages + * that support this type. + * @param {google.protobuf.Int64Value} [request.initializationVectorCrc32c] + * Optional. An optional CRC32C checksum of the + * {@link protos.google.cloud.kms.v1.RawDecryptRequest.initialization_vector|RawDecryptRequest.initialization_vector}. + * If specified, + * {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} will + * verify the integrity of the received initialization_vector using this + * checksum. {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} + * will report an error if the checksum verification fails. If you receive a + * checksum error, your client should verify that + * CRC32C(initialization_vector) is equal to initialization_vector_crc32c, and + * if so, perform a limited number of retries. A persistent mismatch may + * indicate an issue in your computation of the CRC32C checksum. + * Note: This field is defined as int64 for reasons of compatibility across + * different languages. However, it is a non-negative integer, which will + * never exceed 2^32-1, and can be safely downconverted to uint32 in languages + * that support this type. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.kms.v1.RawDecryptResponse|RawDecryptResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/key_management_service.raw_decrypt.js + * region_tag:cloudkms_v1_generated_KeyManagementService_RawDecrypt_async + */ rawDecrypt( - request?: protos.google.cloud.kms.v1.IRawDecryptRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.kms.v1.IRawDecryptResponse, - protos.google.cloud.kms.v1.IRawDecryptRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.kms.v1.IRawDecryptRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.kms.v1.IRawDecryptResponse, + protos.google.cloud.kms.v1.IRawDecryptRequest | undefined, + {} | undefined, + ] + >; rawDecrypt( - request: protos.google.cloud.kms.v1.IRawDecryptRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.kms.v1.IRawDecryptResponse, - protos.google.cloud.kms.v1.IRawDecryptRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IRawDecryptRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.kms.v1.IRawDecryptResponse, + protos.google.cloud.kms.v1.IRawDecryptRequest | null | undefined, + {} | null | undefined + >, + ): void; rawDecrypt( - request: protos.google.cloud.kms.v1.IRawDecryptRequest, - callback: Callback< - protos.google.cloud.kms.v1.IRawDecryptResponse, - protos.google.cloud.kms.v1.IRawDecryptRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IRawDecryptRequest, + callback: Callback< + protos.google.cloud.kms.v1.IRawDecryptResponse, + protos.google.cloud.kms.v1.IRawDecryptRequest | null | undefined, + {} | null | undefined + >, + ): void; rawDecrypt( - request?: protos.google.cloud.kms.v1.IRawDecryptRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.kms.v1.IRawDecryptResponse, - protos.google.cloud.kms.v1.IRawDecryptRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.kms.v1.IRawDecryptRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.kms.v1.IRawDecryptResponse, - protos.google.cloud.kms.v1.IRawDecryptRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.kms.v1.IRawDecryptResponse, - protos.google.cloud.kms.v1.IRawDecryptRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.kms.v1.IRawDecryptRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.kms.v1.IRawDecryptResponse, + protos.google.cloud.kms.v1.IRawDecryptRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.kms.v1.IRawDecryptResponse, + protos.google.cloud.kms.v1.IRawDecryptRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('rawDecrypt request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.kms.v1.IRawDecryptResponse, - protos.google.cloud.kms.v1.IRawDecryptRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.kms.v1.IRawDecryptResponse, + protos.google.cloud.kms.v1.IRawDecryptRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('rawDecrypt response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.rawDecrypt(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.kms.v1.IRawDecryptResponse, - protos.google.cloud.kms.v1.IRawDecryptRequest|undefined, - {}|undefined - ]) => { - this._log.info('rawDecrypt response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .rawDecrypt(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.kms.v1.IRawDecryptResponse, + protos.google.cloud.kms.v1.IRawDecryptRequest | undefined, + {} | undefined, + ]) => { + this._log.info('rawDecrypt response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Signs data using a {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} - * with {@link protos.google.cloud.kms.v1.CryptoKey.purpose|CryptoKey.purpose} - * ASYMMETRIC_SIGN, producing a signature that can be verified with the public - * key retrieved from - * {@link protos.google.cloud.kms.v1.KeyManagementService.GetPublicKey|GetPublicKey}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the - * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} to use for - * signing. - * @param {google.cloud.kms.v1.Digest} [request.digest] - * Optional. The digest of the data to sign. The digest must be produced with - * the same digest algorithm as specified by the key version's - * {@link protos.google.cloud.kms.v1.CryptoKeyVersion.algorithm|algorithm}. - * - * This field may not be supplied if - * {@link protos.google.cloud.kms.v1.AsymmetricSignRequest.data|AsymmetricSignRequest.data} - * is supplied. - * @param {google.protobuf.Int64Value} [request.digestCrc32c] - * Optional. An optional CRC32C checksum of the - * {@link protos.google.cloud.kms.v1.AsymmetricSignRequest.digest|AsymmetricSignRequest.digest}. - * If specified, - * {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} will - * verify the integrity of the received - * {@link protos.google.cloud.kms.v1.AsymmetricSignRequest.digest|AsymmetricSignRequest.digest} - * using this checksum. - * {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} will - * report an error if the checksum verification fails. If you receive a - * checksum error, your client should verify that - * CRC32C({@link protos.google.cloud.kms.v1.AsymmetricSignRequest.digest|AsymmetricSignRequest.digest}) - * is equal to - * {@link protos.google.cloud.kms.v1.AsymmetricSignRequest.digest_crc32c|AsymmetricSignRequest.digest_crc32c}, - * and if so, perform a limited number of retries. A persistent mismatch may - * indicate an issue in your computation of the CRC32C checksum. Note: This - * field is defined as int64 for reasons of compatibility across different - * languages. However, it is a non-negative integer, which will never exceed - * 2^32-1, and can be safely downconverted to uint32 in languages that support - * this type. - * @param {Buffer} [request.data] - * Optional. The data to sign. - * It can't be supplied if - * {@link protos.google.cloud.kms.v1.AsymmetricSignRequest.digest|AsymmetricSignRequest.digest} - * is supplied. - * @param {google.protobuf.Int64Value} [request.dataCrc32c] - * Optional. An optional CRC32C checksum of the - * {@link protos.google.cloud.kms.v1.AsymmetricSignRequest.data|AsymmetricSignRequest.data}. - * If specified, - * {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} will - * verify the integrity of the received - * {@link protos.google.cloud.kms.v1.AsymmetricSignRequest.data|AsymmetricSignRequest.data} - * using this checksum. - * {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} will - * report an error if the checksum verification fails. If you receive a - * checksum error, your client should verify that - * CRC32C({@link protos.google.cloud.kms.v1.AsymmetricSignRequest.data|AsymmetricSignRequest.data}) - * is equal to - * {@link protos.google.cloud.kms.v1.AsymmetricSignRequest.data_crc32c|AsymmetricSignRequest.data_crc32c}, - * and if so, perform a limited number of retries. A persistent mismatch may - * indicate an issue in your computation of the CRC32C checksum. Note: This - * field is defined as int64 for reasons of compatibility across different - * languages. However, it is a non-negative integer, which will never exceed - * 2^32-1, and can be safely downconverted to uint32 in languages that support - * this type. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.kms.v1.AsymmetricSignResponse|AsymmetricSignResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/key_management_service.asymmetric_sign.js - * region_tag:cloudkms_v1_generated_KeyManagementService_AsymmetricSign_async - */ + /** + * Signs data using a {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} + * with {@link protos.google.cloud.kms.v1.CryptoKey.purpose|CryptoKey.purpose} + * ASYMMETRIC_SIGN, producing a signature that can be verified with the public + * key retrieved from + * {@link protos.google.cloud.kms.v1.KeyManagementService.GetPublicKey|GetPublicKey}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the + * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} to use for + * signing. + * @param {google.cloud.kms.v1.Digest} [request.digest] + * Optional. The digest of the data to sign. The digest must be produced with + * the same digest algorithm as specified by the key version's + * {@link protos.google.cloud.kms.v1.CryptoKeyVersion.algorithm|algorithm}. + * + * This field may not be supplied if + * {@link protos.google.cloud.kms.v1.AsymmetricSignRequest.data|AsymmetricSignRequest.data} + * is supplied. + * @param {google.protobuf.Int64Value} [request.digestCrc32c] + * Optional. An optional CRC32C checksum of the + * {@link protos.google.cloud.kms.v1.AsymmetricSignRequest.digest|AsymmetricSignRequest.digest}. + * If specified, + * {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} will + * verify the integrity of the received + * {@link protos.google.cloud.kms.v1.AsymmetricSignRequest.digest|AsymmetricSignRequest.digest} + * using this checksum. + * {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} will + * report an error if the checksum verification fails. If you receive a + * checksum error, your client should verify that + * CRC32C({@link protos.google.cloud.kms.v1.AsymmetricSignRequest.digest|AsymmetricSignRequest.digest}) + * is equal to + * {@link protos.google.cloud.kms.v1.AsymmetricSignRequest.digest_crc32c|AsymmetricSignRequest.digest_crc32c}, + * and if so, perform a limited number of retries. A persistent mismatch may + * indicate an issue in your computation of the CRC32C checksum. Note: This + * field is defined as int64 for reasons of compatibility across different + * languages. However, it is a non-negative integer, which will never exceed + * 2^32-1, and can be safely downconverted to uint32 in languages that support + * this type. + * @param {Buffer} [request.data] + * Optional. The data to sign. + * It can't be supplied if + * {@link protos.google.cloud.kms.v1.AsymmetricSignRequest.digest|AsymmetricSignRequest.digest} + * is supplied. + * @param {google.protobuf.Int64Value} [request.dataCrc32c] + * Optional. An optional CRC32C checksum of the + * {@link protos.google.cloud.kms.v1.AsymmetricSignRequest.data|AsymmetricSignRequest.data}. + * If specified, + * {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} will + * verify the integrity of the received + * {@link protos.google.cloud.kms.v1.AsymmetricSignRequest.data|AsymmetricSignRequest.data} + * using this checksum. + * {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} will + * report an error if the checksum verification fails. If you receive a + * checksum error, your client should verify that + * CRC32C({@link protos.google.cloud.kms.v1.AsymmetricSignRequest.data|AsymmetricSignRequest.data}) + * is equal to + * {@link protos.google.cloud.kms.v1.AsymmetricSignRequest.data_crc32c|AsymmetricSignRequest.data_crc32c}, + * and if so, perform a limited number of retries. A persistent mismatch may + * indicate an issue in your computation of the CRC32C checksum. Note: This + * field is defined as int64 for reasons of compatibility across different + * languages. However, it is a non-negative integer, which will never exceed + * 2^32-1, and can be safely downconverted to uint32 in languages that support + * this type. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.kms.v1.AsymmetricSignResponse|AsymmetricSignResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/key_management_service.asymmetric_sign.js + * region_tag:cloudkms_v1_generated_KeyManagementService_AsymmetricSign_async + */ asymmetricSign( - request?: protos.google.cloud.kms.v1.IAsymmetricSignRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.kms.v1.IAsymmetricSignResponse, - protos.google.cloud.kms.v1.IAsymmetricSignRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.kms.v1.IAsymmetricSignRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.kms.v1.IAsymmetricSignResponse, + protos.google.cloud.kms.v1.IAsymmetricSignRequest | undefined, + {} | undefined, + ] + >; asymmetricSign( - request: protos.google.cloud.kms.v1.IAsymmetricSignRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.kms.v1.IAsymmetricSignResponse, - protos.google.cloud.kms.v1.IAsymmetricSignRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IAsymmetricSignRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.kms.v1.IAsymmetricSignResponse, + protos.google.cloud.kms.v1.IAsymmetricSignRequest | null | undefined, + {} | null | undefined + >, + ): void; asymmetricSign( - request: protos.google.cloud.kms.v1.IAsymmetricSignRequest, - callback: Callback< - protos.google.cloud.kms.v1.IAsymmetricSignResponse, - protos.google.cloud.kms.v1.IAsymmetricSignRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IAsymmetricSignRequest, + callback: Callback< + protos.google.cloud.kms.v1.IAsymmetricSignResponse, + protos.google.cloud.kms.v1.IAsymmetricSignRequest | null | undefined, + {} | null | undefined + >, + ): void; asymmetricSign( - request?: protos.google.cloud.kms.v1.IAsymmetricSignRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.kms.v1.IAsymmetricSignResponse, - protos.google.cloud.kms.v1.IAsymmetricSignRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.kms.v1.IAsymmetricSignRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.kms.v1.IAsymmetricSignResponse, - protos.google.cloud.kms.v1.IAsymmetricSignRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.kms.v1.IAsymmetricSignResponse, - protos.google.cloud.kms.v1.IAsymmetricSignRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.kms.v1.IAsymmetricSignRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.kms.v1.IAsymmetricSignResponse, + protos.google.cloud.kms.v1.IAsymmetricSignRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.kms.v1.IAsymmetricSignResponse, + protos.google.cloud.kms.v1.IAsymmetricSignRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('asymmetricSign request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.kms.v1.IAsymmetricSignResponse, - protos.google.cloud.kms.v1.IAsymmetricSignRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.kms.v1.IAsymmetricSignResponse, + protos.google.cloud.kms.v1.IAsymmetricSignRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('asymmetricSign response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.asymmetricSign(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.kms.v1.IAsymmetricSignResponse, - protos.google.cloud.kms.v1.IAsymmetricSignRequest|undefined, - {}|undefined - ]) => { - this._log.info('asymmetricSign response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .asymmetricSign(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.kms.v1.IAsymmetricSignResponse, + protos.google.cloud.kms.v1.IAsymmetricSignRequest | undefined, + {} | undefined, + ]) => { + this._log.info('asymmetricSign response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Decrypts data that was encrypted with a public key retrieved from - * {@link protos.google.cloud.kms.v1.KeyManagementService.GetPublicKey|GetPublicKey} - * corresponding to a {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} - * with {@link protos.google.cloud.kms.v1.CryptoKey.purpose|CryptoKey.purpose} - * ASYMMETRIC_DECRYPT. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the - * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} to use for - * decryption. - * @param {Buffer} request.ciphertext - * Required. The data encrypted with the named - * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion}'s public key using - * OAEP. - * @param {google.protobuf.Int64Value} [request.ciphertextCrc32c] - * Optional. An optional CRC32C checksum of the - * {@link protos.google.cloud.kms.v1.AsymmetricDecryptRequest.ciphertext|AsymmetricDecryptRequest.ciphertext}. - * If specified, - * {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} will - * verify the integrity of the received - * {@link protos.google.cloud.kms.v1.AsymmetricDecryptRequest.ciphertext|AsymmetricDecryptRequest.ciphertext} - * using this checksum. - * {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} will - * report an error if the checksum verification fails. If you receive a - * checksum error, your client should verify that - * CRC32C({@link protos.google.cloud.kms.v1.AsymmetricDecryptRequest.ciphertext|AsymmetricDecryptRequest.ciphertext}) - * is equal to - * {@link protos.google.cloud.kms.v1.AsymmetricDecryptRequest.ciphertext_crc32c|AsymmetricDecryptRequest.ciphertext_crc32c}, - * and if so, perform a limited number of retries. A persistent mismatch may - * indicate an issue in your computation of the CRC32C checksum. Note: This - * field is defined as int64 for reasons of compatibility across different - * languages. However, it is a non-negative integer, which will never exceed - * 2^32-1, and can be safely downconverted to uint32 in languages that support - * this type. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.kms.v1.AsymmetricDecryptResponse|AsymmetricDecryptResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/key_management_service.asymmetric_decrypt.js - * region_tag:cloudkms_v1_generated_KeyManagementService_AsymmetricDecrypt_async - */ + /** + * Decrypts data that was encrypted with a public key retrieved from + * {@link protos.google.cloud.kms.v1.KeyManagementService.GetPublicKey|GetPublicKey} + * corresponding to a {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} + * with {@link protos.google.cloud.kms.v1.CryptoKey.purpose|CryptoKey.purpose} + * ASYMMETRIC_DECRYPT. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the + * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} to use for + * decryption. + * @param {Buffer} request.ciphertext + * Required. The data encrypted with the named + * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion}'s public key using + * OAEP. + * @param {google.protobuf.Int64Value} [request.ciphertextCrc32c] + * Optional. An optional CRC32C checksum of the + * {@link protos.google.cloud.kms.v1.AsymmetricDecryptRequest.ciphertext|AsymmetricDecryptRequest.ciphertext}. + * If specified, + * {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} will + * verify the integrity of the received + * {@link protos.google.cloud.kms.v1.AsymmetricDecryptRequest.ciphertext|AsymmetricDecryptRequest.ciphertext} + * using this checksum. + * {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} will + * report an error if the checksum verification fails. If you receive a + * checksum error, your client should verify that + * CRC32C({@link protos.google.cloud.kms.v1.AsymmetricDecryptRequest.ciphertext|AsymmetricDecryptRequest.ciphertext}) + * is equal to + * {@link protos.google.cloud.kms.v1.AsymmetricDecryptRequest.ciphertext_crc32c|AsymmetricDecryptRequest.ciphertext_crc32c}, + * and if so, perform a limited number of retries. A persistent mismatch may + * indicate an issue in your computation of the CRC32C checksum. Note: This + * field is defined as int64 for reasons of compatibility across different + * languages. However, it is a non-negative integer, which will never exceed + * 2^32-1, and can be safely downconverted to uint32 in languages that support + * this type. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.kms.v1.AsymmetricDecryptResponse|AsymmetricDecryptResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/key_management_service.asymmetric_decrypt.js + * region_tag:cloudkms_v1_generated_KeyManagementService_AsymmetricDecrypt_async + */ asymmetricDecrypt( - request?: protos.google.cloud.kms.v1.IAsymmetricDecryptRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.kms.v1.IAsymmetricDecryptResponse, - protos.google.cloud.kms.v1.IAsymmetricDecryptRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.kms.v1.IAsymmetricDecryptRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.kms.v1.IAsymmetricDecryptResponse, + protos.google.cloud.kms.v1.IAsymmetricDecryptRequest | undefined, + {} | undefined, + ] + >; asymmetricDecrypt( - request: protos.google.cloud.kms.v1.IAsymmetricDecryptRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.kms.v1.IAsymmetricDecryptResponse, - protos.google.cloud.kms.v1.IAsymmetricDecryptRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IAsymmetricDecryptRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.kms.v1.IAsymmetricDecryptResponse, + protos.google.cloud.kms.v1.IAsymmetricDecryptRequest | null | undefined, + {} | null | undefined + >, + ): void; asymmetricDecrypt( - request: protos.google.cloud.kms.v1.IAsymmetricDecryptRequest, - callback: Callback< - protos.google.cloud.kms.v1.IAsymmetricDecryptResponse, - protos.google.cloud.kms.v1.IAsymmetricDecryptRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IAsymmetricDecryptRequest, + callback: Callback< + protos.google.cloud.kms.v1.IAsymmetricDecryptResponse, + protos.google.cloud.kms.v1.IAsymmetricDecryptRequest | null | undefined, + {} | null | undefined + >, + ): void; asymmetricDecrypt( - request?: protos.google.cloud.kms.v1.IAsymmetricDecryptRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.kms.v1.IAsymmetricDecryptResponse, - protos.google.cloud.kms.v1.IAsymmetricDecryptRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.kms.v1.IAsymmetricDecryptRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.kms.v1.IAsymmetricDecryptResponse, - protos.google.cloud.kms.v1.IAsymmetricDecryptRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.kms.v1.IAsymmetricDecryptResponse, - protos.google.cloud.kms.v1.IAsymmetricDecryptRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.kms.v1.IAsymmetricDecryptRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.kms.v1.IAsymmetricDecryptResponse, + protos.google.cloud.kms.v1.IAsymmetricDecryptRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.kms.v1.IAsymmetricDecryptResponse, + protos.google.cloud.kms.v1.IAsymmetricDecryptRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('asymmetricDecrypt request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.kms.v1.IAsymmetricDecryptResponse, - protos.google.cloud.kms.v1.IAsymmetricDecryptRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.kms.v1.IAsymmetricDecryptResponse, + | protos.google.cloud.kms.v1.IAsymmetricDecryptRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('asymmetricDecrypt response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.asymmetricDecrypt(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.kms.v1.IAsymmetricDecryptResponse, - protos.google.cloud.kms.v1.IAsymmetricDecryptRequest|undefined, - {}|undefined - ]) => { - this._log.info('asymmetricDecrypt response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .asymmetricDecrypt(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.kms.v1.IAsymmetricDecryptResponse, + protos.google.cloud.kms.v1.IAsymmetricDecryptRequest | undefined, + {} | undefined, + ]) => { + this._log.info('asymmetricDecrypt response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Signs data using a {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} - * with {@link protos.google.cloud.kms.v1.CryptoKey.purpose|CryptoKey.purpose} MAC, - * producing a tag that can be verified by another source with the same key. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the - * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} to use for - * signing. - * @param {Buffer} request.data - * Required. The data to sign. The MAC tag is computed over this data field - * based on the specific algorithm. - * @param {google.protobuf.Int64Value} [request.dataCrc32c] - * Optional. An optional CRC32C checksum of the - * {@link protos.google.cloud.kms.v1.MacSignRequest.data|MacSignRequest.data}. If - * specified, {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} - * will verify the integrity of the received - * {@link protos.google.cloud.kms.v1.MacSignRequest.data|MacSignRequest.data} using this - * checksum. {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} - * will report an error if the checksum verification fails. If you receive a - * checksum error, your client should verify that - * CRC32C({@link protos.google.cloud.kms.v1.MacSignRequest.data|MacSignRequest.data}) is - * equal to - * {@link protos.google.cloud.kms.v1.MacSignRequest.data_crc32c|MacSignRequest.data_crc32c}, - * and if so, perform a limited number of retries. A persistent mismatch may - * indicate an issue in your computation of the CRC32C checksum. Note: This - * field is defined as int64 for reasons of compatibility across different - * languages. However, it is a non-negative integer, which will never exceed - * 2^32-1, and can be safely downconverted to uint32 in languages that support - * this type. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.kms.v1.MacSignResponse|MacSignResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/key_management_service.mac_sign.js - * region_tag:cloudkms_v1_generated_KeyManagementService_MacSign_async - */ + /** + * Signs data using a {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} + * with {@link protos.google.cloud.kms.v1.CryptoKey.purpose|CryptoKey.purpose} MAC, + * producing a tag that can be verified by another source with the same key. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the + * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} to use for + * signing. + * @param {Buffer} request.data + * Required. The data to sign. The MAC tag is computed over this data field + * based on the specific algorithm. + * @param {google.protobuf.Int64Value} [request.dataCrc32c] + * Optional. An optional CRC32C checksum of the + * {@link protos.google.cloud.kms.v1.MacSignRequest.data|MacSignRequest.data}. If + * specified, {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} + * will verify the integrity of the received + * {@link protos.google.cloud.kms.v1.MacSignRequest.data|MacSignRequest.data} using this + * checksum. {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} + * will report an error if the checksum verification fails. If you receive a + * checksum error, your client should verify that + * CRC32C({@link protos.google.cloud.kms.v1.MacSignRequest.data|MacSignRequest.data}) is + * equal to + * {@link protos.google.cloud.kms.v1.MacSignRequest.data_crc32c|MacSignRequest.data_crc32c}, + * and if so, perform a limited number of retries. A persistent mismatch may + * indicate an issue in your computation of the CRC32C checksum. Note: This + * field is defined as int64 for reasons of compatibility across different + * languages. However, it is a non-negative integer, which will never exceed + * 2^32-1, and can be safely downconverted to uint32 in languages that support + * this type. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.kms.v1.MacSignResponse|MacSignResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/key_management_service.mac_sign.js + * region_tag:cloudkms_v1_generated_KeyManagementService_MacSign_async + */ macSign( - request?: protos.google.cloud.kms.v1.IMacSignRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.kms.v1.IMacSignResponse, - protos.google.cloud.kms.v1.IMacSignRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.kms.v1.IMacSignRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.kms.v1.IMacSignResponse, + protos.google.cloud.kms.v1.IMacSignRequest | undefined, + {} | undefined, + ] + >; macSign( - request: protos.google.cloud.kms.v1.IMacSignRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.kms.v1.IMacSignResponse, - protos.google.cloud.kms.v1.IMacSignRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IMacSignRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.kms.v1.IMacSignResponse, + protos.google.cloud.kms.v1.IMacSignRequest | null | undefined, + {} | null | undefined + >, + ): void; macSign( - request: protos.google.cloud.kms.v1.IMacSignRequest, - callback: Callback< - protos.google.cloud.kms.v1.IMacSignResponse, - protos.google.cloud.kms.v1.IMacSignRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IMacSignRequest, + callback: Callback< + protos.google.cloud.kms.v1.IMacSignResponse, + protos.google.cloud.kms.v1.IMacSignRequest | null | undefined, + {} | null | undefined + >, + ): void; macSign( - request?: protos.google.cloud.kms.v1.IMacSignRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.kms.v1.IMacSignResponse, - protos.google.cloud.kms.v1.IMacSignRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.kms.v1.IMacSignRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.kms.v1.IMacSignResponse, - protos.google.cloud.kms.v1.IMacSignRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.kms.v1.IMacSignResponse, - protos.google.cloud.kms.v1.IMacSignRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.kms.v1.IMacSignRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.kms.v1.IMacSignResponse, + protos.google.cloud.kms.v1.IMacSignRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.kms.v1.IMacSignResponse, + protos.google.cloud.kms.v1.IMacSignRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('macSign request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.kms.v1.IMacSignResponse, - protos.google.cloud.kms.v1.IMacSignRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.kms.v1.IMacSignResponse, + protos.google.cloud.kms.v1.IMacSignRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('macSign response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.macSign(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.kms.v1.IMacSignResponse, - protos.google.cloud.kms.v1.IMacSignRequest|undefined, - {}|undefined - ]) => { - this._log.info('macSign response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .macSign(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.kms.v1.IMacSignResponse, + protos.google.cloud.kms.v1.IMacSignRequest | undefined, + {} | undefined, + ]) => { + this._log.info('macSign response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Verifies MAC tag using a - * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} with - * {@link protos.google.cloud.kms.v1.CryptoKey.purpose|CryptoKey.purpose} MAC, and returns - * a response that indicates whether or not the verification was successful. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the - * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} to use for - * verification. - * @param {Buffer} request.data - * Required. The data used previously as a - * {@link protos.google.cloud.kms.v1.MacSignRequest.data|MacSignRequest.data} to generate - * the MAC tag. - * @param {google.protobuf.Int64Value} [request.dataCrc32c] - * Optional. An optional CRC32C checksum of the - * {@link protos.google.cloud.kms.v1.MacVerifyRequest.data|MacVerifyRequest.data}. If - * specified, {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} - * will verify the integrity of the received - * {@link protos.google.cloud.kms.v1.MacVerifyRequest.data|MacVerifyRequest.data} using - * this checksum. - * {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} will - * report an error if the checksum verification fails. If you receive a - * checksum error, your client should verify that - * CRC32C({@link protos.google.cloud.kms.v1.MacVerifyRequest.data|MacVerifyRequest.data}) - * is equal to - * {@link protos.google.cloud.kms.v1.MacVerifyRequest.data_crc32c|MacVerifyRequest.data_crc32c}, - * and if so, perform a limited number of retries. A persistent mismatch may - * indicate an issue in your computation of the CRC32C checksum. Note: This - * field is defined as int64 for reasons of compatibility across different - * languages. However, it is a non-negative integer, which will never exceed - * 2^32-1, and can be safely downconverted to uint32 in languages that support - * this type. - * @param {Buffer} request.mac - * Required. The signature to verify. - * @param {google.protobuf.Int64Value} [request.macCrc32c] - * Optional. An optional CRC32C checksum of the - * {@link protos.google.cloud.kms.v1.MacVerifyRequest.mac|MacVerifyRequest.mac}. If - * specified, {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} - * will verify the integrity of the received - * {@link protos.google.cloud.kms.v1.MacVerifyRequest.mac|MacVerifyRequest.mac} using this - * checksum. {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} - * will report an error if the checksum verification fails. If you receive a - * checksum error, your client should verify that - * CRC32C({@link protos.google.cloud.kms.v1.MacVerifyRequest.mac|MacVerifyRequest.mac}) is - * equal to - * {@link protos.google.cloud.kms.v1.MacVerifyRequest.mac_crc32c|MacVerifyRequest.mac_crc32c}, - * and if so, perform a limited number of retries. A persistent mismatch may - * indicate an issue in your computation of the CRC32C checksum. Note: This - * field is defined as int64 for reasons of compatibility across different - * languages. However, it is a non-negative integer, which will never exceed - * 2^32-1, and can be safely downconverted to uint32 in languages that support - * this type. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.kms.v1.MacVerifyResponse|MacVerifyResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/key_management_service.mac_verify.js - * region_tag:cloudkms_v1_generated_KeyManagementService_MacVerify_async - */ + /** + * Verifies MAC tag using a + * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} with + * {@link protos.google.cloud.kms.v1.CryptoKey.purpose|CryptoKey.purpose} MAC, and returns + * a response that indicates whether or not the verification was successful. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the + * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} to use for + * verification. + * @param {Buffer} request.data + * Required. The data used previously as a + * {@link protos.google.cloud.kms.v1.MacSignRequest.data|MacSignRequest.data} to generate + * the MAC tag. + * @param {google.protobuf.Int64Value} [request.dataCrc32c] + * Optional. An optional CRC32C checksum of the + * {@link protos.google.cloud.kms.v1.MacVerifyRequest.data|MacVerifyRequest.data}. If + * specified, {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} + * will verify the integrity of the received + * {@link protos.google.cloud.kms.v1.MacVerifyRequest.data|MacVerifyRequest.data} using + * this checksum. + * {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} will + * report an error if the checksum verification fails. If you receive a + * checksum error, your client should verify that + * CRC32C({@link protos.google.cloud.kms.v1.MacVerifyRequest.data|MacVerifyRequest.data}) + * is equal to + * {@link protos.google.cloud.kms.v1.MacVerifyRequest.data_crc32c|MacVerifyRequest.data_crc32c}, + * and if so, perform a limited number of retries. A persistent mismatch may + * indicate an issue in your computation of the CRC32C checksum. Note: This + * field is defined as int64 for reasons of compatibility across different + * languages. However, it is a non-negative integer, which will never exceed + * 2^32-1, and can be safely downconverted to uint32 in languages that support + * this type. + * @param {Buffer} request.mac + * Required. The signature to verify. + * @param {google.protobuf.Int64Value} [request.macCrc32c] + * Optional. An optional CRC32C checksum of the + * {@link protos.google.cloud.kms.v1.MacVerifyRequest.mac|MacVerifyRequest.mac}. If + * specified, {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} + * will verify the integrity of the received + * {@link protos.google.cloud.kms.v1.MacVerifyRequest.mac|MacVerifyRequest.mac} using this + * checksum. {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} + * will report an error if the checksum verification fails. If you receive a + * checksum error, your client should verify that + * CRC32C({@link protos.google.cloud.kms.v1.MacVerifyRequest.mac|MacVerifyRequest.mac}) is + * equal to + * {@link protos.google.cloud.kms.v1.MacVerifyRequest.mac_crc32c|MacVerifyRequest.mac_crc32c}, + * and if so, perform a limited number of retries. A persistent mismatch may + * indicate an issue in your computation of the CRC32C checksum. Note: This + * field is defined as int64 for reasons of compatibility across different + * languages. However, it is a non-negative integer, which will never exceed + * 2^32-1, and can be safely downconverted to uint32 in languages that support + * this type. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.kms.v1.MacVerifyResponse|MacVerifyResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/key_management_service.mac_verify.js + * region_tag:cloudkms_v1_generated_KeyManagementService_MacVerify_async + */ macVerify( - request?: protos.google.cloud.kms.v1.IMacVerifyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.kms.v1.IMacVerifyResponse, - protos.google.cloud.kms.v1.IMacVerifyRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.kms.v1.IMacVerifyRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.kms.v1.IMacVerifyResponse, + protos.google.cloud.kms.v1.IMacVerifyRequest | undefined, + {} | undefined, + ] + >; macVerify( - request: protos.google.cloud.kms.v1.IMacVerifyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.kms.v1.IMacVerifyResponse, - protos.google.cloud.kms.v1.IMacVerifyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IMacVerifyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.kms.v1.IMacVerifyResponse, + protos.google.cloud.kms.v1.IMacVerifyRequest | null | undefined, + {} | null | undefined + >, + ): void; macVerify( - request: protos.google.cloud.kms.v1.IMacVerifyRequest, - callback: Callback< - protos.google.cloud.kms.v1.IMacVerifyResponse, - protos.google.cloud.kms.v1.IMacVerifyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IMacVerifyRequest, + callback: Callback< + protos.google.cloud.kms.v1.IMacVerifyResponse, + protos.google.cloud.kms.v1.IMacVerifyRequest | null | undefined, + {} | null | undefined + >, + ): void; macVerify( - request?: protos.google.cloud.kms.v1.IMacVerifyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.kms.v1.IMacVerifyResponse, - protos.google.cloud.kms.v1.IMacVerifyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.kms.v1.IMacVerifyRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.kms.v1.IMacVerifyResponse, - protos.google.cloud.kms.v1.IMacVerifyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.kms.v1.IMacVerifyResponse, - protos.google.cloud.kms.v1.IMacVerifyRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.kms.v1.IMacVerifyRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.kms.v1.IMacVerifyResponse, + protos.google.cloud.kms.v1.IMacVerifyRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.kms.v1.IMacVerifyResponse, + protos.google.cloud.kms.v1.IMacVerifyRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('macVerify request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.kms.v1.IMacVerifyResponse, - protos.google.cloud.kms.v1.IMacVerifyRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.kms.v1.IMacVerifyResponse, + protos.google.cloud.kms.v1.IMacVerifyRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('macVerify response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.macVerify(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.kms.v1.IMacVerifyResponse, - protos.google.cloud.kms.v1.IMacVerifyRequest|undefined, - {}|undefined - ]) => { - this._log.info('macVerify response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .macVerify(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.kms.v1.IMacVerifyResponse, + protos.google.cloud.kms.v1.IMacVerifyRequest | undefined, + {} | undefined, + ]) => { + this._log.info('macVerify response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Decapsulates data that was encapsulated with a public key retrieved from - * {@link protos.google.cloud.kms.v1.KeyManagementService.GetPublicKey|GetPublicKey} - * corresponding to a {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} - * with {@link protos.google.cloud.kms.v1.CryptoKey.purpose|CryptoKey.purpose} - * KEY_ENCAPSULATION. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the - * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} to use for - * decapsulation. - * @param {Buffer} request.ciphertext - * Required. The ciphertext produced from encapsulation with the - * named {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} public - * key(s). - * @param {google.protobuf.Int64Value} [request.ciphertextCrc32c] - * Optional. A CRC32C checksum of the - * {@link protos.google.cloud.kms.v1.DecapsulateRequest.ciphertext|DecapsulateRequest.ciphertext}. - * If specified, - * {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} will - * verify the integrity of the received - * {@link protos.google.cloud.kms.v1.DecapsulateRequest.ciphertext|DecapsulateRequest.ciphertext} - * using this checksum. - * {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} will - * report an error if the checksum verification fails. If you receive a - * checksum error, your client should verify that - * CRC32C({@link protos.google.cloud.kms.v1.DecapsulateRequest.ciphertext|DecapsulateRequest.ciphertext}) - * is equal to - * {@link protos.google.cloud.kms.v1.DecapsulateRequest.ciphertext_crc32c|DecapsulateRequest.ciphertext_crc32c}, - * and if so, perform a limited number of retries. A persistent mismatch may - * indicate an issue in your computation of the CRC32C checksum. Note: This - * field is defined as int64 for reasons of compatibility across different - * languages. However, it is a non-negative integer, which will never exceed - * 2^32-1, and can be safely downconverted to uint32 in languages that support - * this type. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.kms.v1.DecapsulateResponse|DecapsulateResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/key_management_service.decapsulate.js - * region_tag:cloudkms_v1_generated_KeyManagementService_Decapsulate_async - */ + /** + * Decapsulates data that was encapsulated with a public key retrieved from + * {@link protos.google.cloud.kms.v1.KeyManagementService.GetPublicKey|GetPublicKey} + * corresponding to a {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} + * with {@link protos.google.cloud.kms.v1.CryptoKey.purpose|CryptoKey.purpose} + * KEY_ENCAPSULATION. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the + * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} to use for + * decapsulation. + * @param {Buffer} request.ciphertext + * Required. The ciphertext produced from encapsulation with the + * named {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} public + * key(s). + * @param {google.protobuf.Int64Value} [request.ciphertextCrc32c] + * Optional. A CRC32C checksum of the + * {@link protos.google.cloud.kms.v1.DecapsulateRequest.ciphertext|DecapsulateRequest.ciphertext}. + * If specified, + * {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} will + * verify the integrity of the received + * {@link protos.google.cloud.kms.v1.DecapsulateRequest.ciphertext|DecapsulateRequest.ciphertext} + * using this checksum. + * {@link protos.google.cloud.kms.v1.KeyManagementService|KeyManagementService} will + * report an error if the checksum verification fails. If you receive a + * checksum error, your client should verify that + * CRC32C({@link protos.google.cloud.kms.v1.DecapsulateRequest.ciphertext|DecapsulateRequest.ciphertext}) + * is equal to + * {@link protos.google.cloud.kms.v1.DecapsulateRequest.ciphertext_crc32c|DecapsulateRequest.ciphertext_crc32c}, + * and if so, perform a limited number of retries. A persistent mismatch may + * indicate an issue in your computation of the CRC32C checksum. Note: This + * field is defined as int64 for reasons of compatibility across different + * languages. However, it is a non-negative integer, which will never exceed + * 2^32-1, and can be safely downconverted to uint32 in languages that support + * this type. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.kms.v1.DecapsulateResponse|DecapsulateResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/key_management_service.decapsulate.js + * region_tag:cloudkms_v1_generated_KeyManagementService_Decapsulate_async + */ decapsulate( - request?: protos.google.cloud.kms.v1.IDecapsulateRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.kms.v1.IDecapsulateResponse, - protos.google.cloud.kms.v1.IDecapsulateRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.kms.v1.IDecapsulateRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.kms.v1.IDecapsulateResponse, + protos.google.cloud.kms.v1.IDecapsulateRequest | undefined, + {} | undefined, + ] + >; decapsulate( - request: protos.google.cloud.kms.v1.IDecapsulateRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.kms.v1.IDecapsulateResponse, - protos.google.cloud.kms.v1.IDecapsulateRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IDecapsulateRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.kms.v1.IDecapsulateResponse, + protos.google.cloud.kms.v1.IDecapsulateRequest | null | undefined, + {} | null | undefined + >, + ): void; decapsulate( - request: protos.google.cloud.kms.v1.IDecapsulateRequest, - callback: Callback< - protos.google.cloud.kms.v1.IDecapsulateResponse, - protos.google.cloud.kms.v1.IDecapsulateRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IDecapsulateRequest, + callback: Callback< + protos.google.cloud.kms.v1.IDecapsulateResponse, + protos.google.cloud.kms.v1.IDecapsulateRequest | null | undefined, + {} | null | undefined + >, + ): void; decapsulate( - request?: protos.google.cloud.kms.v1.IDecapsulateRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.kms.v1.IDecapsulateResponse, - protos.google.cloud.kms.v1.IDecapsulateRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.kms.v1.IDecapsulateRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.kms.v1.IDecapsulateResponse, - protos.google.cloud.kms.v1.IDecapsulateRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.kms.v1.IDecapsulateResponse, - protos.google.cloud.kms.v1.IDecapsulateRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.kms.v1.IDecapsulateRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.kms.v1.IDecapsulateResponse, + protos.google.cloud.kms.v1.IDecapsulateRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.kms.v1.IDecapsulateResponse, + protos.google.cloud.kms.v1.IDecapsulateRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('decapsulate request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.kms.v1.IDecapsulateResponse, - protos.google.cloud.kms.v1.IDecapsulateRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.kms.v1.IDecapsulateResponse, + protos.google.cloud.kms.v1.IDecapsulateRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('decapsulate response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.decapsulate(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.kms.v1.IDecapsulateResponse, - protos.google.cloud.kms.v1.IDecapsulateRequest|undefined, - {}|undefined - ]) => { - this._log.info('decapsulate response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .decapsulate(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.kms.v1.IDecapsulateResponse, + protos.google.cloud.kms.v1.IDecapsulateRequest | undefined, + {} | undefined, + ]) => { + this._log.info('decapsulate response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Generate random bytes using the Cloud KMS randomness source in the provided - * location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.location - * The project-specific location in which to generate random bytes. - * For example, "projects/my-project/locations/us-central1". - * @param {number} request.lengthBytes - * The length in bytes of the amount of randomness to retrieve. Minimum 8 - * bytes, maximum 1024 bytes. - * @param {google.cloud.kms.v1.ProtectionLevel} request.protectionLevel - * The {@link protos.google.cloud.kms.v1.ProtectionLevel|ProtectionLevel} to use when - * generating the random data. Currently, only - * {@link protos.google.cloud.kms.v1.ProtectionLevel.HSM|HSM} protection level is - * 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.kms.v1.GenerateRandomBytesResponse|GenerateRandomBytesResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/key_management_service.generate_random_bytes.js - * region_tag:cloudkms_v1_generated_KeyManagementService_GenerateRandomBytes_async - */ + /** + * Generate random bytes using the Cloud KMS randomness source in the provided + * location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.location + * The project-specific location in which to generate random bytes. + * For example, "projects/my-project/locations/us-central1". + * @param {number} request.lengthBytes + * The length in bytes of the amount of randomness to retrieve. Minimum 8 + * bytes, maximum 1024 bytes. + * @param {google.cloud.kms.v1.ProtectionLevel} request.protectionLevel + * The {@link protos.google.cloud.kms.v1.ProtectionLevel|ProtectionLevel} to use when + * generating the random data. Currently, only + * {@link protos.google.cloud.kms.v1.ProtectionLevel.HSM|HSM} protection level is + * 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.kms.v1.GenerateRandomBytesResponse|GenerateRandomBytesResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/key_management_service.generate_random_bytes.js + * region_tag:cloudkms_v1_generated_KeyManagementService_GenerateRandomBytes_async + */ generateRandomBytes( - request?: protos.google.cloud.kms.v1.IGenerateRandomBytesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.kms.v1.IGenerateRandomBytesResponse, - protos.google.cloud.kms.v1.IGenerateRandomBytesRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.kms.v1.IGenerateRandomBytesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.kms.v1.IGenerateRandomBytesResponse, + protos.google.cloud.kms.v1.IGenerateRandomBytesRequest | undefined, + {} | undefined, + ] + >; generateRandomBytes( - request: protos.google.cloud.kms.v1.IGenerateRandomBytesRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.kms.v1.IGenerateRandomBytesResponse, - protos.google.cloud.kms.v1.IGenerateRandomBytesRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IGenerateRandomBytesRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.kms.v1.IGenerateRandomBytesResponse, + protos.google.cloud.kms.v1.IGenerateRandomBytesRequest | null | undefined, + {} | null | undefined + >, + ): void; generateRandomBytes( - request: protos.google.cloud.kms.v1.IGenerateRandomBytesRequest, - callback: Callback< - protos.google.cloud.kms.v1.IGenerateRandomBytesResponse, - protos.google.cloud.kms.v1.IGenerateRandomBytesRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IGenerateRandomBytesRequest, + callback: Callback< + protos.google.cloud.kms.v1.IGenerateRandomBytesResponse, + protos.google.cloud.kms.v1.IGenerateRandomBytesRequest | null | undefined, + {} | null | undefined + >, + ): void; generateRandomBytes( - request?: protos.google.cloud.kms.v1.IGenerateRandomBytesRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.kms.v1.IGenerateRandomBytesResponse, - protos.google.cloud.kms.v1.IGenerateRandomBytesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.kms.v1.IGenerateRandomBytesRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.kms.v1.IGenerateRandomBytesResponse, - protos.google.cloud.kms.v1.IGenerateRandomBytesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.kms.v1.IGenerateRandomBytesResponse, - protos.google.cloud.kms.v1.IGenerateRandomBytesRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.kms.v1.IGenerateRandomBytesRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.kms.v1.IGenerateRandomBytesResponse, + protos.google.cloud.kms.v1.IGenerateRandomBytesRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.kms.v1.IGenerateRandomBytesResponse, + protos.google.cloud.kms.v1.IGenerateRandomBytesRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'location': request.location ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + location: request.location ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('generateRandomBytes request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.kms.v1.IGenerateRandomBytesResponse, - protos.google.cloud.kms.v1.IGenerateRandomBytesRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.kms.v1.IGenerateRandomBytesResponse, + | protos.google.cloud.kms.v1.IGenerateRandomBytesRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('generateRandomBytes response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.generateRandomBytes(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.kms.v1.IGenerateRandomBytesResponse, - protos.google.cloud.kms.v1.IGenerateRandomBytesRequest|undefined, - {}|undefined - ]) => { - this._log.info('generateRandomBytes response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .generateRandomBytes(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.kms.v1.IGenerateRandomBytesResponse, + protos.google.cloud.kms.v1.IGenerateRandomBytesRequest | undefined, + {} | undefined, + ]) => { + this._log.info('generateRandomBytes response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Permanently deletes the given {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey}. - * All child {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersions} must - * have been previously deleted using - * {@link protos.google.cloud.kms.v1.KeyManagementService.DeleteCryptoKeyVersion|KeyManagementService.DeleteCryptoKeyVersion}. - * The specified crypto key will be immediately and permanently deleted upon - * calling this method. This action cannot be undone. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The {@link protos.google.cloud.kms.v1.CryptoKey.name|name} of the - * {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey} 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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/key_management_service.delete_crypto_key.js - * region_tag:cloudkms_v1_generated_KeyManagementService_DeleteCryptoKey_async - */ + /** + * Permanently deletes the given {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey}. + * All child {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersions} must + * have been previously deleted using + * {@link protos.google.cloud.kms.v1.KeyManagementService.DeleteCryptoKeyVersion|KeyManagementService.DeleteCryptoKeyVersion}. + * The specified crypto key will be immediately and permanently deleted upon + * calling this method. This action cannot be undone. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The {@link protos.google.cloud.kms.v1.CryptoKey.name|name} of the + * {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey} 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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/key_management_service.delete_crypto_key.js + * region_tag:cloudkms_v1_generated_KeyManagementService_DeleteCryptoKey_async + */ deleteCryptoKey( - request?: protos.google.cloud.kms.v1.IDeleteCryptoKeyRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.kms.v1.IDeleteCryptoKeyRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.kms.v1.IDeleteCryptoKeyMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteCryptoKey( - request: protos.google.cloud.kms.v1.IDeleteCryptoKeyRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IDeleteCryptoKeyRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.kms.v1.IDeleteCryptoKeyMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteCryptoKey( - request: protos.google.cloud.kms.v1.IDeleteCryptoKeyRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IDeleteCryptoKeyRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.kms.v1.IDeleteCryptoKeyMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteCryptoKey( - request?: protos.google.cloud.kms.v1.IDeleteCryptoKeyRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.kms.v1.IDeleteCryptoKeyRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.kms.v1.IDeleteCryptoKeyMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.kms.v1.IDeleteCryptoKeyMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.kms.v1.IDeleteCryptoKeyMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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.kms.v1.IDeleteCryptoKeyMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteCryptoKey response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteCryptoKey request %j', request); - return this.innerApiCalls.deleteCryptoKey(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteCryptoKey response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteCryptoKey(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.kms.v1.IDeleteCryptoKeyMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteCryptoKey response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteCryptoKey()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/key_management_service.delete_crypto_key.js - * region_tag:cloudkms_v1_generated_KeyManagementService_DeleteCryptoKey_async - */ - async checkDeleteCryptoKeyProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteCryptoKey()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/key_management_service.delete_crypto_key.js + * region_tag:cloudkms_v1_generated_KeyManagementService_DeleteCryptoKey_async + */ + async checkDeleteCryptoKeyProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.kms.v1.DeleteCryptoKeyMetadata + > + > { this._log.info('deleteCryptoKey long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteCryptoKey, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteCryptoKey, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.kms.v1.DeleteCryptoKeyMetadata + >; } -/** - * Permanently deletes the given - * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion}. Only possible if - * the version has not been previously imported and if its - * {@link protos.google.cloud.kms.v1.CryptoKeyVersion.state|state} is one of - * {@link protos.CryptoKeyVersionState.DESTROYED|DESTROYED}, - * {@link protos.CryptoKeyVersionState.IMPORT_FAILED|IMPORT_FAILED}, or - * {@link protos.CryptoKeyVersionState.GENERATION_FAILED|GENERATION_FAILED}. - * Successfully imported - * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersions} cannot be deleted - * at this time. The specified version will be immediately and permanently - * deleted upon calling this method. This action cannot be undone. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The {@link protos.google.cloud.kms.v1.CryptoKeyVersion.name|name} of the - * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} 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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/key_management_service.delete_crypto_key_version.js - * region_tag:cloudkms_v1_generated_KeyManagementService_DeleteCryptoKeyVersion_async - */ + /** + * Permanently deletes the given + * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion}. Only possible if + * the version has not been previously imported and if its + * {@link protos.google.cloud.kms.v1.CryptoKeyVersion.state|state} is one of + * {@link protos.CryptoKeyVersionState.DESTROYED|DESTROYED}, + * {@link protos.CryptoKeyVersionState.IMPORT_FAILED|IMPORT_FAILED}, or + * {@link protos.CryptoKeyVersionState.GENERATION_FAILED|GENERATION_FAILED}. + * Successfully imported + * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersions} cannot be deleted + * at this time. The specified version will be immediately and permanently + * deleted upon calling this method. This action cannot be undone. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The {@link protos.google.cloud.kms.v1.CryptoKeyVersion.name|name} of the + * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} 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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/key_management_service.delete_crypto_key_version.js + * region_tag:cloudkms_v1_generated_KeyManagementService_DeleteCryptoKeyVersion_async + */ deleteCryptoKeyVersion( - request?: protos.google.cloud.kms.v1.IDeleteCryptoKeyVersionRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.kms.v1.IDeleteCryptoKeyVersionRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.kms.v1.IDeleteCryptoKeyVersionMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteCryptoKeyVersion( - request: protos.google.cloud.kms.v1.IDeleteCryptoKeyVersionRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IDeleteCryptoKeyVersionRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.kms.v1.IDeleteCryptoKeyVersionMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteCryptoKeyVersion( - request: protos.google.cloud.kms.v1.IDeleteCryptoKeyVersionRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.kms.v1.IDeleteCryptoKeyVersionRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.kms.v1.IDeleteCryptoKeyVersionMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteCryptoKeyVersion( - request?: protos.google.cloud.kms.v1.IDeleteCryptoKeyVersionRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.kms.v1.IDeleteCryptoKeyVersionRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.kms.v1.IDeleteCryptoKeyVersionMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.kms.v1.IDeleteCryptoKeyVersionMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.kms.v1.IDeleteCryptoKeyVersionMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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.kms.v1.IDeleteCryptoKeyVersionMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteCryptoKeyVersion response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteCryptoKeyVersion request %j', request); - return this.innerApiCalls.deleteCryptoKeyVersion(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteCryptoKeyVersion response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteCryptoKeyVersion(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.kms.v1.IDeleteCryptoKeyVersionMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteCryptoKeyVersion response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteCryptoKeyVersion()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/key_management_service.delete_crypto_key_version.js - * region_tag:cloudkms_v1_generated_KeyManagementService_DeleteCryptoKeyVersion_async - */ - async checkDeleteCryptoKeyVersionProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteCryptoKeyVersion()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/key_management_service.delete_crypto_key_version.js + * region_tag:cloudkms_v1_generated_KeyManagementService_DeleteCryptoKeyVersion_async + */ + async checkDeleteCryptoKeyVersionProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.kms.v1.DeleteCryptoKeyVersionMetadata + > + > { this._log.info('deleteCryptoKeyVersion long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteCryptoKeyVersion, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteCryptoKeyVersion, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.kms.v1.DeleteCryptoKeyVersionMetadata + >; } - /** - * Lists {@link protos.google.cloud.kms.v1.KeyRing|KeyRings}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the location associated with the - * {@link protos.google.cloud.kms.v1.KeyRing|KeyRings}, in the format - * `projects/* /locations/*`. - * @param {number} [request.pageSize] - * Optional. Optional limit on the number of - * {@link protos.google.cloud.kms.v1.KeyRing|KeyRings} to include in the response. Further - * {@link protos.google.cloud.kms.v1.KeyRing|KeyRings} can subsequently be obtained by - * including the - * {@link protos.google.cloud.kms.v1.ListKeyRingsResponse.next_page_token|ListKeyRingsResponse.next_page_token} - * in a subsequent request. If unspecified, the server will pick an - * appropriate default. - * @param {string} [request.pageToken] - * Optional. Optional pagination token, returned earlier via - * {@link protos.google.cloud.kms.v1.ListKeyRingsResponse.next_page_token|ListKeyRingsResponse.next_page_token}. - * @param {string} [request.filter] - * Optional. Only include resources that match the filter in the response. For - * more information, see - * [Sorting and filtering list - * results](https://cloud.google.com/kms/docs/sorting-and-filtering). - * @param {string} [request.orderBy] - * Optional. Specify how the results should be sorted. If not specified, the - * results will be sorted in the default order. For more information, see - * [Sorting and filtering list - * results](https://cloud.google.com/kms/docs/sorting-and-filtering). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link protos.google.cloud.kms.v1.KeyRing|KeyRing}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listKeyRingsAsync()` - * method described below for async iteration which you can stop as 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 {@link protos.google.cloud.kms.v1.KeyRing|KeyRings}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the location associated with the + * {@link protos.google.cloud.kms.v1.KeyRing|KeyRings}, in the format + * `projects/* /locations/*`. + * @param {number} [request.pageSize] + * Optional. Optional limit on the number of + * {@link protos.google.cloud.kms.v1.KeyRing|KeyRings} to include in the response. Further + * {@link protos.google.cloud.kms.v1.KeyRing|KeyRings} can subsequently be obtained by + * including the + * {@link protos.google.cloud.kms.v1.ListKeyRingsResponse.next_page_token|ListKeyRingsResponse.next_page_token} + * in a subsequent request. If unspecified, the server will pick an + * appropriate default. + * @param {string} [request.pageToken] + * Optional. Optional pagination token, returned earlier via + * {@link protos.google.cloud.kms.v1.ListKeyRingsResponse.next_page_token|ListKeyRingsResponse.next_page_token}. + * @param {string} [request.filter] + * Optional. Only include resources that match the filter in the response. For + * more information, see + * [Sorting and filtering list + * results](https://cloud.google.com/kms/docs/sorting-and-filtering). + * @param {string} [request.orderBy] + * Optional. Specify how the results should be sorted. If not specified, the + * results will be sorted in the default order. For more information, see + * [Sorting and filtering list + * results](https://cloud.google.com/kms/docs/sorting-and-filtering). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.kms.v1.KeyRing|KeyRing}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listKeyRingsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listKeyRings( - request?: protos.google.cloud.kms.v1.IListKeyRingsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.kms.v1.IKeyRing[], - protos.google.cloud.kms.v1.IListKeyRingsRequest|null, - protos.google.cloud.kms.v1.IListKeyRingsResponse - ]>; + request?: protos.google.cloud.kms.v1.IListKeyRingsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.kms.v1.IKeyRing[], + protos.google.cloud.kms.v1.IListKeyRingsRequest | null, + protos.google.cloud.kms.v1.IListKeyRingsResponse, + ] + >; listKeyRings( - request: protos.google.cloud.kms.v1.IListKeyRingsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.kms.v1.IListKeyRingsRequest, - protos.google.cloud.kms.v1.IListKeyRingsResponse|null|undefined, - protos.google.cloud.kms.v1.IKeyRing>): void; + request: protos.google.cloud.kms.v1.IListKeyRingsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.kms.v1.IListKeyRingsRequest, + protos.google.cloud.kms.v1.IListKeyRingsResponse | null | undefined, + protos.google.cloud.kms.v1.IKeyRing + >, + ): void; listKeyRings( - request: protos.google.cloud.kms.v1.IListKeyRingsRequest, - callback: PaginationCallback< - protos.google.cloud.kms.v1.IListKeyRingsRequest, - protos.google.cloud.kms.v1.IListKeyRingsResponse|null|undefined, - protos.google.cloud.kms.v1.IKeyRing>): void; + request: protos.google.cloud.kms.v1.IListKeyRingsRequest, + callback: PaginationCallback< + protos.google.cloud.kms.v1.IListKeyRingsRequest, + protos.google.cloud.kms.v1.IListKeyRingsResponse | null | undefined, + protos.google.cloud.kms.v1.IKeyRing + >, + ): void; listKeyRings( - request?: protos.google.cloud.kms.v1.IListKeyRingsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.kms.v1.IListKeyRingsRequest, - protos.google.cloud.kms.v1.IListKeyRingsResponse|null|undefined, - protos.google.cloud.kms.v1.IKeyRing>, - callback?: PaginationCallback< + request?: protos.google.cloud.kms.v1.IListKeyRingsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.kms.v1.IListKeyRingsRequest, - protos.google.cloud.kms.v1.IListKeyRingsResponse|null|undefined, - protos.google.cloud.kms.v1.IKeyRing>): - Promise<[ - protos.google.cloud.kms.v1.IKeyRing[], - protos.google.cloud.kms.v1.IListKeyRingsRequest|null, - protos.google.cloud.kms.v1.IListKeyRingsResponse - ]>|void { + protos.google.cloud.kms.v1.IListKeyRingsResponse | null | undefined, + protos.google.cloud.kms.v1.IKeyRing + >, + callback?: PaginationCallback< + protos.google.cloud.kms.v1.IListKeyRingsRequest, + protos.google.cloud.kms.v1.IListKeyRingsResponse | null | undefined, + protos.google.cloud.kms.v1.IKeyRing + >, + ): Promise< + [ + protos.google.cloud.kms.v1.IKeyRing[], + protos.google.cloud.kms.v1.IListKeyRingsRequest | null, + protos.google.cloud.kms.v1.IListKeyRingsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-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.kms.v1.IListKeyRingsRequest, - protos.google.cloud.kms.v1.IListKeyRingsResponse|null|undefined, - protos.google.cloud.kms.v1.IKeyRing>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.kms.v1.IListKeyRingsRequest, + protos.google.cloud.kms.v1.IListKeyRingsResponse | null | undefined, + protos.google.cloud.kms.v1.IKeyRing + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listKeyRings values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -3933,247 +5130,266 @@ export class KeyManagementServiceClient { this._log.info('listKeyRings request %j', request); return this.innerApiCalls .listKeyRings(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.kms.v1.IKeyRing[], - protos.google.cloud.kms.v1.IListKeyRingsRequest|null, - protos.google.cloud.kms.v1.IListKeyRingsResponse - ]) => { - this._log.info('listKeyRings values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.kms.v1.IKeyRing[], + protos.google.cloud.kms.v1.IListKeyRingsRequest | null, + protos.google.cloud.kms.v1.IListKeyRingsResponse, + ]) => { + this._log.info('listKeyRings values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listKeyRings`, 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 location associated with the - * {@link protos.google.cloud.kms.v1.KeyRing|KeyRings}, in the format - * `projects/* /locations/*`. - * @param {number} [request.pageSize] - * Optional. Optional limit on the number of - * {@link protos.google.cloud.kms.v1.KeyRing|KeyRings} to include in the response. Further - * {@link protos.google.cloud.kms.v1.KeyRing|KeyRings} can subsequently be obtained by - * including the - * {@link protos.google.cloud.kms.v1.ListKeyRingsResponse.next_page_token|ListKeyRingsResponse.next_page_token} - * in a subsequent request. If unspecified, the server will pick an - * appropriate default. - * @param {string} [request.pageToken] - * Optional. Optional pagination token, returned earlier via - * {@link protos.google.cloud.kms.v1.ListKeyRingsResponse.next_page_token|ListKeyRingsResponse.next_page_token}. - * @param {string} [request.filter] - * Optional. Only include resources that match the filter in the response. For - * more information, see - * [Sorting and filtering list - * results](https://cloud.google.com/kms/docs/sorting-and-filtering). - * @param {string} [request.orderBy] - * Optional. Specify how the results should be sorted. If not specified, the - * results will be sorted in the default order. For more information, see - * [Sorting and filtering list - * results](https://cloud.google.com/kms/docs/sorting-and-filtering). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.kms.v1.KeyRing|KeyRing} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listKeyRingsAsync()` - * method described below for async iteration which you can stop as 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 `listKeyRings`, 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 location associated with the + * {@link protos.google.cloud.kms.v1.KeyRing|KeyRings}, in the format + * `projects/* /locations/*`. + * @param {number} [request.pageSize] + * Optional. Optional limit on the number of + * {@link protos.google.cloud.kms.v1.KeyRing|KeyRings} to include in the response. Further + * {@link protos.google.cloud.kms.v1.KeyRing|KeyRings} can subsequently be obtained by + * including the + * {@link protos.google.cloud.kms.v1.ListKeyRingsResponse.next_page_token|ListKeyRingsResponse.next_page_token} + * in a subsequent request. If unspecified, the server will pick an + * appropriate default. + * @param {string} [request.pageToken] + * Optional. Optional pagination token, returned earlier via + * {@link protos.google.cloud.kms.v1.ListKeyRingsResponse.next_page_token|ListKeyRingsResponse.next_page_token}. + * @param {string} [request.filter] + * Optional. Only include resources that match the filter in the response. For + * more information, see + * [Sorting and filtering list + * results](https://cloud.google.com/kms/docs/sorting-and-filtering). + * @param {string} [request.orderBy] + * Optional. Specify how the results should be sorted. If not specified, the + * results will be sorted in the default order. For more information, see + * [Sorting and filtering list + * results](https://cloud.google.com/kms/docs/sorting-and-filtering). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.kms.v1.KeyRing|KeyRing} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listKeyRingsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listKeyRingsStream( - request?: protos.google.cloud.kms.v1.IListKeyRingsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.kms.v1.IListKeyRingsRequest, + 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['listKeyRings']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listKeyRings stream %j', request); return this.descriptors.page.listKeyRings.createStream( this.innerApiCalls.listKeyRings as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listKeyRings`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used 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 location associated with the - * {@link protos.google.cloud.kms.v1.KeyRing|KeyRings}, in the format - * `projects/* /locations/*`. - * @param {number} [request.pageSize] - * Optional. Optional limit on the number of - * {@link protos.google.cloud.kms.v1.KeyRing|KeyRings} to include in the response. Further - * {@link protos.google.cloud.kms.v1.KeyRing|KeyRings} can subsequently be obtained by - * including the - * {@link protos.google.cloud.kms.v1.ListKeyRingsResponse.next_page_token|ListKeyRingsResponse.next_page_token} - * in a subsequent request. If unspecified, the server will pick an - * appropriate default. - * @param {string} [request.pageToken] - * Optional. Optional pagination token, returned earlier via - * {@link protos.google.cloud.kms.v1.ListKeyRingsResponse.next_page_token|ListKeyRingsResponse.next_page_token}. - * @param {string} [request.filter] - * Optional. Only include resources that match the filter in the response. For - * more information, see - * [Sorting and filtering list - * results](https://cloud.google.com/kms/docs/sorting-and-filtering). - * @param {string} [request.orderBy] - * Optional. Specify how the results should be sorted. If not specified, the - * results will be sorted in the default order. For more information, see - * [Sorting and filtering list - * results](https://cloud.google.com/kms/docs/sorting-and-filtering). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.kms.v1.KeyRing|KeyRing}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@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/key_management_service.list_key_rings.js - * region_tag:cloudkms_v1_generated_KeyManagementService_ListKeyRings_async - */ + /** + * Equivalent to `listKeyRings`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used 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 location associated with the + * {@link protos.google.cloud.kms.v1.KeyRing|KeyRings}, in the format + * `projects/* /locations/*`. + * @param {number} [request.pageSize] + * Optional. Optional limit on the number of + * {@link protos.google.cloud.kms.v1.KeyRing|KeyRings} to include in the response. Further + * {@link protos.google.cloud.kms.v1.KeyRing|KeyRings} can subsequently be obtained by + * including the + * {@link protos.google.cloud.kms.v1.ListKeyRingsResponse.next_page_token|ListKeyRingsResponse.next_page_token} + * in a subsequent request. If unspecified, the server will pick an + * appropriate default. + * @param {string} [request.pageToken] + * Optional. Optional pagination token, returned earlier via + * {@link protos.google.cloud.kms.v1.ListKeyRingsResponse.next_page_token|ListKeyRingsResponse.next_page_token}. + * @param {string} [request.filter] + * Optional. Only include resources that match the filter in the response. For + * more information, see + * [Sorting and filtering list + * results](https://cloud.google.com/kms/docs/sorting-and-filtering). + * @param {string} [request.orderBy] + * Optional. Specify how the results should be sorted. If not specified, the + * results will be sorted in the default order. For more information, see + * [Sorting and filtering list + * results](https://cloud.google.com/kms/docs/sorting-and-filtering). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.kms.v1.KeyRing|KeyRing}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@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/key_management_service.list_key_rings.js + * region_tag:cloudkms_v1_generated_KeyManagementService_ListKeyRings_async + */ listKeyRingsAsync( - request?: protos.google.cloud.kms.v1.IListKeyRingsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.kms.v1.IListKeyRingsRequest, + 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['listKeyRings']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listKeyRings iterate %j', request); return this.descriptors.page.listKeyRings.asyncIterate( this.innerApiCalls['listKeyRings'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKeys}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the {@link protos.google.cloud.kms.v1.KeyRing|KeyRing} - * to list, in the format `projects/* /locations/* /keyRings/*`. - * @param {number} [request.pageSize] - * Optional. Optional limit on the number of - * {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKeys} to include in the response. - * Further {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKeys} can subsequently be - * obtained by including the - * {@link protos.google.cloud.kms.v1.ListCryptoKeysResponse.next_page_token|ListCryptoKeysResponse.next_page_token} - * in a subsequent request. If unspecified, the server will pick an - * appropriate default. - * @param {string} [request.pageToken] - * Optional. Optional pagination token, returned earlier via - * {@link protos.google.cloud.kms.v1.ListCryptoKeysResponse.next_page_token|ListCryptoKeysResponse.next_page_token}. - * @param {google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionView} request.versionView - * The fields of the primary version to include in the response. - * @param {string} [request.filter] - * Optional. Only include resources that match the filter in the response. For - * more information, see - * [Sorting and filtering list - * results](https://cloud.google.com/kms/docs/sorting-and-filtering). - * @param {string} [request.orderBy] - * Optional. Specify how the results should be sorted. If not specified, the - * results will be sorted in the default order. For more information, see - * [Sorting and filtering list - * results](https://cloud.google.com/kms/docs/sorting-and-filtering). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listCryptoKeysAsync()` - * method described below for async iteration which you can stop as 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 {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKeys}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the {@link protos.google.cloud.kms.v1.KeyRing|KeyRing} + * to list, in the format `projects/* /locations/* /keyRings/*`. + * @param {number} [request.pageSize] + * Optional. Optional limit on the number of + * {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKeys} to include in the response. + * Further {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKeys} can subsequently be + * obtained by including the + * {@link protos.google.cloud.kms.v1.ListCryptoKeysResponse.next_page_token|ListCryptoKeysResponse.next_page_token} + * in a subsequent request. If unspecified, the server will pick an + * appropriate default. + * @param {string} [request.pageToken] + * Optional. Optional pagination token, returned earlier via + * {@link protos.google.cloud.kms.v1.ListCryptoKeysResponse.next_page_token|ListCryptoKeysResponse.next_page_token}. + * @param {google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionView} request.versionView + * The fields of the primary version to include in the response. + * @param {string} [request.filter] + * Optional. Only include resources that match the filter in the response. For + * more information, see + * [Sorting and filtering list + * results](https://cloud.google.com/kms/docs/sorting-and-filtering). + * @param {string} [request.orderBy] + * Optional. Specify how the results should be sorted. If not specified, the + * results will be sorted in the default order. For more information, see + * [Sorting and filtering list + * results](https://cloud.google.com/kms/docs/sorting-and-filtering). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listCryptoKeysAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listCryptoKeys( - request?: protos.google.cloud.kms.v1.IListCryptoKeysRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.kms.v1.ICryptoKey[], - protos.google.cloud.kms.v1.IListCryptoKeysRequest|null, - protos.google.cloud.kms.v1.IListCryptoKeysResponse - ]>; + request?: protos.google.cloud.kms.v1.IListCryptoKeysRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.kms.v1.ICryptoKey[], + protos.google.cloud.kms.v1.IListCryptoKeysRequest | null, + protos.google.cloud.kms.v1.IListCryptoKeysResponse, + ] + >; listCryptoKeys( - request: protos.google.cloud.kms.v1.IListCryptoKeysRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.kms.v1.IListCryptoKeysRequest, - protos.google.cloud.kms.v1.IListCryptoKeysResponse|null|undefined, - protos.google.cloud.kms.v1.ICryptoKey>): void; + request: protos.google.cloud.kms.v1.IListCryptoKeysRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.kms.v1.IListCryptoKeysRequest, + protos.google.cloud.kms.v1.IListCryptoKeysResponse | null | undefined, + protos.google.cloud.kms.v1.ICryptoKey + >, + ): void; listCryptoKeys( - request: protos.google.cloud.kms.v1.IListCryptoKeysRequest, - callback: PaginationCallback< - protos.google.cloud.kms.v1.IListCryptoKeysRequest, - protos.google.cloud.kms.v1.IListCryptoKeysResponse|null|undefined, - protos.google.cloud.kms.v1.ICryptoKey>): void; + request: protos.google.cloud.kms.v1.IListCryptoKeysRequest, + callback: PaginationCallback< + protos.google.cloud.kms.v1.IListCryptoKeysRequest, + protos.google.cloud.kms.v1.IListCryptoKeysResponse | null | undefined, + protos.google.cloud.kms.v1.ICryptoKey + >, + ): void; listCryptoKeys( - request?: protos.google.cloud.kms.v1.IListCryptoKeysRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.kms.v1.IListCryptoKeysRequest, - protos.google.cloud.kms.v1.IListCryptoKeysResponse|null|undefined, - protos.google.cloud.kms.v1.ICryptoKey>, - callback?: PaginationCallback< + request?: protos.google.cloud.kms.v1.IListCryptoKeysRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.kms.v1.IListCryptoKeysRequest, - protos.google.cloud.kms.v1.IListCryptoKeysResponse|null|undefined, - protos.google.cloud.kms.v1.ICryptoKey>): - Promise<[ - protos.google.cloud.kms.v1.ICryptoKey[], - protos.google.cloud.kms.v1.IListCryptoKeysRequest|null, - protos.google.cloud.kms.v1.IListCryptoKeysResponse - ]>|void { + protos.google.cloud.kms.v1.IListCryptoKeysResponse | null | undefined, + protos.google.cloud.kms.v1.ICryptoKey + >, + callback?: PaginationCallback< + protos.google.cloud.kms.v1.IListCryptoKeysRequest, + protos.google.cloud.kms.v1.IListCryptoKeysResponse | null | undefined, + protos.google.cloud.kms.v1.ICryptoKey + >, + ): Promise< + [ + protos.google.cloud.kms.v1.ICryptoKey[], + protos.google.cloud.kms.v1.IListCryptoKeysRequest | null, + protos.google.cloud.kms.v1.IListCryptoKeysResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-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.kms.v1.IListCryptoKeysRequest, - protos.google.cloud.kms.v1.IListCryptoKeysResponse|null|undefined, - protos.google.cloud.kms.v1.ICryptoKey>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.kms.v1.IListCryptoKeysRequest, + protos.google.cloud.kms.v1.IListCryptoKeysResponse | null | undefined, + protos.google.cloud.kms.v1.ICryptoKey + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listCryptoKeys values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -4182,250 +5398,279 @@ export class KeyManagementServiceClient { this._log.info('listCryptoKeys request %j', request); return this.innerApiCalls .listCryptoKeys(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.kms.v1.ICryptoKey[], - protos.google.cloud.kms.v1.IListCryptoKeysRequest|null, - protos.google.cloud.kms.v1.IListCryptoKeysResponse - ]) => { - this._log.info('listCryptoKeys values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.kms.v1.ICryptoKey[], + protos.google.cloud.kms.v1.IListCryptoKeysRequest | null, + protos.google.cloud.kms.v1.IListCryptoKeysResponse, + ]) => { + this._log.info('listCryptoKeys values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listCryptoKeys`, 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 {@link protos.google.cloud.kms.v1.KeyRing|KeyRing} - * to list, in the format `projects/* /locations/* /keyRings/*`. - * @param {number} [request.pageSize] - * Optional. Optional limit on the number of - * {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKeys} to include in the response. - * Further {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKeys} can subsequently be - * obtained by including the - * {@link protos.google.cloud.kms.v1.ListCryptoKeysResponse.next_page_token|ListCryptoKeysResponse.next_page_token} - * in a subsequent request. If unspecified, the server will pick an - * appropriate default. - * @param {string} [request.pageToken] - * Optional. Optional pagination token, returned earlier via - * {@link protos.google.cloud.kms.v1.ListCryptoKeysResponse.next_page_token|ListCryptoKeysResponse.next_page_token}. - * @param {google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionView} request.versionView - * The fields of the primary version to include in the response. - * @param {string} [request.filter] - * Optional. Only include resources that match the filter in the response. For - * more information, see - * [Sorting and filtering list - * results](https://cloud.google.com/kms/docs/sorting-and-filtering). - * @param {string} [request.orderBy] - * Optional. Specify how the results should be sorted. If not specified, the - * results will be sorted in the default order. For more information, see - * [Sorting and filtering list - * results](https://cloud.google.com/kms/docs/sorting-and-filtering). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listCryptoKeysAsync()` - * method described below for async iteration which you can stop as 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 `listCryptoKeys`, 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 {@link protos.google.cloud.kms.v1.KeyRing|KeyRing} + * to list, in the format `projects/* /locations/* /keyRings/*`. + * @param {number} [request.pageSize] + * Optional. Optional limit on the number of + * {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKeys} to include in the response. + * Further {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKeys} can subsequently be + * obtained by including the + * {@link protos.google.cloud.kms.v1.ListCryptoKeysResponse.next_page_token|ListCryptoKeysResponse.next_page_token} + * in a subsequent request. If unspecified, the server will pick an + * appropriate default. + * @param {string} [request.pageToken] + * Optional. Optional pagination token, returned earlier via + * {@link protos.google.cloud.kms.v1.ListCryptoKeysResponse.next_page_token|ListCryptoKeysResponse.next_page_token}. + * @param {google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionView} request.versionView + * The fields of the primary version to include in the response. + * @param {string} [request.filter] + * Optional. Only include resources that match the filter in the response. For + * more information, see + * [Sorting and filtering list + * results](https://cloud.google.com/kms/docs/sorting-and-filtering). + * @param {string} [request.orderBy] + * Optional. Specify how the results should be sorted. If not specified, the + * results will be sorted in the default order. For more information, see + * [Sorting and filtering list + * results](https://cloud.google.com/kms/docs/sorting-and-filtering). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listCryptoKeysAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listCryptoKeysStream( - request?: protos.google.cloud.kms.v1.IListCryptoKeysRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.kms.v1.IListCryptoKeysRequest, + 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['listCryptoKeys']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listCryptoKeys stream %j', request); return this.descriptors.page.listCryptoKeys.createStream( this.innerApiCalls.listCryptoKeys as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listCryptoKeys`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used 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 {@link protos.google.cloud.kms.v1.KeyRing|KeyRing} - * to list, in the format `projects/* /locations/* /keyRings/*`. - * @param {number} [request.pageSize] - * Optional. Optional limit on the number of - * {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKeys} to include in the response. - * Further {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKeys} can subsequently be - * obtained by including the - * {@link protos.google.cloud.kms.v1.ListCryptoKeysResponse.next_page_token|ListCryptoKeysResponse.next_page_token} - * in a subsequent request. If unspecified, the server will pick an - * appropriate default. - * @param {string} [request.pageToken] - * Optional. Optional pagination token, returned earlier via - * {@link protos.google.cloud.kms.v1.ListCryptoKeysResponse.next_page_token|ListCryptoKeysResponse.next_page_token}. - * @param {google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionView} request.versionView - * The fields of the primary version to include in the response. - * @param {string} [request.filter] - * Optional. Only include resources that match the filter in the response. For - * more information, see - * [Sorting and filtering list - * results](https://cloud.google.com/kms/docs/sorting-and-filtering). - * @param {string} [request.orderBy] - * Optional. Specify how the results should be sorted. If not specified, the - * results will be sorted in the default order. For more information, see - * [Sorting and filtering list - * results](https://cloud.google.com/kms/docs/sorting-and-filtering). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@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/key_management_service.list_crypto_keys.js - * region_tag:cloudkms_v1_generated_KeyManagementService_ListCryptoKeys_async - */ + /** + * Equivalent to `listCryptoKeys`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used 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 {@link protos.google.cloud.kms.v1.KeyRing|KeyRing} + * to list, in the format `projects/* /locations/* /keyRings/*`. + * @param {number} [request.pageSize] + * Optional. Optional limit on the number of + * {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKeys} to include in the response. + * Further {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKeys} can subsequently be + * obtained by including the + * {@link protos.google.cloud.kms.v1.ListCryptoKeysResponse.next_page_token|ListCryptoKeysResponse.next_page_token} + * in a subsequent request. If unspecified, the server will pick an + * appropriate default. + * @param {string} [request.pageToken] + * Optional. Optional pagination token, returned earlier via + * {@link protos.google.cloud.kms.v1.ListCryptoKeysResponse.next_page_token|ListCryptoKeysResponse.next_page_token}. + * @param {google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionView} request.versionView + * The fields of the primary version to include in the response. + * @param {string} [request.filter] + * Optional. Only include resources that match the filter in the response. For + * more information, see + * [Sorting and filtering list + * results](https://cloud.google.com/kms/docs/sorting-and-filtering). + * @param {string} [request.orderBy] + * Optional. Specify how the results should be sorted. If not specified, the + * results will be sorted in the default order. For more information, see + * [Sorting and filtering list + * results](https://cloud.google.com/kms/docs/sorting-and-filtering). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@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/key_management_service.list_crypto_keys.js + * region_tag:cloudkms_v1_generated_KeyManagementService_ListCryptoKeys_async + */ listCryptoKeysAsync( - request?: protos.google.cloud.kms.v1.IListCryptoKeysRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.kms.v1.IListCryptoKeysRequest, + 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['listCryptoKeys']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listCryptoKeys iterate %j', request); return this.descriptors.page.listCryptoKeys.asyncIterate( this.innerApiCalls['listCryptoKeys'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersions}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the - * {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey} to list, in the format - * `projects/* /locations/* /keyRings/* /cryptoKeys/*`. - * @param {number} [request.pageSize] - * Optional. Optional limit on the number of - * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersions} to include in the - * response. Further {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersions} - * can subsequently be obtained by including the - * {@link protos.google.cloud.kms.v1.ListCryptoKeyVersionsResponse.next_page_token|ListCryptoKeyVersionsResponse.next_page_token} - * in a subsequent request. If unspecified, the server will pick an - * appropriate default. - * @param {string} [request.pageToken] - * Optional. Optional pagination token, returned earlier via - * {@link protos.google.cloud.kms.v1.ListCryptoKeyVersionsResponse.next_page_token|ListCryptoKeyVersionsResponse.next_page_token}. - * @param {google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionView} request.view - * The fields to include in the response. - * @param {string} [request.filter] - * Optional. Only include resources that match the filter in the response. For - * more information, see - * [Sorting and filtering list - * results](https://cloud.google.com/kms/docs/sorting-and-filtering). - * @param {string} [request.orderBy] - * Optional. Specify how the results should be sorted. If not specified, the - * results will be sorted in the default order. For more information, see - * [Sorting and filtering list - * results](https://cloud.google.com/kms/docs/sorting-and-filtering). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listCryptoKeyVersionsAsync()` - * method described below for async iteration which you can stop as 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 {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersions}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the + * {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey} to list, in the format + * `projects/* /locations/* /keyRings/* /cryptoKeys/*`. + * @param {number} [request.pageSize] + * Optional. Optional limit on the number of + * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersions} to include in the + * response. Further {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersions} + * can subsequently be obtained by including the + * {@link protos.google.cloud.kms.v1.ListCryptoKeyVersionsResponse.next_page_token|ListCryptoKeyVersionsResponse.next_page_token} + * in a subsequent request. If unspecified, the server will pick an + * appropriate default. + * @param {string} [request.pageToken] + * Optional. Optional pagination token, returned earlier via + * {@link protos.google.cloud.kms.v1.ListCryptoKeyVersionsResponse.next_page_token|ListCryptoKeyVersionsResponse.next_page_token}. + * @param {google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionView} request.view + * The fields to include in the response. + * @param {string} [request.filter] + * Optional. Only include resources that match the filter in the response. For + * more information, see + * [Sorting and filtering list + * results](https://cloud.google.com/kms/docs/sorting-and-filtering). + * @param {string} [request.orderBy] + * Optional. Specify how the results should be sorted. If not specified, the + * results will be sorted in the default order. For more information, see + * [Sorting and filtering list + * results](https://cloud.google.com/kms/docs/sorting-and-filtering). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listCryptoKeyVersionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listCryptoKeyVersions( - request?: protos.google.cloud.kms.v1.IListCryptoKeyVersionsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.kms.v1.ICryptoKeyVersion[], - protos.google.cloud.kms.v1.IListCryptoKeyVersionsRequest|null, - protos.google.cloud.kms.v1.IListCryptoKeyVersionsResponse - ]>; + request?: protos.google.cloud.kms.v1.IListCryptoKeyVersionsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.kms.v1.ICryptoKeyVersion[], + protos.google.cloud.kms.v1.IListCryptoKeyVersionsRequest | null, + protos.google.cloud.kms.v1.IListCryptoKeyVersionsResponse, + ] + >; listCryptoKeyVersions( - request: protos.google.cloud.kms.v1.IListCryptoKeyVersionsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.kms.v1.IListCryptoKeyVersionsRequest, - protos.google.cloud.kms.v1.IListCryptoKeyVersionsResponse|null|undefined, - protos.google.cloud.kms.v1.ICryptoKeyVersion>): void; + request: protos.google.cloud.kms.v1.IListCryptoKeyVersionsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.kms.v1.IListCryptoKeyVersionsRequest, + | protos.google.cloud.kms.v1.IListCryptoKeyVersionsResponse + | null + | undefined, + protos.google.cloud.kms.v1.ICryptoKeyVersion + >, + ): void; listCryptoKeyVersions( - request: protos.google.cloud.kms.v1.IListCryptoKeyVersionsRequest, - callback: PaginationCallback< - protos.google.cloud.kms.v1.IListCryptoKeyVersionsRequest, - protos.google.cloud.kms.v1.IListCryptoKeyVersionsResponse|null|undefined, - protos.google.cloud.kms.v1.ICryptoKeyVersion>): void; + request: protos.google.cloud.kms.v1.IListCryptoKeyVersionsRequest, + callback: PaginationCallback< + protos.google.cloud.kms.v1.IListCryptoKeyVersionsRequest, + | protos.google.cloud.kms.v1.IListCryptoKeyVersionsResponse + | null + | undefined, + protos.google.cloud.kms.v1.ICryptoKeyVersion + >, + ): void; listCryptoKeyVersions( - request?: protos.google.cloud.kms.v1.IListCryptoKeyVersionsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.kms.v1.IListCryptoKeyVersionsRequest, - protos.google.cloud.kms.v1.IListCryptoKeyVersionsResponse|null|undefined, - protos.google.cloud.kms.v1.ICryptoKeyVersion>, - callback?: PaginationCallback< + request?: protos.google.cloud.kms.v1.IListCryptoKeyVersionsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.kms.v1.IListCryptoKeyVersionsRequest, - protos.google.cloud.kms.v1.IListCryptoKeyVersionsResponse|null|undefined, - protos.google.cloud.kms.v1.ICryptoKeyVersion>): - Promise<[ - protos.google.cloud.kms.v1.ICryptoKeyVersion[], - protos.google.cloud.kms.v1.IListCryptoKeyVersionsRequest|null, - protos.google.cloud.kms.v1.IListCryptoKeyVersionsResponse - ]>|void { + | protos.google.cloud.kms.v1.IListCryptoKeyVersionsResponse + | null + | undefined, + protos.google.cloud.kms.v1.ICryptoKeyVersion + >, + callback?: PaginationCallback< + protos.google.cloud.kms.v1.IListCryptoKeyVersionsRequest, + | protos.google.cloud.kms.v1.IListCryptoKeyVersionsResponse + | null + | undefined, + protos.google.cloud.kms.v1.ICryptoKeyVersion + >, + ): Promise< + [ + protos.google.cloud.kms.v1.ICryptoKeyVersion[], + protos.google.cloud.kms.v1.IListCryptoKeyVersionsRequest | null, + protos.google.cloud.kms.v1.IListCryptoKeyVersionsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-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.kms.v1.IListCryptoKeyVersionsRequest, - protos.google.cloud.kms.v1.IListCryptoKeyVersionsResponse|null|undefined, - protos.google.cloud.kms.v1.ICryptoKeyVersion>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.kms.v1.IListCryptoKeyVersionsRequest, + | protos.google.cloud.kms.v1.IListCryptoKeyVersionsResponse + | null + | undefined, + protos.google.cloud.kms.v1.ICryptoKeyVersion + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listCryptoKeyVersions values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -4434,249 +5679,268 @@ export class KeyManagementServiceClient { this._log.info('listCryptoKeyVersions request %j', request); return this.innerApiCalls .listCryptoKeyVersions(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.kms.v1.ICryptoKeyVersion[], - protos.google.cloud.kms.v1.IListCryptoKeyVersionsRequest|null, - protos.google.cloud.kms.v1.IListCryptoKeyVersionsResponse - ]) => { - this._log.info('listCryptoKeyVersions values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.kms.v1.ICryptoKeyVersion[], + protos.google.cloud.kms.v1.IListCryptoKeyVersionsRequest | null, + protos.google.cloud.kms.v1.IListCryptoKeyVersionsResponse, + ]) => { + this._log.info('listCryptoKeyVersions values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listCryptoKeyVersions`, 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 - * {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey} to list, in the format - * `projects/* /locations/* /keyRings/* /cryptoKeys/*`. - * @param {number} [request.pageSize] - * Optional. Optional limit on the number of - * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersions} to include in the - * response. Further {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersions} - * can subsequently be obtained by including the - * {@link protos.google.cloud.kms.v1.ListCryptoKeyVersionsResponse.next_page_token|ListCryptoKeyVersionsResponse.next_page_token} - * in a subsequent request. If unspecified, the server will pick an - * appropriate default. - * @param {string} [request.pageToken] - * Optional. Optional pagination token, returned earlier via - * {@link protos.google.cloud.kms.v1.ListCryptoKeyVersionsResponse.next_page_token|ListCryptoKeyVersionsResponse.next_page_token}. - * @param {google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionView} request.view - * The fields to include in the response. - * @param {string} [request.filter] - * Optional. Only include resources that match the filter in the response. For - * more information, see - * [Sorting and filtering list - * results](https://cloud.google.com/kms/docs/sorting-and-filtering). - * @param {string} [request.orderBy] - * Optional. Specify how the results should be sorted. If not specified, the - * results will be sorted in the default order. For more information, see - * [Sorting and filtering list - * results](https://cloud.google.com/kms/docs/sorting-and-filtering). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listCryptoKeyVersionsAsync()` - * method described below for async iteration which you can stop as 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 `listCryptoKeyVersions`, 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 + * {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey} to list, in the format + * `projects/* /locations/* /keyRings/* /cryptoKeys/*`. + * @param {number} [request.pageSize] + * Optional. Optional limit on the number of + * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersions} to include in the + * response. Further {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersions} + * can subsequently be obtained by including the + * {@link protos.google.cloud.kms.v1.ListCryptoKeyVersionsResponse.next_page_token|ListCryptoKeyVersionsResponse.next_page_token} + * in a subsequent request. If unspecified, the server will pick an + * appropriate default. + * @param {string} [request.pageToken] + * Optional. Optional pagination token, returned earlier via + * {@link protos.google.cloud.kms.v1.ListCryptoKeyVersionsResponse.next_page_token|ListCryptoKeyVersionsResponse.next_page_token}. + * @param {google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionView} request.view + * The fields to include in the response. + * @param {string} [request.filter] + * Optional. Only include resources that match the filter in the response. For + * more information, see + * [Sorting and filtering list + * results](https://cloud.google.com/kms/docs/sorting-and-filtering). + * @param {string} [request.orderBy] + * Optional. Specify how the results should be sorted. If not specified, the + * results will be sorted in the default order. For more information, see + * [Sorting and filtering list + * results](https://cloud.google.com/kms/docs/sorting-and-filtering). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listCryptoKeyVersionsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listCryptoKeyVersionsStream( - request?: protos.google.cloud.kms.v1.IListCryptoKeyVersionsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.kms.v1.IListCryptoKeyVersionsRequest, + 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['listCryptoKeyVersions']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listCryptoKeyVersions stream %j', request); return this.descriptors.page.listCryptoKeyVersions.createStream( this.innerApiCalls.listCryptoKeyVersions as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listCryptoKeyVersions`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used 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 - * {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey} to list, in the format - * `projects/* /locations/* /keyRings/* /cryptoKeys/*`. - * @param {number} [request.pageSize] - * Optional. Optional limit on the number of - * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersions} to include in the - * response. Further {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersions} - * can subsequently be obtained by including the - * {@link protos.google.cloud.kms.v1.ListCryptoKeyVersionsResponse.next_page_token|ListCryptoKeyVersionsResponse.next_page_token} - * in a subsequent request. If unspecified, the server will pick an - * appropriate default. - * @param {string} [request.pageToken] - * Optional. Optional pagination token, returned earlier via - * {@link protos.google.cloud.kms.v1.ListCryptoKeyVersionsResponse.next_page_token|ListCryptoKeyVersionsResponse.next_page_token}. - * @param {google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionView} request.view - * The fields to include in the response. - * @param {string} [request.filter] - * Optional. Only include resources that match the filter in the response. For - * more information, see - * [Sorting and filtering list - * results](https://cloud.google.com/kms/docs/sorting-and-filtering). - * @param {string} [request.orderBy] - * Optional. Specify how the results should be sorted. If not specified, the - * results will be sorted in the default order. For more information, see - * [Sorting and filtering list - * results](https://cloud.google.com/kms/docs/sorting-and-filtering). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@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/key_management_service.list_crypto_key_versions.js - * region_tag:cloudkms_v1_generated_KeyManagementService_ListCryptoKeyVersions_async - */ + /** + * Equivalent to `listCryptoKeyVersions`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used 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 + * {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKey} to list, in the format + * `projects/* /locations/* /keyRings/* /cryptoKeys/*`. + * @param {number} [request.pageSize] + * Optional. Optional limit on the number of + * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersions} to include in the + * response. Further {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersions} + * can subsequently be obtained by including the + * {@link protos.google.cloud.kms.v1.ListCryptoKeyVersionsResponse.next_page_token|ListCryptoKeyVersionsResponse.next_page_token} + * in a subsequent request. If unspecified, the server will pick an + * appropriate default. + * @param {string} [request.pageToken] + * Optional. Optional pagination token, returned earlier via + * {@link protos.google.cloud.kms.v1.ListCryptoKeyVersionsResponse.next_page_token|ListCryptoKeyVersionsResponse.next_page_token}. + * @param {google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionView} request.view + * The fields to include in the response. + * @param {string} [request.filter] + * Optional. Only include resources that match the filter in the response. For + * more information, see + * [Sorting and filtering list + * results](https://cloud.google.com/kms/docs/sorting-and-filtering). + * @param {string} [request.orderBy] + * Optional. Specify how the results should be sorted. If not specified, the + * results will be sorted in the default order. For more information, see + * [Sorting and filtering list + * results](https://cloud.google.com/kms/docs/sorting-and-filtering). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@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/key_management_service.list_crypto_key_versions.js + * region_tag:cloudkms_v1_generated_KeyManagementService_ListCryptoKeyVersions_async + */ listCryptoKeyVersionsAsync( - request?: protos.google.cloud.kms.v1.IListCryptoKeyVersionsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.kms.v1.IListCryptoKeyVersionsRequest, + 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['listCryptoKeyVersions']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listCryptoKeyVersions iterate %j', request); return this.descriptors.page.listCryptoKeyVersions.asyncIterate( this.innerApiCalls['listCryptoKeyVersions'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists {@link protos.google.cloud.kms.v1.ImportJob|ImportJobs}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the {@link protos.google.cloud.kms.v1.KeyRing|KeyRing} - * to list, in the format `projects/* /locations/* /keyRings/*`. - * @param {number} [request.pageSize] - * Optional. Optional limit on the number of - * {@link protos.google.cloud.kms.v1.ImportJob|ImportJobs} to include in the response. - * Further {@link protos.google.cloud.kms.v1.ImportJob|ImportJobs} can subsequently be - * obtained by including the - * {@link protos.google.cloud.kms.v1.ListImportJobsResponse.next_page_token|ListImportJobsResponse.next_page_token} - * in a subsequent request. If unspecified, the server will pick an - * appropriate default. - * @param {string} [request.pageToken] - * Optional. Optional pagination token, returned earlier via - * {@link protos.google.cloud.kms.v1.ListImportJobsResponse.next_page_token|ListImportJobsResponse.next_page_token}. - * @param {string} [request.filter] - * Optional. Only include resources that match the filter in the response. For - * more information, see - * [Sorting and filtering list - * results](https://cloud.google.com/kms/docs/sorting-and-filtering). - * @param {string} [request.orderBy] - * Optional. Specify how the results should be sorted. If not specified, the - * results will be sorted in the default order. For more information, see - * [Sorting and filtering list - * results](https://cloud.google.com/kms/docs/sorting-and-filtering). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link protos.google.cloud.kms.v1.ImportJob|ImportJob}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listImportJobsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists {@link protos.google.cloud.kms.v1.ImportJob|ImportJobs}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the {@link protos.google.cloud.kms.v1.KeyRing|KeyRing} + * to list, in the format `projects/* /locations/* /keyRings/*`. + * @param {number} [request.pageSize] + * Optional. Optional limit on the number of + * {@link protos.google.cloud.kms.v1.ImportJob|ImportJobs} to include in the response. + * Further {@link protos.google.cloud.kms.v1.ImportJob|ImportJobs} can subsequently be + * obtained by including the + * {@link protos.google.cloud.kms.v1.ListImportJobsResponse.next_page_token|ListImportJobsResponse.next_page_token} + * in a subsequent request. If unspecified, the server will pick an + * appropriate default. + * @param {string} [request.pageToken] + * Optional. Optional pagination token, returned earlier via + * {@link protos.google.cloud.kms.v1.ListImportJobsResponse.next_page_token|ListImportJobsResponse.next_page_token}. + * @param {string} [request.filter] + * Optional. Only include resources that match the filter in the response. For + * more information, see + * [Sorting and filtering list + * results](https://cloud.google.com/kms/docs/sorting-and-filtering). + * @param {string} [request.orderBy] + * Optional. Specify how the results should be sorted. If not specified, the + * results will be sorted in the default order. For more information, see + * [Sorting and filtering list + * results](https://cloud.google.com/kms/docs/sorting-and-filtering). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.kms.v1.ImportJob|ImportJob}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listImportJobsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listImportJobs( - request?: protos.google.cloud.kms.v1.IListImportJobsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.kms.v1.IImportJob[], - protos.google.cloud.kms.v1.IListImportJobsRequest|null, - protos.google.cloud.kms.v1.IListImportJobsResponse - ]>; + request?: protos.google.cloud.kms.v1.IListImportJobsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.kms.v1.IImportJob[], + protos.google.cloud.kms.v1.IListImportJobsRequest | null, + protos.google.cloud.kms.v1.IListImportJobsResponse, + ] + >; listImportJobs( - request: protos.google.cloud.kms.v1.IListImportJobsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.kms.v1.IListImportJobsRequest, - protos.google.cloud.kms.v1.IListImportJobsResponse|null|undefined, - protos.google.cloud.kms.v1.IImportJob>): void; + request: protos.google.cloud.kms.v1.IListImportJobsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.kms.v1.IListImportJobsRequest, + protos.google.cloud.kms.v1.IListImportJobsResponse | null | undefined, + protos.google.cloud.kms.v1.IImportJob + >, + ): void; listImportJobs( - request: protos.google.cloud.kms.v1.IListImportJobsRequest, - callback: PaginationCallback< - protos.google.cloud.kms.v1.IListImportJobsRequest, - protos.google.cloud.kms.v1.IListImportJobsResponse|null|undefined, - protos.google.cloud.kms.v1.IImportJob>): void; + request: protos.google.cloud.kms.v1.IListImportJobsRequest, + callback: PaginationCallback< + protos.google.cloud.kms.v1.IListImportJobsRequest, + protos.google.cloud.kms.v1.IListImportJobsResponse | null | undefined, + protos.google.cloud.kms.v1.IImportJob + >, + ): void; listImportJobs( - request?: protos.google.cloud.kms.v1.IListImportJobsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.kms.v1.IListImportJobsRequest, - protos.google.cloud.kms.v1.IListImportJobsResponse|null|undefined, - protos.google.cloud.kms.v1.IImportJob>, - callback?: PaginationCallback< + request?: protos.google.cloud.kms.v1.IListImportJobsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.kms.v1.IListImportJobsRequest, - protos.google.cloud.kms.v1.IListImportJobsResponse|null|undefined, - protos.google.cloud.kms.v1.IImportJob>): - Promise<[ - protos.google.cloud.kms.v1.IImportJob[], - protos.google.cloud.kms.v1.IListImportJobsRequest|null, - protos.google.cloud.kms.v1.IListImportJobsResponse - ]>|void { + protos.google.cloud.kms.v1.IListImportJobsResponse | null | undefined, + protos.google.cloud.kms.v1.IImportJob + >, + callback?: PaginationCallback< + protos.google.cloud.kms.v1.IListImportJobsRequest, + protos.google.cloud.kms.v1.IListImportJobsResponse | null | undefined, + protos.google.cloud.kms.v1.IImportJob + >, + ): Promise< + [ + protos.google.cloud.kms.v1.IImportJob[], + protos.google.cloud.kms.v1.IListImportJobsRequest | null, + protos.google.cloud.kms.v1.IListImportJobsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.kms.v1.IListImportJobsRequest, - protos.google.cloud.kms.v1.IListImportJobsResponse|null|undefined, - protos.google.cloud.kms.v1.IImportJob>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.kms.v1.IListImportJobsRequest, + protos.google.cloud.kms.v1.IListImportJobsResponse | null | undefined, + protos.google.cloud.kms.v1.IImportJob + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listImportJobs values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -4685,237 +5949,266 @@ export class KeyManagementServiceClient { this._log.info('listImportJobs request %j', request); return this.innerApiCalls .listImportJobs(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.kms.v1.IImportJob[], - protos.google.cloud.kms.v1.IListImportJobsRequest|null, - protos.google.cloud.kms.v1.IListImportJobsResponse - ]) => { - this._log.info('listImportJobs values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.kms.v1.IImportJob[], + protos.google.cloud.kms.v1.IListImportJobsRequest | null, + protos.google.cloud.kms.v1.IListImportJobsResponse, + ]) => { + this._log.info('listImportJobs values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listImportJobs`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the {@link protos.google.cloud.kms.v1.KeyRing|KeyRing} - * to list, in the format `projects/* /locations/* /keyRings/*`. - * @param {number} [request.pageSize] - * Optional. Optional limit on the number of - * {@link protos.google.cloud.kms.v1.ImportJob|ImportJobs} to include in the response. - * Further {@link protos.google.cloud.kms.v1.ImportJob|ImportJobs} can subsequently be - * obtained by including the - * {@link protos.google.cloud.kms.v1.ListImportJobsResponse.next_page_token|ListImportJobsResponse.next_page_token} - * in a subsequent request. If unspecified, the server will pick an - * appropriate default. - * @param {string} [request.pageToken] - * Optional. Optional pagination token, returned earlier via - * {@link protos.google.cloud.kms.v1.ListImportJobsResponse.next_page_token|ListImportJobsResponse.next_page_token}. - * @param {string} [request.filter] - * Optional. Only include resources that match the filter in the response. For - * more information, see - * [Sorting and filtering list - * results](https://cloud.google.com/kms/docs/sorting-and-filtering). - * @param {string} [request.orderBy] - * Optional. Specify how the results should be sorted. If not specified, the - * results will be sorted in the default order. For more information, see - * [Sorting and filtering list - * results](https://cloud.google.com/kms/docs/sorting-and-filtering). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.kms.v1.ImportJob|ImportJob} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listImportJobsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listImportJobs`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the {@link protos.google.cloud.kms.v1.KeyRing|KeyRing} + * to list, in the format `projects/* /locations/* /keyRings/*`. + * @param {number} [request.pageSize] + * Optional. Optional limit on the number of + * {@link protos.google.cloud.kms.v1.ImportJob|ImportJobs} to include in the response. + * Further {@link protos.google.cloud.kms.v1.ImportJob|ImportJobs} can subsequently be + * obtained by including the + * {@link protos.google.cloud.kms.v1.ListImportJobsResponse.next_page_token|ListImportJobsResponse.next_page_token} + * in a subsequent request. If unspecified, the server will pick an + * appropriate default. + * @param {string} [request.pageToken] + * Optional. Optional pagination token, returned earlier via + * {@link protos.google.cloud.kms.v1.ListImportJobsResponse.next_page_token|ListImportJobsResponse.next_page_token}. + * @param {string} [request.filter] + * Optional. Only include resources that match the filter in the response. For + * more information, see + * [Sorting and filtering list + * results](https://cloud.google.com/kms/docs/sorting-and-filtering). + * @param {string} [request.orderBy] + * Optional. Specify how the results should be sorted. If not specified, the + * results will be sorted in the default order. For more information, see + * [Sorting and filtering list + * results](https://cloud.google.com/kms/docs/sorting-and-filtering). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.kms.v1.ImportJob|ImportJob} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listImportJobsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listImportJobsStream( - request?: protos.google.cloud.kms.v1.IListImportJobsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.kms.v1.IListImportJobsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listImportJobs']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listImportJobs stream %j', request); return this.descriptors.page.listImportJobs.createStream( this.innerApiCalls.listImportJobs as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listImportJobs`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the {@link protos.google.cloud.kms.v1.KeyRing|KeyRing} - * to list, in the format `projects/* /locations/* /keyRings/*`. - * @param {number} [request.pageSize] - * Optional. Optional limit on the number of - * {@link protos.google.cloud.kms.v1.ImportJob|ImportJobs} to include in the response. - * Further {@link protos.google.cloud.kms.v1.ImportJob|ImportJobs} can subsequently be - * obtained by including the - * {@link protos.google.cloud.kms.v1.ListImportJobsResponse.next_page_token|ListImportJobsResponse.next_page_token} - * in a subsequent request. If unspecified, the server will pick an - * appropriate default. - * @param {string} [request.pageToken] - * Optional. Optional pagination token, returned earlier via - * {@link protos.google.cloud.kms.v1.ListImportJobsResponse.next_page_token|ListImportJobsResponse.next_page_token}. - * @param {string} [request.filter] - * Optional. Only include resources that match the filter in the response. For - * more information, see - * [Sorting and filtering list - * results](https://cloud.google.com/kms/docs/sorting-and-filtering). - * @param {string} [request.orderBy] - * Optional. Specify how the results should be sorted. If not specified, the - * results will be sorted in the default order. For more information, see - * [Sorting and filtering list - * results](https://cloud.google.com/kms/docs/sorting-and-filtering). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.kms.v1.ImportJob|ImportJob}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/key_management_service.list_import_jobs.js - * region_tag:cloudkms_v1_generated_KeyManagementService_ListImportJobs_async - */ + /** + * Equivalent to `listImportJobs`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the {@link protos.google.cloud.kms.v1.KeyRing|KeyRing} + * to list, in the format `projects/* /locations/* /keyRings/*`. + * @param {number} [request.pageSize] + * Optional. Optional limit on the number of + * {@link protos.google.cloud.kms.v1.ImportJob|ImportJobs} to include in the response. + * Further {@link protos.google.cloud.kms.v1.ImportJob|ImportJobs} can subsequently be + * obtained by including the + * {@link protos.google.cloud.kms.v1.ListImportJobsResponse.next_page_token|ListImportJobsResponse.next_page_token} + * in a subsequent request. If unspecified, the server will pick an + * appropriate default. + * @param {string} [request.pageToken] + * Optional. Optional pagination token, returned earlier via + * {@link protos.google.cloud.kms.v1.ListImportJobsResponse.next_page_token|ListImportJobsResponse.next_page_token}. + * @param {string} [request.filter] + * Optional. Only include resources that match the filter in the response. For + * more information, see + * [Sorting and filtering list + * results](https://cloud.google.com/kms/docs/sorting-and-filtering). + * @param {string} [request.orderBy] + * Optional. Specify how the results should be sorted. If not specified, the + * results will be sorted in the default order. For more information, see + * [Sorting and filtering list + * results](https://cloud.google.com/kms/docs/sorting-and-filtering). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.kms.v1.ImportJob|ImportJob}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/key_management_service.list_import_jobs.js + * region_tag:cloudkms_v1_generated_KeyManagementService_ListImportJobs_async + */ listImportJobsAsync( - request?: protos.google.cloud.kms.v1.IListImportJobsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.kms.v1.IListImportJobsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listImportJobs']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listImportJobs iterate %j', request); return this.descriptors.page.listImportJobs.asyncIterate( this.innerApiCalls['listImportJobs'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists the {@link protos.google.cloud.kms.v1.RetiredResource|RetiredResources} which are - * the records of deleted {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKeys}. - * RetiredResources prevent the reuse of these resource names after deletion. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project-specific location holding the - * {@link protos.google.cloud.kms.v1.RetiredResource|RetiredResources}, in the format - * `projects/* /locations/*`. - * @param {number} [request.pageSize] - * Optional. Optional limit on the number of - * {@link protos.google.cloud.kms.v1.RetiredResource|RetiredResources} to be included in - * the response. Further - * {@link protos.google.cloud.kms.v1.RetiredResource|RetiredResources} can subsequently be - * obtained by including the - * {@link protos.google.cloud.kms.v1.ListRetiredResourcesResponse.next_page_token|ListRetiredResourcesResponse.next_page_token} - * in a subsequent request. If unspecified, the server will pick an - * appropriate default. - * @param {string} [request.pageToken] - * Optional. Optional pagination token, returned earlier via - * {@link protos.google.cloud.kms.v1.ListRetiredResourcesResponse.next_page_token|ListRetiredResourcesResponse.next_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.kms.v1.RetiredResource|RetiredResource}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listRetiredResourcesAsync()` - * method described below for async iteration which you can stop as 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 {@link protos.google.cloud.kms.v1.RetiredResource|RetiredResources} which are + * the records of deleted {@link protos.google.cloud.kms.v1.CryptoKey|CryptoKeys}. + * RetiredResources prevent the reuse of these resource names after deletion. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project-specific location holding the + * {@link protos.google.cloud.kms.v1.RetiredResource|RetiredResources}, in the format + * `projects/* /locations/*`. + * @param {number} [request.pageSize] + * Optional. Optional limit on the number of + * {@link protos.google.cloud.kms.v1.RetiredResource|RetiredResources} to be included in + * the response. Further + * {@link protos.google.cloud.kms.v1.RetiredResource|RetiredResources} can subsequently be + * obtained by including the + * {@link protos.google.cloud.kms.v1.ListRetiredResourcesResponse.next_page_token|ListRetiredResourcesResponse.next_page_token} + * in a subsequent request. If unspecified, the server will pick an + * appropriate default. + * @param {string} [request.pageToken] + * Optional. Optional pagination token, returned earlier via + * {@link protos.google.cloud.kms.v1.ListRetiredResourcesResponse.next_page_token|ListRetiredResourcesResponse.next_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.kms.v1.RetiredResource|RetiredResource}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listRetiredResourcesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listRetiredResources( - request?: protos.google.cloud.kms.v1.IListRetiredResourcesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.kms.v1.IRetiredResource[], - protos.google.cloud.kms.v1.IListRetiredResourcesRequest|null, - protos.google.cloud.kms.v1.IListRetiredResourcesResponse - ]>; + request?: protos.google.cloud.kms.v1.IListRetiredResourcesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.kms.v1.IRetiredResource[], + protos.google.cloud.kms.v1.IListRetiredResourcesRequest | null, + protos.google.cloud.kms.v1.IListRetiredResourcesResponse, + ] + >; listRetiredResources( - request: protos.google.cloud.kms.v1.IListRetiredResourcesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.kms.v1.IListRetiredResourcesRequest, - protos.google.cloud.kms.v1.IListRetiredResourcesResponse|null|undefined, - protos.google.cloud.kms.v1.IRetiredResource>): void; + request: protos.google.cloud.kms.v1.IListRetiredResourcesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.kms.v1.IListRetiredResourcesRequest, + | protos.google.cloud.kms.v1.IListRetiredResourcesResponse + | null + | undefined, + protos.google.cloud.kms.v1.IRetiredResource + >, + ): void; listRetiredResources( - request: protos.google.cloud.kms.v1.IListRetiredResourcesRequest, - callback: PaginationCallback< - protos.google.cloud.kms.v1.IListRetiredResourcesRequest, - protos.google.cloud.kms.v1.IListRetiredResourcesResponse|null|undefined, - protos.google.cloud.kms.v1.IRetiredResource>): void; + request: protos.google.cloud.kms.v1.IListRetiredResourcesRequest, + callback: PaginationCallback< + protos.google.cloud.kms.v1.IListRetiredResourcesRequest, + | protos.google.cloud.kms.v1.IListRetiredResourcesResponse + | null + | undefined, + protos.google.cloud.kms.v1.IRetiredResource + >, + ): void; listRetiredResources( - request?: protos.google.cloud.kms.v1.IListRetiredResourcesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.kms.v1.IListRetiredResourcesRequest, - protos.google.cloud.kms.v1.IListRetiredResourcesResponse|null|undefined, - protos.google.cloud.kms.v1.IRetiredResource>, - callback?: PaginationCallback< + request?: protos.google.cloud.kms.v1.IListRetiredResourcesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.kms.v1.IListRetiredResourcesRequest, - protos.google.cloud.kms.v1.IListRetiredResourcesResponse|null|undefined, - protos.google.cloud.kms.v1.IRetiredResource>): - Promise<[ - protos.google.cloud.kms.v1.IRetiredResource[], - protos.google.cloud.kms.v1.IListRetiredResourcesRequest|null, - protos.google.cloud.kms.v1.IListRetiredResourcesResponse - ]>|void { + | protos.google.cloud.kms.v1.IListRetiredResourcesResponse + | null + | undefined, + protos.google.cloud.kms.v1.IRetiredResource + >, + callback?: PaginationCallback< + protos.google.cloud.kms.v1.IListRetiredResourcesRequest, + | protos.google.cloud.kms.v1.IListRetiredResourcesResponse + | null + | undefined, + protos.google.cloud.kms.v1.IRetiredResource + >, + ): Promise< + [ + protos.google.cloud.kms.v1.IRetiredResource[], + protos.google.cloud.kms.v1.IListRetiredResourcesRequest | null, + protos.google.cloud.kms.v1.IListRetiredResourcesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-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.kms.v1.IListRetiredResourcesRequest, - protos.google.cloud.kms.v1.IListRetiredResourcesResponse|null|undefined, - protos.google.cloud.kms.v1.IRetiredResource>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.kms.v1.IListRetiredResourcesRequest, + | protos.google.cloud.kms.v1.IListRetiredResourcesResponse + | null + | undefined, + protos.google.cloud.kms.v1.IRetiredResource + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listRetiredResources values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -4924,153 +6217,157 @@ export class KeyManagementServiceClient { this._log.info('listRetiredResources request %j', request); return this.innerApiCalls .listRetiredResources(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.kms.v1.IRetiredResource[], - protos.google.cloud.kms.v1.IListRetiredResourcesRequest|null, - protos.google.cloud.kms.v1.IListRetiredResourcesResponse - ]) => { - this._log.info('listRetiredResources values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.kms.v1.IRetiredResource[], + protos.google.cloud.kms.v1.IListRetiredResourcesRequest | null, + protos.google.cloud.kms.v1.IListRetiredResourcesResponse, + ]) => { + this._log.info('listRetiredResources values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listRetiredResources`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project-specific location holding the - * {@link protos.google.cloud.kms.v1.RetiredResource|RetiredResources}, in the format - * `projects/* /locations/*`. - * @param {number} [request.pageSize] - * Optional. Optional limit on the number of - * {@link protos.google.cloud.kms.v1.RetiredResource|RetiredResources} to be included in - * the response. Further - * {@link protos.google.cloud.kms.v1.RetiredResource|RetiredResources} can subsequently be - * obtained by including the - * {@link protos.google.cloud.kms.v1.ListRetiredResourcesResponse.next_page_token|ListRetiredResourcesResponse.next_page_token} - * in a subsequent request. If unspecified, the server will pick an - * appropriate default. - * @param {string} [request.pageToken] - * Optional. Optional pagination token, returned earlier via - * {@link protos.google.cloud.kms.v1.ListRetiredResourcesResponse.next_page_token|ListRetiredResourcesResponse.next_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.kms.v1.RetiredResource|RetiredResource} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listRetiredResourcesAsync()` - * method described below for async iteration which you can stop as 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 `listRetiredResources`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project-specific location holding the + * {@link protos.google.cloud.kms.v1.RetiredResource|RetiredResources}, in the format + * `projects/* /locations/*`. + * @param {number} [request.pageSize] + * Optional. Optional limit on the number of + * {@link protos.google.cloud.kms.v1.RetiredResource|RetiredResources} to be included in + * the response. Further + * {@link protos.google.cloud.kms.v1.RetiredResource|RetiredResources} can subsequently be + * obtained by including the + * {@link protos.google.cloud.kms.v1.ListRetiredResourcesResponse.next_page_token|ListRetiredResourcesResponse.next_page_token} + * in a subsequent request. If unspecified, the server will pick an + * appropriate default. + * @param {string} [request.pageToken] + * Optional. Optional pagination token, returned earlier via + * {@link protos.google.cloud.kms.v1.ListRetiredResourcesResponse.next_page_token|ListRetiredResourcesResponse.next_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.kms.v1.RetiredResource|RetiredResource} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listRetiredResourcesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listRetiredResourcesStream( - request?: protos.google.cloud.kms.v1.IListRetiredResourcesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.kms.v1.IListRetiredResourcesRequest, + 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['listRetiredResources']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listRetiredResources stream %j', request); return this.descriptors.page.listRetiredResources.createStream( this.innerApiCalls.listRetiredResources as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listRetiredResources`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used 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-specific location holding the - * {@link protos.google.cloud.kms.v1.RetiredResource|RetiredResources}, in the format - * `projects/* /locations/*`. - * @param {number} [request.pageSize] - * Optional. Optional limit on the number of - * {@link protos.google.cloud.kms.v1.RetiredResource|RetiredResources} to be included in - * the response. Further - * {@link protos.google.cloud.kms.v1.RetiredResource|RetiredResources} can subsequently be - * obtained by including the - * {@link protos.google.cloud.kms.v1.ListRetiredResourcesResponse.next_page_token|ListRetiredResourcesResponse.next_page_token} - * in a subsequent request. If unspecified, the server will pick an - * appropriate default. - * @param {string} [request.pageToken] - * Optional. Optional pagination token, returned earlier via - * {@link protos.google.cloud.kms.v1.ListRetiredResourcesResponse.next_page_token|ListRetiredResourcesResponse.next_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.kms.v1.RetiredResource|RetiredResource}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@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/key_management_service.list_retired_resources.js - * region_tag:cloudkms_v1_generated_KeyManagementService_ListRetiredResources_async - */ + /** + * Equivalent to `listRetiredResources`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used 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-specific location holding the + * {@link protos.google.cloud.kms.v1.RetiredResource|RetiredResources}, in the format + * `projects/* /locations/*`. + * @param {number} [request.pageSize] + * Optional. Optional limit on the number of + * {@link protos.google.cloud.kms.v1.RetiredResource|RetiredResources} to be included in + * the response. Further + * {@link protos.google.cloud.kms.v1.RetiredResource|RetiredResources} can subsequently be + * obtained by including the + * {@link protos.google.cloud.kms.v1.ListRetiredResourcesResponse.next_page_token|ListRetiredResourcesResponse.next_page_token} + * in a subsequent request. If unspecified, the server will pick an + * appropriate default. + * @param {string} [request.pageToken] + * Optional. Optional pagination token, returned earlier via + * {@link protos.google.cloud.kms.v1.ListRetiredResourcesResponse.next_page_token|ListRetiredResourcesResponse.next_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.kms.v1.RetiredResource|RetiredResource}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@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/key_management_service.list_retired_resources.js + * region_tag:cloudkms_v1_generated_KeyManagementService_ListRetiredResources_async + */ listRetiredResourcesAsync( - request?: protos.google.cloud.kms.v1.IListRetiredResourcesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.kms.v1.IListRetiredResourcesRequest, + 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['listRetiredResources']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listRetiredResources iterate %j', request); return this.descriptors.page.listRetiredResources.asyncIterate( this.innerApiCalls['listRetiredResources'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** - * Gets the access control policy for a resource. Returns an empty policy - * if the resource exists and does not have a policy set. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {Object} [request.options] - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. This field is only used by Cloud IAM. - * - * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Gets the access control policy for a resource. Returns an empty policy + * if the resource exists and does not have a policy set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {Object} [request.options] + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. This field is only used by Cloud IAM. + * + * This object should have the same structure as {@link google.iam.v1.GetPolicyOptions | GetPolicyOptions}. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.Policy | Policy}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.Policy | Policy}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ getIamPolicy( request: IamProtos.google.iam.v1.GetIamPolicyRequest, options?: @@ -5084,40 +6381,40 @@ export class KeyManagementServiceClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.getIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + */ setIamPolicy( request: IamProtos.google.iam.v1.SetIamPolicyRequest, options?: @@ -5131,41 +6428,41 @@ export class KeyManagementServiceClient { IamProtos.google.iam.v1.Policy, IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.Policy]> { + >, + ): Promise<[IamProtos.google.iam.v1.Policy]> { return this.iamClient.setIamPolicy(request, options, callback); } -/** - * Returns permissions that a caller has on the specified resource. If the - * resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * Note: This operation is designed to be used for building - * permission-aware UIs and command-line tools, not for authorization - * checking. This operation may "fail open" without warning. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. - * @param {Object} [options] - * Optional parameters. You can override the default settings for this call, e.g, timeout, - * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. - * @param {function(?Error, ?Object)} [callback] - * The function which will be called with the result of the API call. - * - * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. - * The promise has a method named "cancel" which cancels the ongoing API call. - * - */ + /** + * Returns permissions that a caller has on the specified resource. If the + * resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * Note: This operation is designed to be used for building + * permission-aware UIs and command-line tools, not for authorization + * checking. This operation may "fail open" without warning. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see {@link https://cloud.google.com/iam/docs/overview#permissions | IAM Overview }. + * @param {Object} [options] + * Optional parameters. You can override the default settings for this call, e.g, timeout, + * retries, paginations, etc. See {@link https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html | gax.CallOptions} for the details. + * @param {function(?Error, ?Object)} [callback] + * The function which will be called with the result of the API call. + * + * The second parameter to the callback is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link google.iam.v1.TestIamPermissionsResponse | TestIamPermissionsResponse}. + * The promise has a method named "cancel" which cancels the ongoing API call. + * + */ testIamPermissions( request: IamProtos.google.iam.v1.TestIamPermissionsRequest, options?: @@ -5179,12 +6476,12 @@ export class KeyManagementServiceClient { IamProtos.google.iam.v1.TestIamPermissionsResponse, IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined, {} | null | undefined - > - ):Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { + >, + ): Promise<[IamProtos.google.iam.v1.TestIamPermissionsResponse]> { return this.iamClient.testIamPermissions(request, options, callback); } -/** + /** * Gets information about a location. * * @param {Object} request @@ -5219,12 +6516,11 @@ export class KeyManagementServiceClient { | 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. @@ -5257,12 +6553,12 @@ export class KeyManagementServiceClient { */ 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. @@ -5305,22 +6601,22 @@ export class KeyManagementServiceClient { 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); } /** @@ -5355,15 +6651,15 @@ export class KeyManagementServiceClient { */ 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); } /** @@ -5397,7 +6693,7 @@ export class KeyManagementServiceClient { * await client.cancelOperation({name: ''}); * ``` */ - cancelOperation( + cancelOperation( request: protos.google.longrunning.CancelOperationRequest, optionsOrCallback?: | gax.CallOptions @@ -5410,25 +6706,24 @@ export class KeyManagementServiceClient { 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 @@ -5467,22 +6762,22 @@ export class KeyManagementServiceClient { 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); } @@ -5499,7 +6794,12 @@ export class KeyManagementServiceClient { * @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, @@ -5516,7 +6816,8 @@ export class KeyManagementServiceClient { * @returns {string} A string representing the project. */ matchProjectFromCryptoKeyName(cryptoKeyName: string) { - return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName).project; + return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName) + .project; } /** @@ -5527,7 +6828,8 @@ export class KeyManagementServiceClient { * @returns {string} A string representing the location. */ matchLocationFromCryptoKeyName(cryptoKeyName: string) { - return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName).location; + return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName) + .location; } /** @@ -5538,7 +6840,8 @@ export class KeyManagementServiceClient { * @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; } /** @@ -5549,7 +6852,8 @@ export class KeyManagementServiceClient { * @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; } /** @@ -5562,7 +6866,13 @@ export class KeyManagementServiceClient { * @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, @@ -5580,7 +6890,9 @@ export class KeyManagementServiceClient { * @returns {string} A string representing the project. */ matchProjectFromCryptoKeyVersionName(cryptoKeyVersionName: string) { - return this.pathTemplates.cryptoKeyVersionPathTemplate.match(cryptoKeyVersionName).project; + return this.pathTemplates.cryptoKeyVersionPathTemplate.match( + cryptoKeyVersionName, + ).project; } /** @@ -5591,7 +6903,9 @@ export class KeyManagementServiceClient { * @returns {string} A string representing the location. */ matchLocationFromCryptoKeyVersionName(cryptoKeyVersionName: string) { - return this.pathTemplates.cryptoKeyVersionPathTemplate.match(cryptoKeyVersionName).location; + return this.pathTemplates.cryptoKeyVersionPathTemplate.match( + cryptoKeyVersionName, + ).location; } /** @@ -5602,7 +6916,9 @@ export class KeyManagementServiceClient { * @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; } /** @@ -5613,7 +6929,9 @@ export class KeyManagementServiceClient { * @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; } /** @@ -5624,7 +6942,9 @@ export class KeyManagementServiceClient { * @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; } /** @@ -5634,7 +6954,7 @@ export class KeyManagementServiceClient { * @param {string} location * @returns {string} Resource name string. */ - ekmConfigPath(project:string,location:string) { + ekmConfigPath(project: string, location: string) { return this.pathTemplates.ekmConfigPathTemplate.render({ project: project, location: location, @@ -5649,7 +6969,8 @@ export class KeyManagementServiceClient { * @returns {string} A string representing the project. */ matchProjectFromEkmConfigName(ekmConfigName: string) { - return this.pathTemplates.ekmConfigPathTemplate.match(ekmConfigName).project; + return this.pathTemplates.ekmConfigPathTemplate.match(ekmConfigName) + .project; } /** @@ -5660,7 +6981,8 @@ export class KeyManagementServiceClient { * @returns {string} A string representing the location. */ matchLocationFromEkmConfigName(ekmConfigName: string) { - return this.pathTemplates.ekmConfigPathTemplate.match(ekmConfigName).location; + return this.pathTemplates.ekmConfigPathTemplate.match(ekmConfigName) + .location; } /** @@ -5671,7 +6993,7 @@ export class KeyManagementServiceClient { * @param {string} ekm_connection * @returns {string} Resource name string. */ - ekmConnectionPath(project:string,location:string,ekmConnection:string) { + ekmConnectionPath(project: string, location: string, ekmConnection: string) { return this.pathTemplates.ekmConnectionPathTemplate.render({ project: project, location: location, @@ -5687,7 +7009,8 @@ export class KeyManagementServiceClient { * @returns {string} A string representing the project. */ matchProjectFromEkmConnectionName(ekmConnectionName: string) { - return this.pathTemplates.ekmConnectionPathTemplate.match(ekmConnectionName).project; + return this.pathTemplates.ekmConnectionPathTemplate.match(ekmConnectionName) + .project; } /** @@ -5698,7 +7021,8 @@ export class KeyManagementServiceClient { * @returns {string} A string representing the location. */ matchLocationFromEkmConnectionName(ekmConnectionName: string) { - return this.pathTemplates.ekmConnectionPathTemplate.match(ekmConnectionName).location; + return this.pathTemplates.ekmConnectionPathTemplate.match(ekmConnectionName) + .location; } /** @@ -5709,7 +7033,8 @@ export class KeyManagementServiceClient { * @returns {string} A string representing the ekm_connection. */ matchEkmConnectionFromEkmConnectionName(ekmConnectionName: string) { - return this.pathTemplates.ekmConnectionPathTemplate.match(ekmConnectionName).ekm_connection; + return this.pathTemplates.ekmConnectionPathTemplate.match(ekmConnectionName) + .ekm_connection; } /** @@ -5718,7 +7043,7 @@ export class KeyManagementServiceClient { * @param {string} folder * @returns {string} Resource name string. */ - folderAutokeyConfigPath(folder:string) { + folderAutokeyConfigPath(folder: string) { return this.pathTemplates.folderAutokeyConfigPathTemplate.render({ folder: folder, }); @@ -5732,7 +7057,9 @@ export class KeyManagementServiceClient { * @returns {string} A string representing the folder. */ matchFolderFromFolderAutokeyConfigName(folderAutokeyConfigName: string) { - return this.pathTemplates.folderAutokeyConfigPathTemplate.match(folderAutokeyConfigName).folder; + return this.pathTemplates.folderAutokeyConfigPathTemplate.match( + folderAutokeyConfigName, + ).folder; } /** @@ -5744,7 +7071,12 @@ export class KeyManagementServiceClient { * @param {string} import_job * @returns {string} Resource name string. */ - importJobPath(project:string,location:string,keyRing:string,importJob:string) { + importJobPath( + project: string, + location: string, + keyRing: string, + importJob: string, + ) { return this.pathTemplates.importJobPathTemplate.render({ project: project, location: location, @@ -5761,7 +7093,8 @@ export class KeyManagementServiceClient { * @returns {string} A string representing the project. */ matchProjectFromImportJobName(importJobName: string) { - return this.pathTemplates.importJobPathTemplate.match(importJobName).project; + return this.pathTemplates.importJobPathTemplate.match(importJobName) + .project; } /** @@ -5772,7 +7105,8 @@ export class KeyManagementServiceClient { * @returns {string} A string representing the location. */ matchLocationFromImportJobName(importJobName: string) { - return this.pathTemplates.importJobPathTemplate.match(importJobName).location; + return this.pathTemplates.importJobPathTemplate.match(importJobName) + .location; } /** @@ -5783,7 +7117,8 @@ export class KeyManagementServiceClient { * @returns {string} A string representing the key_ring. */ matchKeyRingFromImportJobName(importJobName: string) { - return this.pathTemplates.importJobPathTemplate.match(importJobName).key_ring; + return this.pathTemplates.importJobPathTemplate.match(importJobName) + .key_ring; } /** @@ -5794,7 +7129,8 @@ export class KeyManagementServiceClient { * @returns {string} A string representing the import_job. */ matchImportJobFromImportJobName(importJobName: string) { - return this.pathTemplates.importJobPathTemplate.match(importJobName).import_job; + return this.pathTemplates.importJobPathTemplate.match(importJobName) + .import_job; } /** @@ -5805,7 +7141,7 @@ export class KeyManagementServiceClient { * @param {string} key_handle * @returns {string} Resource name string. */ - keyHandlePath(project:string,location:string,keyHandle:string) { + keyHandlePath(project: string, location: string, keyHandle: string) { return this.pathTemplates.keyHandlePathTemplate.render({ project: project, location: location, @@ -5821,7 +7157,8 @@ export class KeyManagementServiceClient { * @returns {string} A string representing the project. */ matchProjectFromKeyHandleName(keyHandleName: string) { - return this.pathTemplates.keyHandlePathTemplate.match(keyHandleName).project; + return this.pathTemplates.keyHandlePathTemplate.match(keyHandleName) + .project; } /** @@ -5832,7 +7169,8 @@ export class KeyManagementServiceClient { * @returns {string} A string representing the location. */ matchLocationFromKeyHandleName(keyHandleName: string) { - return this.pathTemplates.keyHandlePathTemplate.match(keyHandleName).location; + return this.pathTemplates.keyHandlePathTemplate.match(keyHandleName) + .location; } /** @@ -5843,7 +7181,8 @@ export class KeyManagementServiceClient { * @returns {string} A string representing the key_handle. */ matchKeyHandleFromKeyHandleName(keyHandleName: string) { - return this.pathTemplates.keyHandlePathTemplate.match(keyHandleName).key_handle; + return this.pathTemplates.keyHandlePathTemplate.match(keyHandleName) + .key_handle; } /** @@ -5854,7 +7193,7 @@ export class KeyManagementServiceClient { * @param {string} key_ring * @returns {string} Resource name string. */ - keyRingPath(project:string,location:string,keyRing:string) { + keyRingPath(project: string, location: string, keyRing: string) { return this.pathTemplates.keyRingPathTemplate.render({ project: project, location: location, @@ -5902,7 +7241,7 @@ export class KeyManagementServiceClient { * @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, @@ -5937,7 +7276,7 @@ export class KeyManagementServiceClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -5960,7 +7299,7 @@ export class KeyManagementServiceClient { * @param {string} project * @returns {string} Resource name string. */ - projectAutokeyConfigPath(project:string) { + projectAutokeyConfigPath(project: string) { return this.pathTemplates.projectAutokeyConfigPathTemplate.render({ project: project, }); @@ -5974,7 +7313,9 @@ export class KeyManagementServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectAutokeyConfigName(projectAutokeyConfigName: string) { - return this.pathTemplates.projectAutokeyConfigPathTemplate.match(projectAutokeyConfigName).project; + return this.pathTemplates.projectAutokeyConfigPathTemplate.match( + projectAutokeyConfigName, + ).project; } /** @@ -5987,7 +7328,13 @@ export class KeyManagementServiceClient { * @param {string} crypto_key_version * @returns {string} Resource name string. */ - publicKeyPath(project:string,location:string,keyRing:string,cryptoKey:string,cryptoKeyVersion:string) { + publicKeyPath( + project: string, + location: string, + keyRing: string, + cryptoKey: string, + cryptoKeyVersion: string, + ) { return this.pathTemplates.publicKeyPathTemplate.render({ project: project, location: location, @@ -6005,7 +7352,8 @@ export class KeyManagementServiceClient { * @returns {string} A string representing the project. */ matchProjectFromPublicKeyName(publicKeyName: string) { - return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName).project; + return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName) + .project; } /** @@ -6016,7 +7364,8 @@ export class KeyManagementServiceClient { * @returns {string} A string representing the location. */ matchLocationFromPublicKeyName(publicKeyName: string) { - return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName).location; + return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName) + .location; } /** @@ -6027,7 +7376,8 @@ export class KeyManagementServiceClient { * @returns {string} A string representing the key_ring. */ matchKeyRingFromPublicKeyName(publicKeyName: string) { - return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName).key_ring; + return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName) + .key_ring; } /** @@ -6038,7 +7388,8 @@ export class KeyManagementServiceClient { * @returns {string} A string representing the crypto_key. */ matchCryptoKeyFromPublicKeyName(publicKeyName: string) { - return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName).crypto_key; + return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName) + .crypto_key; } /** @@ -6049,7 +7400,8 @@ export class KeyManagementServiceClient { * @returns {string} A string representing the crypto_key_version. */ matchCryptoKeyVersionFromPublicKeyName(publicKeyName: string) { - return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName).crypto_key_version; + return this.pathTemplates.publicKeyPathTemplate.match(publicKeyName) + .crypto_key_version; } /** @@ -6060,7 +7412,11 @@ export class KeyManagementServiceClient { * @param {string} retired_resource * @returns {string} Resource name string. */ - retiredResourcePath(project:string,location:string,retiredResource:string) { + retiredResourcePath( + project: string, + location: string, + retiredResource: string, + ) { return this.pathTemplates.retiredResourcePathTemplate.render({ project: project, location: location, @@ -6076,7 +7432,9 @@ export class KeyManagementServiceClient { * @returns {string} A string representing the project. */ matchProjectFromRetiredResourceName(retiredResourceName: string) { - return this.pathTemplates.retiredResourcePathTemplate.match(retiredResourceName).project; + return this.pathTemplates.retiredResourcePathTemplate.match( + retiredResourceName, + ).project; } /** @@ -6087,7 +7445,9 @@ export class KeyManagementServiceClient { * @returns {string} A string representing the location. */ matchLocationFromRetiredResourceName(retiredResourceName: string) { - return this.pathTemplates.retiredResourcePathTemplate.match(retiredResourceName).location; + return this.pathTemplates.retiredResourcePathTemplate.match( + retiredResourceName, + ).location; } /** @@ -6098,7 +7458,9 @@ export class KeyManagementServiceClient { * @returns {string} A string representing the retired_resource. */ matchRetiredResourceFromRetiredResourceName(retiredResourceName: string) { - return this.pathTemplates.retiredResourcePathTemplate.match(retiredResourceName).retired_resource; + return this.pathTemplates.retiredResourcePathTemplate.match( + retiredResourceName, + ).retired_resource; } /** @@ -6109,7 +7471,11 @@ export class KeyManagementServiceClient { * @param {string} single_tenant_hsm_instance * @returns {string} Resource name string. */ - singleTenantHsmInstancePath(project:string,location:string,singleTenantHsmInstance:string) { + singleTenantHsmInstancePath( + project: string, + location: string, + singleTenantHsmInstance: string, + ) { return this.pathTemplates.singleTenantHsmInstancePathTemplate.render({ project: project, location: location, @@ -6124,8 +7490,12 @@ export class KeyManagementServiceClient { * A fully-qualified path representing SingleTenantHsmInstance resource. * @returns {string} A string representing the project. */ - matchProjectFromSingleTenantHsmInstanceName(singleTenantHsmInstanceName: string) { - return this.pathTemplates.singleTenantHsmInstancePathTemplate.match(singleTenantHsmInstanceName).project; + matchProjectFromSingleTenantHsmInstanceName( + singleTenantHsmInstanceName: string, + ) { + return this.pathTemplates.singleTenantHsmInstancePathTemplate.match( + singleTenantHsmInstanceName, + ).project; } /** @@ -6135,8 +7505,12 @@ export class KeyManagementServiceClient { * A fully-qualified path representing SingleTenantHsmInstance resource. * @returns {string} A string representing the location. */ - matchLocationFromSingleTenantHsmInstanceName(singleTenantHsmInstanceName: string) { - return this.pathTemplates.singleTenantHsmInstancePathTemplate.match(singleTenantHsmInstanceName).location; + matchLocationFromSingleTenantHsmInstanceName( + singleTenantHsmInstanceName: string, + ) { + return this.pathTemplates.singleTenantHsmInstancePathTemplate.match( + singleTenantHsmInstanceName, + ).location; } /** @@ -6146,8 +7520,12 @@ export class KeyManagementServiceClient { * A fully-qualified path representing SingleTenantHsmInstance resource. * @returns {string} A string representing the single_tenant_hsm_instance. */ - matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceName(singleTenantHsmInstanceName: string) { - return this.pathTemplates.singleTenantHsmInstancePathTemplate.match(singleTenantHsmInstanceName).single_tenant_hsm_instance; + matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceName( + singleTenantHsmInstanceName: string, + ) { + return this.pathTemplates.singleTenantHsmInstancePathTemplate.match( + singleTenantHsmInstanceName, + ).single_tenant_hsm_instance; } /** @@ -6159,13 +7537,20 @@ export class KeyManagementServiceClient { * @param {string} proposal * @returns {string} Resource name string. */ - singleTenantHsmInstanceProposalPath(project:string,location:string,singleTenantHsmInstance:string,proposal:string) { - return this.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.render({ - project: project, - location: location, - single_tenant_hsm_instance: singleTenantHsmInstance, - proposal: proposal, - }); + singleTenantHsmInstanceProposalPath( + project: string, + location: string, + singleTenantHsmInstance: string, + proposal: string, + ) { + return this.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.render( + { + project: project, + location: location, + single_tenant_hsm_instance: singleTenantHsmInstance, + proposal: proposal, + }, + ); } /** @@ -6175,8 +7560,12 @@ export class KeyManagementServiceClient { * A fully-qualified path representing SingleTenantHsmInstanceProposal resource. * @returns {string} A string representing the project. */ - matchProjectFromSingleTenantHsmInstanceProposalName(singleTenantHsmInstanceProposalName: string) { - return this.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match(singleTenantHsmInstanceProposalName).project; + matchProjectFromSingleTenantHsmInstanceProposalName( + singleTenantHsmInstanceProposalName: string, + ) { + return this.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match( + singleTenantHsmInstanceProposalName, + ).project; } /** @@ -6186,8 +7575,12 @@ export class KeyManagementServiceClient { * A fully-qualified path representing SingleTenantHsmInstanceProposal resource. * @returns {string} A string representing the location. */ - matchLocationFromSingleTenantHsmInstanceProposalName(singleTenantHsmInstanceProposalName: string) { - return this.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match(singleTenantHsmInstanceProposalName).location; + matchLocationFromSingleTenantHsmInstanceProposalName( + singleTenantHsmInstanceProposalName: string, + ) { + return this.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match( + singleTenantHsmInstanceProposalName, + ).location; } /** @@ -6197,8 +7590,12 @@ export class KeyManagementServiceClient { * A fully-qualified path representing SingleTenantHsmInstanceProposal resource. * @returns {string} A string representing the single_tenant_hsm_instance. */ - matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceProposalName(singleTenantHsmInstanceProposalName: string) { - return this.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match(singleTenantHsmInstanceProposalName).single_tenant_hsm_instance; + matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceProposalName( + singleTenantHsmInstanceProposalName: string, + ) { + return this.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match( + singleTenantHsmInstanceProposalName, + ).single_tenant_hsm_instance; } /** @@ -6208,8 +7605,12 @@ export class KeyManagementServiceClient { * A fully-qualified path representing SingleTenantHsmInstanceProposal resource. * @returns {string} A string representing the proposal. */ - matchProposalFromSingleTenantHsmInstanceProposalName(singleTenantHsmInstanceProposalName: string) { - return this.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match(singleTenantHsmInstanceProposalName).proposal; + matchProposalFromSingleTenantHsmInstanceProposalName( + singleTenantHsmInstanceProposalName: string, + ) { + return this.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match( + singleTenantHsmInstanceProposalName, + ).proposal; } /** @@ -6220,15 +7621,19 @@ export class KeyManagementServiceClient { */ close(): Promise { if (this.keyManagementServiceStub && !this._terminated) { - return this.keyManagementServiceStub.then(stub => { + return this.keyManagementServiceStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); - this.iamClient.close().catch(err => {throw err}); - this.locationsClient.close().catch(err => {throw err}); + this.iamClient.close().catch((err) => { + throw err; + }); + this.locationsClient.close().catch((err) => { + throw err; + }); void this.operationsClient.close(); }); } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-kms/system-test/fixtures/sample/src/index.ts b/packages/google-cloud-kms/system-test/fixtures/sample/src/index.ts index 596ddc9a4f00..045aee898cd1 100644 --- a/packages/google-cloud-kms/system-test/fixtures/sample/src/index.ts +++ b/packages/google-cloud-kms/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 {AutokeyClient, AutokeyAdminClient, EkmServiceClient, HsmManagementClient, KeyManagementServiceClient} from '@google-cloud/kms'; +import { + AutokeyClient, + AutokeyAdminClient, + EkmServiceClient, + HsmManagementClient, + KeyManagementServiceClient, +} from '@google-cloud/kms'; // check that the client class type name can be used function doStuffWithAutokeyClient(client: AutokeyClient) { @@ -31,7 +37,9 @@ function doStuffWithEkmServiceClient(client: EkmServiceClient) { function doStuffWithHsmManagementClient(client: HsmManagementClient) { client.close(); } -function doStuffWithKeyManagementServiceClient(client: KeyManagementServiceClient) { +function doStuffWithKeyManagementServiceClient( + client: KeyManagementServiceClient, +) { client.close(); } diff --git a/packages/google-cloud-kms/system-test/install.ts b/packages/google-cloud-kms/system-test/install.ts index f66069aa3940..ccf167042d2e 100644 --- a/packages/google-cloud-kms/system-test/install.ts +++ b/packages/google-cloud-kms/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-kms/test/gapic_autokey_admin_v1.ts b/packages/google-cloud-kms/test/gapic_autokey_admin_v1.ts index d859b3b77886..b75cda4a92e5 100644 --- a/packages/google-cloud-kms/test/gapic_autokey_admin_v1.ts +++ b/packages/google-cloud-kms/test/gapic_autokey_admin_v1.ts @@ -19,1633 +19,2146 @@ 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 autokeyadminModule from '../src'; -import {protobuf, IamProtos, LocationProtos} from 'google-gax'; +import { protobuf, IamProtos, LocationProtos } from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); +const root = protobuf.Root.fromJSON( + require('../protos/protos.json'), +).resolveAll(); // eslint-disable-next-line @typescript-eslint/no-unused-vars function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; } function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, { defaults: true }); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject, + ) as T; } function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); } -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error, +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); } -function 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.AutokeyAdminClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new autokeyadminModule.v1.AutokeyAdminClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'cloudkms.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new autokeyadminModule.v1.AutokeyAdminClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new autokeyadminModule.v1.AutokeyAdminClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'cloudkms.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 = autokeyadminModule.v1.AutokeyAdminClient.servicePath; - assert.strictEqual(servicePath, 'cloudkms.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = autokeyadminModule.v1.AutokeyAdminClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'cloudkms.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new autokeyadminModule.v1.AutokeyAdminClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudkms.example.com'); - }); + it('has universeDomain', () => { + const client = new autokeyadminModule.v1.AutokeyAdminClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new autokeyadminModule.v1.AutokeyAdminClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudkms.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 = + autokeyadminModule.v1.AutokeyAdminClient.servicePath; + assert.strictEqual(servicePath, 'cloudkms.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + autokeyadminModule.v1.AutokeyAdminClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'cloudkms.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new autokeyadminModule.v1.AutokeyAdminClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudkms.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 autokeyadminModule.v1.AutokeyAdminClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudkms.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 autokeyadminModule.v1.AutokeyAdminClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudkms.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 autokeyadminModule.v1.AutokeyAdminClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new autokeyadminModule.v1.AutokeyAdminClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudkms.example.com'); + }); - it('has port', () => { - const port = autokeyadminModule.v1.AutokeyAdminClient.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 autokeyadminModule.v1.AutokeyAdminClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudkms.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 autokeyadminModule.v1.AutokeyAdminClient(); - 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 autokeyadminModule.v1.AutokeyAdminClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudkms.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 autokeyadminModule.v1.AutokeyAdminClient({ - fallback: true, - }); - assert(client); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new autokeyadminModule.v1.AutokeyAdminClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new autokeyadminModule.v1.AutokeyAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.autokeyAdminStub, undefined); - await client.initialize(); - assert(client.autokeyAdminStub); - }); + it('has port', () => { + const port = autokeyadminModule.v1.AutokeyAdminClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has close method for the initialized client', done => { - const client = new autokeyadminModule.v1.AutokeyAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.autokeyAdminStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('should create a client with no option', () => { + const client = new autokeyadminModule.v1.AutokeyAdminClient(); + assert(client); + }); - it('has close method for the non-initialized client', done => { - const client = new autokeyadminModule.v1.AutokeyAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.autokeyAdminStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('should create a client with gRPC fallback', () => { + const client = new autokeyadminModule.v1.AutokeyAdminClient({ + fallback: true, + }); + assert(client); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new autokeyadminModule.v1.AutokeyAdminClient({ - 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 autokeyadminModule.v1.AutokeyAdminClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.autokeyAdminStub, undefined); + await client.initialize(); + assert(client.autokeyAdminStub); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new autokeyadminModule.v1.AutokeyAdminClient({ - 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 autokeyadminModule.v1.AutokeyAdminClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.autokeyAdminStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('updateAutokeyConfig', () => { - it('invokes updateAutokeyConfig without error', async () => { - const client = new autokeyadminModule.v1.AutokeyAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.UpdateAutokeyConfigRequest() - ); - request.autokeyConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.UpdateAutokeyConfigRequest', ['autokeyConfig', 'name']); - request.autokeyConfig.name = defaultValue1; - const expectedHeaderRequestParams = `autokey_config.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.AutokeyConfig() - ); - client.innerApiCalls.updateAutokeyConfig = stubSimpleCall(expectedResponse); - const [response] = await client.updateAutokeyConfig(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateAutokeyConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateAutokeyConfig 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 autokeyadminModule.v1.AutokeyAdminClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.autokeyAdminStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes updateAutokeyConfig without error using callback', async () => { - const client = new autokeyadminModule.v1.AutokeyAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.UpdateAutokeyConfigRequest() - ); - request.autokeyConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.UpdateAutokeyConfigRequest', ['autokeyConfig', 'name']); - request.autokeyConfig.name = defaultValue1; - const expectedHeaderRequestParams = `autokey_config.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.AutokeyConfig() - ); - client.innerApiCalls.updateAutokeyConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateAutokeyConfig( - request, - (err?: Error|null, result?: protos.google.cloud.kms.v1.IAutokeyConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateAutokeyConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateAutokeyConfig 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 autokeyadminModule.v1.AutokeyAdminClient({ + 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 updateAutokeyConfig with error', async () => { - const client = new autokeyadminModule.v1.AutokeyAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.UpdateAutokeyConfigRequest() - ); - request.autokeyConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.UpdateAutokeyConfigRequest', ['autokeyConfig', 'name']); - request.autokeyConfig.name = defaultValue1; - const expectedHeaderRequestParams = `autokey_config.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateAutokeyConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateAutokeyConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.updateAutokeyConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateAutokeyConfig 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 autokeyadminModule.v1.AutokeyAdminClient({ + 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('updateAutokeyConfig', () => { + it('invokes updateAutokeyConfig without error', async () => { + const client = new autokeyadminModule.v1.AutokeyAdminClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.UpdateAutokeyConfigRequest(), + ); + request.autokeyConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.UpdateAutokeyConfigRequest', + ['autokeyConfig', 'name'], + ); + request.autokeyConfig.name = defaultValue1; + const expectedHeaderRequestParams = `autokey_config.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.AutokeyConfig(), + ); + client.innerApiCalls.updateAutokeyConfig = + stubSimpleCall(expectedResponse); + const [response] = await client.updateAutokeyConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateAutokeyConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateAutokeyConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateAutokeyConfig with closed client', async () => { - const client = new autokeyadminModule.v1.AutokeyAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.UpdateAutokeyConfigRequest() - ); - request.autokeyConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.UpdateAutokeyConfigRequest', ['autokeyConfig', 'name']); - request.autokeyConfig.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.updateAutokeyConfig(request), expectedError); - }); + it('invokes updateAutokeyConfig without error using callback', async () => { + const client = new autokeyadminModule.v1.AutokeyAdminClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.UpdateAutokeyConfigRequest(), + ); + request.autokeyConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.UpdateAutokeyConfigRequest', + ['autokeyConfig', 'name'], + ); + request.autokeyConfig.name = defaultValue1; + const expectedHeaderRequestParams = `autokey_config.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.AutokeyConfig(), + ); + client.innerApiCalls.updateAutokeyConfig = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateAutokeyConfig( + request, + ( + err?: Error | null, + result?: protos.google.cloud.kms.v1.IAutokeyConfig | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateAutokeyConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateAutokeyConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getAutokeyConfig', () => { - it('invokes getAutokeyConfig without error', async () => { - const client = new autokeyadminModule.v1.AutokeyAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.GetAutokeyConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.GetAutokeyConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.AutokeyConfig() - ); - client.innerApiCalls.getAutokeyConfig = stubSimpleCall(expectedResponse); - const [response] = await client.getAutokeyConfig(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getAutokeyConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getAutokeyConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateAutokeyConfig with error', async () => { + const client = new autokeyadminModule.v1.AutokeyAdminClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.UpdateAutokeyConfigRequest(), + ); + request.autokeyConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.UpdateAutokeyConfigRequest', + ['autokeyConfig', 'name'], + ); + request.autokeyConfig.name = defaultValue1; + const expectedHeaderRequestParams = `autokey_config.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateAutokeyConfig = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateAutokeyConfig(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateAutokeyConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateAutokeyConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getAutokeyConfig without error using callback', async () => { - const client = new autokeyadminModule.v1.AutokeyAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.GetAutokeyConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.GetAutokeyConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.AutokeyConfig() - ); - client.innerApiCalls.getAutokeyConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getAutokeyConfig( - request, - (err?: Error|null, result?: protos.google.cloud.kms.v1.IAutokeyConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getAutokeyConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getAutokeyConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateAutokeyConfig with closed client', async () => { + const client = new autokeyadminModule.v1.AutokeyAdminClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.UpdateAutokeyConfigRequest(), + ); + request.autokeyConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.UpdateAutokeyConfigRequest', + ['autokeyConfig', 'name'], + ); + request.autokeyConfig.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.updateAutokeyConfig(request), expectedError); + }); + }); + + describe('getAutokeyConfig', () => { + it('invokes getAutokeyConfig without error', async () => { + const client = new autokeyadminModule.v1.AutokeyAdminClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.GetAutokeyConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.GetAutokeyConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.AutokeyConfig(), + ); + client.innerApiCalls.getAutokeyConfig = stubSimpleCall(expectedResponse); + const [response] = await client.getAutokeyConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getAutokeyConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getAutokeyConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getAutokeyConfig with error', async () => { - const client = new autokeyadminModule.v1.AutokeyAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.GetAutokeyConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.GetAutokeyConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getAutokeyConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getAutokeyConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.getAutokeyConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getAutokeyConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getAutokeyConfig without error using callback', async () => { + const client = new autokeyadminModule.v1.AutokeyAdminClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.GetAutokeyConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.GetAutokeyConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.AutokeyConfig(), + ); + client.innerApiCalls.getAutokeyConfig = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getAutokeyConfig( + request, + ( + err?: Error | null, + result?: protos.google.cloud.kms.v1.IAutokeyConfig | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getAutokeyConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getAutokeyConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getAutokeyConfig with closed client', async () => { - const client = new autokeyadminModule.v1.AutokeyAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.GetAutokeyConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.GetAutokeyConfigRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getAutokeyConfig(request), expectedError); - }); + it('invokes getAutokeyConfig with error', async () => { + const client = new autokeyadminModule.v1.AutokeyAdminClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.GetAutokeyConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.GetAutokeyConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getAutokeyConfig = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getAutokeyConfig(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getAutokeyConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getAutokeyConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('showEffectiveAutokeyConfig', () => { - it('invokes showEffectiveAutokeyConfig without error', async () => { - const client = new autokeyadminModule.v1.AutokeyAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ShowEffectiveAutokeyConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ShowEffectiveAutokeyConfigRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.ShowEffectiveAutokeyConfigResponse() - ); - client.innerApiCalls.showEffectiveAutokeyConfig = stubSimpleCall(expectedResponse); - const [response] = await client.showEffectiveAutokeyConfig(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.showEffectiveAutokeyConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.showEffectiveAutokeyConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getAutokeyConfig with closed client', async () => { + const client = new autokeyadminModule.v1.AutokeyAdminClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.GetAutokeyConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.GetAutokeyConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getAutokeyConfig(request), expectedError); + }); + }); + + describe('showEffectiveAutokeyConfig', () => { + it('invokes showEffectiveAutokeyConfig without error', async () => { + const client = new autokeyadminModule.v1.AutokeyAdminClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ShowEffectiveAutokeyConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ShowEffectiveAutokeyConfigRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.ShowEffectiveAutokeyConfigResponse(), + ); + client.innerApiCalls.showEffectiveAutokeyConfig = + stubSimpleCall(expectedResponse); + const [response] = await client.showEffectiveAutokeyConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.showEffectiveAutokeyConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.showEffectiveAutokeyConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes showEffectiveAutokeyConfig without error using callback', async () => { - const client = new autokeyadminModule.v1.AutokeyAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ShowEffectiveAutokeyConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ShowEffectiveAutokeyConfigRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.ShowEffectiveAutokeyConfigResponse() - ); - client.innerApiCalls.showEffectiveAutokeyConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.showEffectiveAutokeyConfig( - request, - (err?: Error|null, result?: protos.google.cloud.kms.v1.IShowEffectiveAutokeyConfigResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.showEffectiveAutokeyConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.showEffectiveAutokeyConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes showEffectiveAutokeyConfig without error using callback', async () => { + const client = new autokeyadminModule.v1.AutokeyAdminClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ShowEffectiveAutokeyConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ShowEffectiveAutokeyConfigRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.ShowEffectiveAutokeyConfigResponse(), + ); + client.innerApiCalls.showEffectiveAutokeyConfig = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.showEffectiveAutokeyConfig( + request, + ( + err?: Error | null, + result?: protos.google.cloud.kms.v1.IShowEffectiveAutokeyConfigResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.showEffectiveAutokeyConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.showEffectiveAutokeyConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes showEffectiveAutokeyConfig with error', async () => { - const client = new autokeyadminModule.v1.AutokeyAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ShowEffectiveAutokeyConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ShowEffectiveAutokeyConfigRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.showEffectiveAutokeyConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.showEffectiveAutokeyConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.showEffectiveAutokeyConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.showEffectiveAutokeyConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes showEffectiveAutokeyConfig with error', async () => { + const client = new autokeyadminModule.v1.AutokeyAdminClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ShowEffectiveAutokeyConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ShowEffectiveAutokeyConfigRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.showEffectiveAutokeyConfig = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.showEffectiveAutokeyConfig(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.showEffectiveAutokeyConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.showEffectiveAutokeyConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes showEffectiveAutokeyConfig with closed client', async () => { - const client = new autokeyadminModule.v1.AutokeyAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ShowEffectiveAutokeyConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ShowEffectiveAutokeyConfigRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.showEffectiveAutokeyConfig(request), expectedError); - }); + it('invokes showEffectiveAutokeyConfig with closed client', async () => { + const client = new autokeyadminModule.v1.AutokeyAdminClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ShowEffectiveAutokeyConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ShowEffectiveAutokeyConfigRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.showEffectiveAutokeyConfig(request), + expectedError, + ); }); - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new autokeyadminModule.v1.AutokeyAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.getIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getIamPolicy without error using callback', async () => { - const client = new autokeyadminModule.v1.AutokeyAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes getIamPolicy with error', async () => { - const client = new autokeyadminModule.v1.AutokeyAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new autokeyadminModule.v1.AutokeyAdminClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.getIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new autokeyadminModule.v1.AutokeyAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.setIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes setIamPolicy without error using callback', async () => { - const client = new autokeyadminModule.v1.AutokeyAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes setIamPolicy with error', async () => { - const client = new autokeyadminModule.v1.AutokeyAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getIamPolicy without error using callback', async () => { + const client = new autokeyadminModule.v1.AutokeyAdminClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .getIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.getIamPolicy as SinonStub).getCall(0)); }); - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new autokeyadminModule.v1.AutokeyAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); - const response = await client.testIamPermissions(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes testIamPermissions without error using callback', async () => { - const client = new autokeyadminModule.v1.AutokeyAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.TestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0)); - }); - it('invokes testIamPermissions with error', async () => { - const client = new autokeyadminModule.v1.AutokeyAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request, expectedOptions), expectedError); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getIamPolicy with error', async () => { + const client = new autokeyadminModule.v1.AutokeyAdminClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.getIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new autokeyadminModule.v1.AutokeyAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - 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 autokeyadminModule.v1.AutokeyAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - 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 autokeyadminModule.v1.AutokeyAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new autokeyadminModule.v1.AutokeyAdminClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.setIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + it('invokes setIamPolicy without error using callback', async () => { + const client = new autokeyadminModule.v1.AutokeyAdminClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .setIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.setIamPolicy as SinonStub).getCall(0)); + }); + it('invokes setIamPolicy with error', async () => { + const client = new autokeyadminModule.v1.AutokeyAdminClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.setIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new autokeyadminModule.v1.AutokeyAdminClient({ - 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('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new autokeyadminModule.v1.AutokeyAdminClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); + const response = await client.testIamPermissions( + request, + expectedOptions, + ); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + it('invokes testIamPermissions without error using callback', async () => { + const client = new autokeyadminModule.v1.AutokeyAdminClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .testIamPermissions( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.TestIamPermissionsResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.testIamPermissions as SinonStub).getCall(0)); + }); + it('invokes testIamPermissions with error', async () => { + const client = new autokeyadminModule.v1.AutokeyAdminClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.testIamPermissions = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.testIamPermissions(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new autokeyadminModule.v1.AutokeyAdminClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + 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 autokeyadminModule.v1.AutokeyAdminClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + 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 autokeyadminModule.v1.AutokeyAdminClient({ - 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 autokeyadminModule.v1.AutokeyAdminClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + 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 autokeyadminModule.v1.AutokeyAdminClient({ + 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 autokeyadminModule.v1.AutokeyAdminClient({ + 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('cryptoKey', async () => { + const fakePath = '/rendered/path/cryptoKey'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + key_ring: 'keyRingValue', + crypto_key: 'cryptoKeyValue', + }; + const client = new autokeyadminModule.v1.AutokeyAdminClient({ + 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('Path templates', () => { - - describe('cryptoKey', async () => { - const fakePath = "/rendered/path/cryptoKey"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - key_ring: "keyRingValue", - crypto_key: "cryptoKeyValue", - }; - const client = new autokeyadminModule.v1.AutokeyAdminClient({ - 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 autokeyadminModule.v1.AutokeyAdminClient({ - 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 autokeyadminModule.v1.AutokeyAdminClient({ + 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('ekmConfig', async () => { - const fakePath = "/rendered/path/ekmConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new autokeyadminModule.v1.AutokeyAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.ekmConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.ekmConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('ekmConfigPath', () => { - const result = client.ekmConfigPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.ekmConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromEkmConfigName', () => { - const result = client.matchProjectFromEkmConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.ekmConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromEkmConfigName', () => { - const result = client.matchLocationFromEkmConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.ekmConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('ekmConfig', async () => { + const fakePath = '/rendered/path/ekmConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = new autokeyadminModule.v1.AutokeyAdminClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.ekmConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.ekmConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('ekmConfigPath', () => { + const result = client.ekmConfigPath('projectValue', 'locationValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.ekmConfigPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromEkmConfigName', () => { + const result = client.matchProjectFromEkmConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.ekmConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromEkmConfigName', () => { + const result = client.matchLocationFromEkmConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.ekmConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('ekmConnection', async () => { - const fakePath = "/rendered/path/ekmConnection"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - ekm_connection: "ekmConnectionValue", - }; - const client = new autokeyadminModule.v1.AutokeyAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.ekmConnectionPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.ekmConnectionPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('ekmConnectionPath', () => { - const result = client.ekmConnectionPath("projectValue", "locationValue", "ekmConnectionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.ekmConnectionPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromEkmConnectionName', () => { - const result = client.matchProjectFromEkmConnectionName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.ekmConnectionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromEkmConnectionName', () => { - const result = client.matchLocationFromEkmConnectionName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.ekmConnectionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchEkmConnectionFromEkmConnectionName', () => { - const result = client.matchEkmConnectionFromEkmConnectionName(fakePath); - assert.strictEqual(result, "ekmConnectionValue"); - assert((client.pathTemplates.ekmConnectionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('ekmConnection', async () => { + const fakePath = '/rendered/path/ekmConnection'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + ekm_connection: 'ekmConnectionValue', + }; + const client = new autokeyadminModule.v1.AutokeyAdminClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.ekmConnectionPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.ekmConnectionPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('ekmConnectionPath', () => { + const result = client.ekmConnectionPath( + 'projectValue', + 'locationValue', + 'ekmConnectionValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.ekmConnectionPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromEkmConnectionName', () => { + const result = client.matchProjectFromEkmConnectionName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.ekmConnectionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromEkmConnectionName', () => { + const result = client.matchLocationFromEkmConnectionName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.ekmConnectionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchEkmConnectionFromEkmConnectionName', () => { + const result = client.matchEkmConnectionFromEkmConnectionName(fakePath); + assert.strictEqual(result, 'ekmConnectionValue'); + assert( + (client.pathTemplates.ekmConnectionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('folderAutokeyConfig', async () => { - const fakePath = "/rendered/path/folderAutokeyConfig"; - const expectedParameters = { - folder: "folderValue", - }; - const client = new autokeyadminModule.v1.AutokeyAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.folderAutokeyConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.folderAutokeyConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('folderAutokeyConfigPath', () => { - const result = client.folderAutokeyConfigPath("folderValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.folderAutokeyConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchFolderFromFolderAutokeyConfigName', () => { - const result = client.matchFolderFromFolderAutokeyConfigName(fakePath); - assert.strictEqual(result, "folderValue"); - assert((client.pathTemplates.folderAutokeyConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('folderAutokeyConfig', async () => { + const fakePath = '/rendered/path/folderAutokeyConfig'; + const expectedParameters = { + folder: 'folderValue', + }; + const client = new autokeyadminModule.v1.AutokeyAdminClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.folderAutokeyConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.folderAutokeyConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('folderAutokeyConfigPath', () => { + const result = client.folderAutokeyConfigPath('folderValue'); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.folderAutokeyConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchFolderFromFolderAutokeyConfigName', () => { + const result = client.matchFolderFromFolderAutokeyConfigName(fakePath); + assert.strictEqual(result, 'folderValue'); + assert( + ( + client.pathTemplates.folderAutokeyConfigPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('importJob', async () => { - const fakePath = "/rendered/path/importJob"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - key_ring: "keyRingValue", - import_job: "importJobValue", - }; - const client = new autokeyadminModule.v1.AutokeyAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.importJobPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.importJobPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('importJobPath', () => { - const result = client.importJobPath("projectValue", "locationValue", "keyRingValue", "importJobValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.importJobPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromImportJobName', () => { - const result = client.matchProjectFromImportJobName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.importJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromImportJobName', () => { - const result = client.matchLocationFromImportJobName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.importJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchKeyRingFromImportJobName', () => { - const result = client.matchKeyRingFromImportJobName(fakePath); - assert.strictEqual(result, "keyRingValue"); - assert((client.pathTemplates.importJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchImportJobFromImportJobName', () => { - const result = client.matchImportJobFromImportJobName(fakePath); - assert.strictEqual(result, "importJobValue"); - assert((client.pathTemplates.importJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('importJob', async () => { + const fakePath = '/rendered/path/importJob'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + key_ring: 'keyRingValue', + import_job: 'importJobValue', + }; + const client = new autokeyadminModule.v1.AutokeyAdminClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.importJobPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.importJobPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('importJobPath', () => { + const result = client.importJobPath( + 'projectValue', + 'locationValue', + 'keyRingValue', + 'importJobValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.importJobPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromImportJobName', () => { + const result = client.matchProjectFromImportJobName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.importJobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromImportJobName', () => { + const result = client.matchLocationFromImportJobName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.importJobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchKeyRingFromImportJobName', () => { + const result = client.matchKeyRingFromImportJobName(fakePath); + assert.strictEqual(result, 'keyRingValue'); + assert( + (client.pathTemplates.importJobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchImportJobFromImportJobName', () => { + const result = client.matchImportJobFromImportJobName(fakePath); + assert.strictEqual(result, 'importJobValue'); + assert( + (client.pathTemplates.importJobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('keyHandle', async () => { - const fakePath = "/rendered/path/keyHandle"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - key_handle: "keyHandleValue", - }; - const client = new autokeyadminModule.v1.AutokeyAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.keyHandlePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.keyHandlePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('keyHandlePath', () => { - const result = client.keyHandlePath("projectValue", "locationValue", "keyHandleValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.keyHandlePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromKeyHandleName', () => { - const result = client.matchProjectFromKeyHandleName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.keyHandlePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromKeyHandleName', () => { - const result = client.matchLocationFromKeyHandleName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.keyHandlePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchKeyHandleFromKeyHandleName', () => { - const result = client.matchKeyHandleFromKeyHandleName(fakePath); - assert.strictEqual(result, "keyHandleValue"); - assert((client.pathTemplates.keyHandlePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('keyHandle', async () => { + const fakePath = '/rendered/path/keyHandle'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + key_handle: 'keyHandleValue', + }; + const client = new autokeyadminModule.v1.AutokeyAdminClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.keyHandlePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.keyHandlePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('keyHandlePath', () => { + const result = client.keyHandlePath( + 'projectValue', + 'locationValue', + 'keyHandleValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.keyHandlePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromKeyHandleName', () => { + const result = client.matchProjectFromKeyHandleName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.keyHandlePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromKeyHandleName', () => { + const result = client.matchLocationFromKeyHandleName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.keyHandlePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchKeyHandleFromKeyHandleName', () => { + const result = client.matchKeyHandleFromKeyHandleName(fakePath); + assert.strictEqual(result, 'keyHandleValue'); + assert( + (client.pathTemplates.keyHandlePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('keyRing', async () => { - const fakePath = "/rendered/path/keyRing"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - key_ring: "keyRingValue", - }; - const client = new autokeyadminModule.v1.AutokeyAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.keyRingPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.keyRingPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('keyRingPath', () => { - const result = client.keyRingPath("projectValue", "locationValue", "keyRingValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.keyRingPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromKeyRingName', () => { - const result = client.matchProjectFromKeyRingName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.keyRingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromKeyRingName', () => { - const result = client.matchLocationFromKeyRingName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.keyRingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchKeyRingFromKeyRingName', () => { - const result = client.matchKeyRingFromKeyRingName(fakePath); - assert.strictEqual(result, "keyRingValue"); - assert((client.pathTemplates.keyRingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('keyRing', async () => { + const fakePath = '/rendered/path/keyRing'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + key_ring: 'keyRingValue', + }; + const client = new autokeyadminModule.v1.AutokeyAdminClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.keyRingPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.keyRingPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('keyRingPath', () => { + const result = client.keyRingPath( + 'projectValue', + 'locationValue', + 'keyRingValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.keyRingPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromKeyRingName', () => { + const result = client.matchProjectFromKeyRingName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.keyRingPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromKeyRingName', () => { + const result = client.matchLocationFromKeyRingName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.keyRingPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchKeyRingFromKeyRingName', () => { + const result = client.matchKeyRingFromKeyRingName(fakePath); + assert.strictEqual(result, 'keyRingValue'); + assert( + (client.pathTemplates.keyRingPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('project', async () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new autokeyadminModule.v1.AutokeyAdminClient({ - 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 autokeyadminModule.v1.AutokeyAdminClient({ + 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('projectAutokeyConfig', async () => { - const fakePath = "/rendered/path/projectAutokeyConfig"; - const expectedParameters = { - project: "projectValue", - }; - const client = new autokeyadminModule.v1.AutokeyAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectAutokeyConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectAutokeyConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectAutokeyConfigPath', () => { - const result = client.projectAutokeyConfigPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectAutokeyConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectAutokeyConfigName', () => { - const result = client.matchProjectFromProjectAutokeyConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectAutokeyConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectAutokeyConfig', async () => { + const fakePath = '/rendered/path/projectAutokeyConfig'; + const expectedParameters = { + project: 'projectValue', + }; + const client = new autokeyadminModule.v1.AutokeyAdminClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectAutokeyConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectAutokeyConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectAutokeyConfigPath', () => { + const result = client.projectAutokeyConfigPath('projectValue'); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectAutokeyConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectAutokeyConfigName', () => { + const result = + client.matchProjectFromProjectAutokeyConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.projectAutokeyConfigPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('publicKey', async () => { - const fakePath = "/rendered/path/publicKey"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - key_ring: "keyRingValue", - crypto_key: "cryptoKeyValue", - crypto_key_version: "cryptoKeyVersionValue", - }; - const client = new autokeyadminModule.v1.AutokeyAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.publicKeyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.publicKeyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('publicKeyPath', () => { - const result = client.publicKeyPath("projectValue", "locationValue", "keyRingValue", "cryptoKeyValue", "cryptoKeyVersionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.publicKeyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromPublicKeyName', () => { - const result = client.matchProjectFromPublicKeyName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.publicKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromPublicKeyName', () => { - const result = client.matchLocationFromPublicKeyName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.publicKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchKeyRingFromPublicKeyName', () => { - const result = client.matchKeyRingFromPublicKeyName(fakePath); - assert.strictEqual(result, "keyRingValue"); - assert((client.pathTemplates.publicKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCryptoKeyFromPublicKeyName', () => { - const result = client.matchCryptoKeyFromPublicKeyName(fakePath); - assert.strictEqual(result, "cryptoKeyValue"); - assert((client.pathTemplates.publicKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCryptoKeyVersionFromPublicKeyName', () => { - const result = client.matchCryptoKeyVersionFromPublicKeyName(fakePath); - assert.strictEqual(result, "cryptoKeyVersionValue"); - assert((client.pathTemplates.publicKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('publicKey', async () => { + const fakePath = '/rendered/path/publicKey'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + key_ring: 'keyRingValue', + crypto_key: 'cryptoKeyValue', + crypto_key_version: 'cryptoKeyVersionValue', + }; + const client = new autokeyadminModule.v1.AutokeyAdminClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.publicKeyPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.publicKeyPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('publicKeyPath', () => { + const result = client.publicKeyPath( + 'projectValue', + 'locationValue', + 'keyRingValue', + 'cryptoKeyValue', + 'cryptoKeyVersionValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.publicKeyPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromPublicKeyName', () => { + const result = client.matchProjectFromPublicKeyName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.publicKeyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromPublicKeyName', () => { + const result = client.matchLocationFromPublicKeyName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.publicKeyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchKeyRingFromPublicKeyName', () => { + const result = client.matchKeyRingFromPublicKeyName(fakePath); + assert.strictEqual(result, 'keyRingValue'); + assert( + (client.pathTemplates.publicKeyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCryptoKeyFromPublicKeyName', () => { + const result = client.matchCryptoKeyFromPublicKeyName(fakePath); + assert.strictEqual(result, 'cryptoKeyValue'); + assert( + (client.pathTemplates.publicKeyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCryptoKeyVersionFromPublicKeyName', () => { + const result = client.matchCryptoKeyVersionFromPublicKeyName(fakePath); + assert.strictEqual(result, 'cryptoKeyVersionValue'); + assert( + (client.pathTemplates.publicKeyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('retiredResource', async () => { - const fakePath = "/rendered/path/retiredResource"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - retired_resource: "retiredResourceValue", - }; - const client = new autokeyadminModule.v1.AutokeyAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.retiredResourcePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.retiredResourcePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('retiredResourcePath', () => { - const result = client.retiredResourcePath("projectValue", "locationValue", "retiredResourceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.retiredResourcePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromRetiredResourceName', () => { - const result = client.matchProjectFromRetiredResourceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.retiredResourcePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromRetiredResourceName', () => { - const result = client.matchLocationFromRetiredResourceName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.retiredResourcePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRetiredResourceFromRetiredResourceName', () => { - const result = client.matchRetiredResourceFromRetiredResourceName(fakePath); - assert.strictEqual(result, "retiredResourceValue"); - assert((client.pathTemplates.retiredResourcePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('retiredResource', async () => { + const fakePath = '/rendered/path/retiredResource'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + retired_resource: 'retiredResourceValue', + }; + const client = new autokeyadminModule.v1.AutokeyAdminClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.retiredResourcePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.retiredResourcePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('retiredResourcePath', () => { + const result = client.retiredResourcePath( + 'projectValue', + 'locationValue', + 'retiredResourceValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.retiredResourcePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromRetiredResourceName', () => { + const result = client.matchProjectFromRetiredResourceName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.retiredResourcePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromRetiredResourceName', () => { + const result = client.matchLocationFromRetiredResourceName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.retiredResourcePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRetiredResourceFromRetiredResourceName', () => { + const result = + client.matchRetiredResourceFromRetiredResourceName(fakePath); + assert.strictEqual(result, 'retiredResourceValue'); + assert( + (client.pathTemplates.retiredResourcePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('singleTenantHsmInstance', async () => { - const fakePath = "/rendered/path/singleTenantHsmInstance"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - single_tenant_hsm_instance: "singleTenantHsmInstanceValue", - }; - const client = new autokeyadminModule.v1.AutokeyAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.singleTenantHsmInstancePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.singleTenantHsmInstancePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('singleTenantHsmInstancePath', () => { - const result = client.singleTenantHsmInstancePath("projectValue", "locationValue", "singleTenantHsmInstanceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.singleTenantHsmInstancePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromSingleTenantHsmInstanceName', () => { - const result = client.matchProjectFromSingleTenantHsmInstanceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.singleTenantHsmInstancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromSingleTenantHsmInstanceName', () => { - const result = client.matchLocationFromSingleTenantHsmInstanceName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.singleTenantHsmInstancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceName', () => { - const result = client.matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceName(fakePath); - assert.strictEqual(result, "singleTenantHsmInstanceValue"); - assert((client.pathTemplates.singleTenantHsmInstancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('singleTenantHsmInstance', async () => { + const fakePath = '/rendered/path/singleTenantHsmInstance'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + single_tenant_hsm_instance: 'singleTenantHsmInstanceValue', + }; + const client = new autokeyadminModule.v1.AutokeyAdminClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.singleTenantHsmInstancePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.singleTenantHsmInstancePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('singleTenantHsmInstancePath', () => { + const result = client.singleTenantHsmInstancePath( + 'projectValue', + 'locationValue', + 'singleTenantHsmInstanceValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.singleTenantHsmInstancePathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromSingleTenantHsmInstanceName', () => { + const result = + client.matchProjectFromSingleTenantHsmInstanceName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.singleTenantHsmInstancePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromSingleTenantHsmInstanceName', () => { + const result = + client.matchLocationFromSingleTenantHsmInstanceName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.singleTenantHsmInstancePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceName', () => { + const result = + client.matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceName( + fakePath, + ); + assert.strictEqual(result, 'singleTenantHsmInstanceValue'); + assert( + ( + client.pathTemplates.singleTenantHsmInstancePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('singleTenantHsmInstanceProposal', async () => { - const fakePath = "/rendered/path/singleTenantHsmInstanceProposal"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - single_tenant_hsm_instance: "singleTenantHsmInstanceValue", - proposal: "proposalValue", - }; - const client = new autokeyadminModule.v1.AutokeyAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('singleTenantHsmInstanceProposalPath', () => { - const result = client.singleTenantHsmInstanceProposalPath("projectValue", "locationValue", "singleTenantHsmInstanceValue", "proposalValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromSingleTenantHsmInstanceProposalName', () => { - const result = client.matchProjectFromSingleTenantHsmInstanceProposalName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromSingleTenantHsmInstanceProposalName', () => { - const result = client.matchLocationFromSingleTenantHsmInstanceProposalName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceProposalName', () => { - const result = client.matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceProposalName(fakePath); - assert.strictEqual(result, "singleTenantHsmInstanceValue"); - assert((client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProposalFromSingleTenantHsmInstanceProposalName', () => { - const result = client.matchProposalFromSingleTenantHsmInstanceProposalName(fakePath); - assert.strictEqual(result, "proposalValue"); - assert((client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('singleTenantHsmInstanceProposal', async () => { + const fakePath = '/rendered/path/singleTenantHsmInstanceProposal'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + single_tenant_hsm_instance: 'singleTenantHsmInstanceValue', + proposal: 'proposalValue', + }; + const client = new autokeyadminModule.v1.AutokeyAdminClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('singleTenantHsmInstanceProposalPath', () => { + const result = client.singleTenantHsmInstanceProposalPath( + 'projectValue', + 'locationValue', + 'singleTenantHsmInstanceValue', + 'proposalValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromSingleTenantHsmInstanceProposalName', () => { + const result = + client.matchProjectFromSingleTenantHsmInstanceProposalName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromSingleTenantHsmInstanceProposalName', () => { + const result = + client.matchLocationFromSingleTenantHsmInstanceProposalName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceProposalName', () => { + const result = + client.matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceProposalName( + fakePath, + ); + assert.strictEqual(result, 'singleTenantHsmInstanceValue'); + assert( + ( + client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchProposalFromSingleTenantHsmInstanceProposalName', () => { + const result = + client.matchProposalFromSingleTenantHsmInstanceProposalName(fakePath); + assert.strictEqual(result, 'proposalValue'); + assert( + ( + client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-kms/test/gapic_autokey_v1.ts b/packages/google-cloud-kms/test/gapic_autokey_v1.ts index 549e90f602f3..3ea7cff4168c 100644 --- a/packages/google-cloud-kms/test/gapic_autokey_v1.ts +++ b/packages/google-cloud-kms/test/gapic_autokey_v1.ts @@ -19,2118 +19,2761 @@ 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 autokeyModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf, LROperation, operationsProtos, IamProtos, LocationProtos} from 'google-gax'; +import { + protobuf, + LROperation, + operationsProtos, + IamProtos, + LocationProtos, +} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); +const root = protobuf.Root.fromJSON( + require('../protos/protos.json'), +).resolveAll(); // eslint-disable-next-line @typescript-eslint/no-unused-vars function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; } function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, { defaults: true }); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject, + ) as T; } function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); } -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error, +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); } -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +function stubLongRunningCall( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().rejects(callError) + : sinon.stub().resolves([mockOperation]); } -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +function stubLongRunningCallWithCallback( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().callsArgWith(2, callError) + : sinon.stub().callsArgWith(2, null, mockOperation); } -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error, +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); } - return sinon.stub().returns(mockStream); + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); } -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error, +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({ done: true, value: undefined }); + } + return Promise.resolve({ done: false, value: responses![counter++] }); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); } describe('v1.AutokeyClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new autokeyModule.v1.AutokeyClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'cloudkms.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new autokeyModule.v1.AutokeyClient(); - 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 = autokeyModule.v1.AutokeyClient.servicePath; - assert.strictEqual(servicePath, 'cloudkms.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = autokeyModule.v1.AutokeyClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'cloudkms.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new autokeyModule.v1.AutokeyClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudkms.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new autokeyModule.v1.AutokeyClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudkms.example.com'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new autokeyModule.v1.AutokeyClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'cloudkms.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 autokeyModule.v1.AutokeyClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudkms.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 autokeyModule.v1.AutokeyClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudkms.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 autokeyModule.v1.AutokeyClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); + it('has universeDomain', () => { + const client = new autokeyModule.v1.AutokeyClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('has port', () => { - const port = autokeyModule.v1.AutokeyClient.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 = autokeyModule.v1.AutokeyClient.servicePath; + assert.strictEqual(servicePath, 'cloudkms.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = autokeyModule.v1.AutokeyClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'cloudkms.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new autokeyModule.v1.AutokeyClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudkms.example.com'); + }); - it('should create a client with no option', () => { - const client = new autokeyModule.v1.AutokeyClient(); - assert(client); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new autokeyModule.v1.AutokeyClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudkms.example.com'); + }); - it('should create a client with gRPC fallback', () => { - const client = new autokeyModule.v1.AutokeyClient({ - 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 autokeyModule.v1.AutokeyClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudkms.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 autokeyModule.v1.AutokeyClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudkms.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 autokeyModule.v1.AutokeyClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new autokeyModule.v1.AutokeyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.autokeyStub, undefined); - await client.initialize(); - assert(client.autokeyStub); - }); + it('has port', () => { + const port = autokeyModule.v1.AutokeyClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has close method for the initialized client', done => { - const client = new autokeyModule.v1.AutokeyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.autokeyStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('should create a client with no option', () => { + const client = new autokeyModule.v1.AutokeyClient(); + assert(client); + }); - it('has close method for the non-initialized client', done => { - const client = new autokeyModule.v1.AutokeyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.autokeyStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('should create a client with gRPC fallback', () => { + const client = new autokeyModule.v1.AutokeyClient({ + fallback: true, + }); + assert(client); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new autokeyModule.v1.AutokeyClient({ - 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 autokeyModule.v1.AutokeyClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.autokeyStub, undefined); + await client.initialize(); + assert(client.autokeyStub); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new autokeyModule.v1.AutokeyClient({ - 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 autokeyModule.v1.AutokeyClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.autokeyStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('getKeyHandle', () => { - it('invokes getKeyHandle without error', async () => { - const client = new autokeyModule.v1.AutokeyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.GetKeyHandleRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.GetKeyHandleRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.KeyHandle() - ); - client.innerApiCalls.getKeyHandle = stubSimpleCall(expectedResponse); - const [response] = await client.getKeyHandle(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getKeyHandle as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getKeyHandle 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 autokeyModule.v1.AutokeyClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.autokeyStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes getKeyHandle without error using callback', async () => { - const client = new autokeyModule.v1.AutokeyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.GetKeyHandleRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.GetKeyHandleRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.KeyHandle() - ); - client.innerApiCalls.getKeyHandle = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getKeyHandle( - request, - (err?: Error|null, result?: protos.google.cloud.kms.v1.IKeyHandle|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getKeyHandle as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getKeyHandle 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 autokeyModule.v1.AutokeyClient({ + 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 getKeyHandle with error', async () => { - const client = new autokeyModule.v1.AutokeyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.GetKeyHandleRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.GetKeyHandleRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getKeyHandle = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getKeyHandle(request), expectedError); - const actualRequest = (client.innerApiCalls.getKeyHandle as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getKeyHandle 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 autokeyModule.v1.AutokeyClient({ + 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('getKeyHandle', () => { + it('invokes getKeyHandle without error', async () => { + const client = new autokeyModule.v1.AutokeyClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.GetKeyHandleRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.GetKeyHandleRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.KeyHandle(), + ); + client.innerApiCalls.getKeyHandle = stubSimpleCall(expectedResponse); + const [response] = await client.getKeyHandle(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getKeyHandle as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getKeyHandle as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getKeyHandle with closed client', async () => { - const client = new autokeyModule.v1.AutokeyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.GetKeyHandleRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.GetKeyHandleRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getKeyHandle(request), expectedError); - }); + it('invokes getKeyHandle without error using callback', async () => { + const client = new autokeyModule.v1.AutokeyClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.GetKeyHandleRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.GetKeyHandleRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.KeyHandle(), + ); + client.innerApiCalls.getKeyHandle = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getKeyHandle( + request, + ( + err?: Error | null, + result?: protos.google.cloud.kms.v1.IKeyHandle | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getKeyHandle as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getKeyHandle as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createKeyHandle', () => { - it('invokes createKeyHandle without error', async () => { - const client = new autokeyModule.v1.AutokeyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.CreateKeyHandleRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.CreateKeyHandleRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createKeyHandle = stubLongRunningCall(expectedResponse); - const [operation] = await client.createKeyHandle(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createKeyHandle as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createKeyHandle as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getKeyHandle with error', async () => { + const client = new autokeyModule.v1.AutokeyClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.GetKeyHandleRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.GetKeyHandleRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getKeyHandle = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getKeyHandle(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getKeyHandle as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getKeyHandle as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createKeyHandle without error using callback', async () => { - const client = new autokeyModule.v1.AutokeyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.CreateKeyHandleRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.CreateKeyHandleRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createKeyHandle = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createKeyHandle( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createKeyHandle as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createKeyHandle as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getKeyHandle with closed client', async () => { + const client = new autokeyModule.v1.AutokeyClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.GetKeyHandleRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.GetKeyHandleRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getKeyHandle(request), expectedError); + }); + }); + + describe('createKeyHandle', () => { + it('invokes createKeyHandle without error', async () => { + const client = new autokeyModule.v1.AutokeyClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.CreateKeyHandleRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.CreateKeyHandleRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createKeyHandle = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createKeyHandle(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createKeyHandle as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createKeyHandle as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createKeyHandle with call error', async () => { - const client = new autokeyModule.v1.AutokeyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.CreateKeyHandleRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.CreateKeyHandleRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createKeyHandle = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createKeyHandle(request), expectedError); - const actualRequest = (client.innerApiCalls.createKeyHandle as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createKeyHandle as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createKeyHandle without error using callback', async () => { + const client = new autokeyModule.v1.AutokeyClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.CreateKeyHandleRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.CreateKeyHandleRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createKeyHandle = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createKeyHandle( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.kms.v1.IKeyHandle, + protos.google.cloud.kms.v1.ICreateKeyHandleMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.kms.v1.IKeyHandle, + protos.google.cloud.kms.v1.ICreateKeyHandleMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createKeyHandle as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createKeyHandle as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createKeyHandle with LRO error', async () => { - const client = new autokeyModule.v1.AutokeyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.CreateKeyHandleRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.CreateKeyHandleRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createKeyHandle = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createKeyHandle(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createKeyHandle as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createKeyHandle as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createKeyHandle with call error', async () => { + const client = new autokeyModule.v1.AutokeyClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.CreateKeyHandleRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.CreateKeyHandleRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createKeyHandle = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createKeyHandle(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createKeyHandle as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createKeyHandle as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateKeyHandleProgress without error', async () => { - const client = new autokeyModule.v1.AutokeyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateKeyHandleProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createKeyHandle with LRO error', async () => { + const client = new autokeyModule.v1.AutokeyClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.CreateKeyHandleRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.CreateKeyHandleRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createKeyHandle = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createKeyHandle(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createKeyHandle as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createKeyHandle as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateKeyHandleProgress with error', async () => { - const client = new autokeyModule.v1.AutokeyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateKeyHandleProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkCreateKeyHandleProgress without error', async () => { + const client = new autokeyModule.v1.AutokeyClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateKeyHandleProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('listKeyHandles', () => { - it('invokes listKeyHandles without error', async () => { - const client = new autokeyModule.v1.AutokeyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListKeyHandlesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListKeyHandlesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.kms.v1.KeyHandle()), - generateSampleMessage(new protos.google.cloud.kms.v1.KeyHandle()), - generateSampleMessage(new protos.google.cloud.kms.v1.KeyHandle()), - ]; - client.innerApiCalls.listKeyHandles = stubSimpleCall(expectedResponse); - const [response] = await client.listKeyHandles(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listKeyHandles as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listKeyHandles as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateKeyHandleProgress with error', async () => { + const client = new autokeyModule.v1.AutokeyClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateKeyHandleProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listKeyHandles', () => { + it('invokes listKeyHandles without error', async () => { + const client = new autokeyModule.v1.AutokeyClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListKeyHandlesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListKeyHandlesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.kms.v1.KeyHandle()), + generateSampleMessage(new protos.google.cloud.kms.v1.KeyHandle()), + generateSampleMessage(new protos.google.cloud.kms.v1.KeyHandle()), + ]; + client.innerApiCalls.listKeyHandles = stubSimpleCall(expectedResponse); + const [response] = await client.listKeyHandles(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listKeyHandles as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listKeyHandles as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listKeyHandles without error using callback', async () => { - const client = new autokeyModule.v1.AutokeyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListKeyHandlesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListKeyHandlesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.kms.v1.KeyHandle()), - generateSampleMessage(new protos.google.cloud.kms.v1.KeyHandle()), - generateSampleMessage(new protos.google.cloud.kms.v1.KeyHandle()), - ]; - client.innerApiCalls.listKeyHandles = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listKeyHandles( - request, - (err?: Error|null, result?: protos.google.cloud.kms.v1.IKeyHandle[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listKeyHandles as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listKeyHandles as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listKeyHandles without error using callback', async () => { + const client = new autokeyModule.v1.AutokeyClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListKeyHandlesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListKeyHandlesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.kms.v1.KeyHandle()), + generateSampleMessage(new protos.google.cloud.kms.v1.KeyHandle()), + generateSampleMessage(new protos.google.cloud.kms.v1.KeyHandle()), + ]; + client.innerApiCalls.listKeyHandles = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listKeyHandles( + request, + ( + err?: Error | null, + result?: protos.google.cloud.kms.v1.IKeyHandle[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listKeyHandles as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listKeyHandles as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listKeyHandles with error', async () => { - const client = new autokeyModule.v1.AutokeyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListKeyHandlesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListKeyHandlesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listKeyHandles = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listKeyHandles(request), expectedError); - const actualRequest = (client.innerApiCalls.listKeyHandles as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listKeyHandles as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listKeyHandles with error', async () => { + const client = new autokeyModule.v1.AutokeyClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListKeyHandlesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListKeyHandlesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listKeyHandles = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listKeyHandles(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listKeyHandles as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listKeyHandles as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listKeyHandlesStream without error', async () => { - const client = new autokeyModule.v1.AutokeyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListKeyHandlesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListKeyHandlesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.kms.v1.KeyHandle()), - generateSampleMessage(new protos.google.cloud.kms.v1.KeyHandle()), - generateSampleMessage(new protos.google.cloud.kms.v1.KeyHandle()), - ]; - client.descriptors.page.listKeyHandles.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listKeyHandlesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.kms.v1.KeyHandle[] = []; - stream.on('data', (response: protos.google.cloud.kms.v1.KeyHandle) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listKeyHandles.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listKeyHandles, request)); - assert( - (client.descriptors.page.listKeyHandles.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listKeyHandlesStream without error', async () => { + const client = new autokeyModule.v1.AutokeyClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListKeyHandlesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListKeyHandlesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.kms.v1.KeyHandle()), + generateSampleMessage(new protos.google.cloud.kms.v1.KeyHandle()), + generateSampleMessage(new protos.google.cloud.kms.v1.KeyHandle()), + ]; + client.descriptors.page.listKeyHandles.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listKeyHandlesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.kms.v1.KeyHandle[] = []; + stream.on('data', (response: protos.google.cloud.kms.v1.KeyHandle) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listKeyHandles.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listKeyHandles, request), + ); + assert( + (client.descriptors.page.listKeyHandles.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listKeyHandlesStream with error', async () => { - const client = new autokeyModule.v1.AutokeyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListKeyHandlesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListKeyHandlesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listKeyHandles.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listKeyHandlesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.kms.v1.KeyHandle[] = []; - stream.on('data', (response: protos.google.cloud.kms.v1.KeyHandle) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listKeyHandles.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listKeyHandles, request)); - assert( - (client.descriptors.page.listKeyHandles.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listKeyHandlesStream with error', async () => { + const client = new autokeyModule.v1.AutokeyClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListKeyHandlesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListKeyHandlesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listKeyHandles.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listKeyHandlesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.kms.v1.KeyHandle[] = []; + stream.on('data', (response: protos.google.cloud.kms.v1.KeyHandle) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listKeyHandles.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listKeyHandles, request), + ); + assert( + (client.descriptors.page.listKeyHandles.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listKeyHandles without error', async () => { - const client = new autokeyModule.v1.AutokeyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListKeyHandlesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListKeyHandlesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.kms.v1.KeyHandle()), - generateSampleMessage(new protos.google.cloud.kms.v1.KeyHandle()), - generateSampleMessage(new protos.google.cloud.kms.v1.KeyHandle()), - ]; - client.descriptors.page.listKeyHandles.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.kms.v1.IKeyHandle[] = []; - const iterable = client.listKeyHandlesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listKeyHandles.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listKeyHandles.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listKeyHandles without error', async () => { + const client = new autokeyModule.v1.AutokeyClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListKeyHandlesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListKeyHandlesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.kms.v1.KeyHandle()), + generateSampleMessage(new protos.google.cloud.kms.v1.KeyHandle()), + generateSampleMessage(new protos.google.cloud.kms.v1.KeyHandle()), + ]; + client.descriptors.page.listKeyHandles.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.kms.v1.IKeyHandle[] = []; + const iterable = client.listKeyHandlesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listKeyHandles.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listKeyHandles.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listKeyHandles with error', async () => { - const client = new autokeyModule.v1.AutokeyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListKeyHandlesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListKeyHandlesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listKeyHandles.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listKeyHandlesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.kms.v1.IKeyHandle[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listKeyHandles.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listKeyHandles.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listKeyHandles with error', async () => { + const client = new autokeyModule.v1.AutokeyClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListKeyHandlesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListKeyHandlesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listKeyHandles.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listKeyHandlesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.kms.v1.IKeyHandle[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listKeyHandles.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listKeyHandles.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); }); - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new autokeyModule.v1.AutokeyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.getIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getIamPolicy without error using callback', async () => { - const client = new autokeyModule.v1.AutokeyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes getIamPolicy with error', async () => { - const client = new autokeyModule.v1.AutokeyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new autokeyModule.v1.AutokeyClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.getIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new autokeyModule.v1.AutokeyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.setIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes setIamPolicy without error using callback', async () => { - const client = new autokeyModule.v1.AutokeyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes setIamPolicy with error', async () => { - const client = new autokeyModule.v1.AutokeyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getIamPolicy without error using callback', async () => { + const client = new autokeyModule.v1.AutokeyClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .getIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.getIamPolicy as SinonStub).getCall(0)); }); - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new autokeyModule.v1.AutokeyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); - const response = await client.testIamPermissions(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes testIamPermissions without error using callback', async () => { - const client = new autokeyModule.v1.AutokeyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.TestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0)); - }); - it('invokes testIamPermissions with error', async () => { - const client = new autokeyModule.v1.AutokeyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request, expectedOptions), expectedError); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getIamPolicy with error', async () => { + const client = new autokeyModule.v1.AutokeyClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.getIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new autokeyModule.v1.AutokeyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - 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 autokeyModule.v1.AutokeyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - 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 autokeyModule.v1.AutokeyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new autokeyModule.v1.AutokeyClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.setIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new autokeyModule.v1.AutokeyClient({ - 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 autokeyModule.v1.AutokeyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes setIamPolicy without error using callback', async () => { + const client = new autokeyModule.v1.AutokeyClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .setIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.setIamPolicy as SinonStub).getCall(0)); }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new autokeyModule.v1.AutokeyClient({ - 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 autokeyModule.v1.AutokeyClient({ - 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 autokeyModule.v1.AutokeyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('invokes setIamPolicy with error', async () => { + const client = new autokeyModule.v1.AutokeyClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.setIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new autokeyModule.v1.AutokeyClient({ - 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 autokeyModule.v1.AutokeyClient({ - 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 autokeyModule.v1.AutokeyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + }); + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new autokeyModule.v1.AutokeyClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); + const response = await client.testIamPermissions( + request, + expectedOptions, + ); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new autokeyModule.v1.AutokeyClient({ - 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 autokeyModule.v1.AutokeyClient({ - 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 autokeyModule.v1.AutokeyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('invokes testIamPermissions without error using callback', async () => { + const client = new autokeyModule.v1.AutokeyClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .testIamPermissions( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.TestIamPermissionsResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.testIamPermissions as SinonStub).getCall(0)); + }); + it('invokes testIamPermissions with error', async () => { + const client = new autokeyModule.v1.AutokeyClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.testIamPermissions = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.testIamPermissions(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new autokeyModule.v1.AutokeyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.IOperation[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new autokeyModule.v1.AutokeyClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + 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 autokeyModule.v1.AutokeyClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new autokeyModule.v1.AutokeyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.IOperation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new autokeyModule.v1.AutokeyClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + 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 autokeyModule.v1.AutokeyClient({ + 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 autokeyModule.v1.AutokeyClient({ + 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 autokeyModule.v1.AutokeyClient({ + 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 autokeyModule.v1.AutokeyClient({ + 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 autokeyModule.v1.AutokeyClient({ + 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 autokeyModule.v1.AutokeyClient({ + 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 autokeyModule.v1.AutokeyClient({ + 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 autokeyModule.v1.AutokeyClient({ + 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 autokeyModule.v1.AutokeyClient({ + 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 autokeyModule.v1.AutokeyClient({ + 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 autokeyModule.v1.AutokeyClient({ + 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 autokeyModule.v1.AutokeyClient({ + 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 autokeyModule.v1.AutokeyClient({ + 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('cryptoKey', async () => { + const fakePath = '/rendered/path/cryptoKey'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + key_ring: 'keyRingValue', + crypto_key: 'cryptoKeyValue', + }; + const client = new autokeyModule.v1.AutokeyClient({ + 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('Path templates', () => { - - describe('cryptoKey', async () => { - const fakePath = "/rendered/path/cryptoKey"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - key_ring: "keyRingValue", - crypto_key: "cryptoKeyValue", - }; - const client = new autokeyModule.v1.AutokeyClient({ - 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 autokeyModule.v1.AutokeyClient({ - 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 autokeyModule.v1.AutokeyClient({ + 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('ekmConfig', async () => { - const fakePath = "/rendered/path/ekmConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new autokeyModule.v1.AutokeyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.ekmConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.ekmConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('ekmConfigPath', () => { - const result = client.ekmConfigPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.ekmConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromEkmConfigName', () => { - const result = client.matchProjectFromEkmConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.ekmConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromEkmConfigName', () => { - const result = client.matchLocationFromEkmConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.ekmConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('ekmConfig', async () => { + const fakePath = '/rendered/path/ekmConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = new autokeyModule.v1.AutokeyClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.ekmConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.ekmConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('ekmConfigPath', () => { + const result = client.ekmConfigPath('projectValue', 'locationValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.ekmConfigPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromEkmConfigName', () => { + const result = client.matchProjectFromEkmConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.ekmConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromEkmConfigName', () => { + const result = client.matchLocationFromEkmConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.ekmConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('ekmConnection', async () => { - const fakePath = "/rendered/path/ekmConnection"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - ekm_connection: "ekmConnectionValue", - }; - const client = new autokeyModule.v1.AutokeyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.ekmConnectionPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.ekmConnectionPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('ekmConnectionPath', () => { - const result = client.ekmConnectionPath("projectValue", "locationValue", "ekmConnectionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.ekmConnectionPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromEkmConnectionName', () => { - const result = client.matchProjectFromEkmConnectionName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.ekmConnectionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromEkmConnectionName', () => { - const result = client.matchLocationFromEkmConnectionName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.ekmConnectionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchEkmConnectionFromEkmConnectionName', () => { - const result = client.matchEkmConnectionFromEkmConnectionName(fakePath); - assert.strictEqual(result, "ekmConnectionValue"); - assert((client.pathTemplates.ekmConnectionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('ekmConnection', async () => { + const fakePath = '/rendered/path/ekmConnection'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + ekm_connection: 'ekmConnectionValue', + }; + const client = new autokeyModule.v1.AutokeyClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.ekmConnectionPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.ekmConnectionPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('ekmConnectionPath', () => { + const result = client.ekmConnectionPath( + 'projectValue', + 'locationValue', + 'ekmConnectionValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.ekmConnectionPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromEkmConnectionName', () => { + const result = client.matchProjectFromEkmConnectionName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.ekmConnectionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromEkmConnectionName', () => { + const result = client.matchLocationFromEkmConnectionName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.ekmConnectionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchEkmConnectionFromEkmConnectionName', () => { + const result = client.matchEkmConnectionFromEkmConnectionName(fakePath); + assert.strictEqual(result, 'ekmConnectionValue'); + assert( + (client.pathTemplates.ekmConnectionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('folderAutokeyConfig', async () => { - const fakePath = "/rendered/path/folderAutokeyConfig"; - const expectedParameters = { - folder: "folderValue", - }; - const client = new autokeyModule.v1.AutokeyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.folderAutokeyConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.folderAutokeyConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('folderAutokeyConfigPath', () => { - const result = client.folderAutokeyConfigPath("folderValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.folderAutokeyConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchFolderFromFolderAutokeyConfigName', () => { - const result = client.matchFolderFromFolderAutokeyConfigName(fakePath); - assert.strictEqual(result, "folderValue"); - assert((client.pathTemplates.folderAutokeyConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('folderAutokeyConfig', async () => { + const fakePath = '/rendered/path/folderAutokeyConfig'; + const expectedParameters = { + folder: 'folderValue', + }; + const client = new autokeyModule.v1.AutokeyClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.folderAutokeyConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.folderAutokeyConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('folderAutokeyConfigPath', () => { + const result = client.folderAutokeyConfigPath('folderValue'); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.folderAutokeyConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchFolderFromFolderAutokeyConfigName', () => { + const result = client.matchFolderFromFolderAutokeyConfigName(fakePath); + assert.strictEqual(result, 'folderValue'); + assert( + ( + client.pathTemplates.folderAutokeyConfigPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('importJob', async () => { - const fakePath = "/rendered/path/importJob"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - key_ring: "keyRingValue", - import_job: "importJobValue", - }; - const client = new autokeyModule.v1.AutokeyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.importJobPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.importJobPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('importJobPath', () => { - const result = client.importJobPath("projectValue", "locationValue", "keyRingValue", "importJobValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.importJobPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromImportJobName', () => { - const result = client.matchProjectFromImportJobName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.importJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromImportJobName', () => { - const result = client.matchLocationFromImportJobName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.importJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchKeyRingFromImportJobName', () => { - const result = client.matchKeyRingFromImportJobName(fakePath); - assert.strictEqual(result, "keyRingValue"); - assert((client.pathTemplates.importJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchImportJobFromImportJobName', () => { - const result = client.matchImportJobFromImportJobName(fakePath); - assert.strictEqual(result, "importJobValue"); - assert((client.pathTemplates.importJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('importJob', async () => { + const fakePath = '/rendered/path/importJob'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + key_ring: 'keyRingValue', + import_job: 'importJobValue', + }; + const client = new autokeyModule.v1.AutokeyClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.importJobPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.importJobPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('importJobPath', () => { + const result = client.importJobPath( + 'projectValue', + 'locationValue', + 'keyRingValue', + 'importJobValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.importJobPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromImportJobName', () => { + const result = client.matchProjectFromImportJobName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.importJobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromImportJobName', () => { + const result = client.matchLocationFromImportJobName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.importJobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchKeyRingFromImportJobName', () => { + const result = client.matchKeyRingFromImportJobName(fakePath); + assert.strictEqual(result, 'keyRingValue'); + assert( + (client.pathTemplates.importJobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchImportJobFromImportJobName', () => { + const result = client.matchImportJobFromImportJobName(fakePath); + assert.strictEqual(result, 'importJobValue'); + assert( + (client.pathTemplates.importJobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('keyHandle', async () => { - const fakePath = "/rendered/path/keyHandle"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - key_handle: "keyHandleValue", - }; - const client = new autokeyModule.v1.AutokeyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.keyHandlePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.keyHandlePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('keyHandlePath', () => { - const result = client.keyHandlePath("projectValue", "locationValue", "keyHandleValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.keyHandlePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromKeyHandleName', () => { - const result = client.matchProjectFromKeyHandleName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.keyHandlePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromKeyHandleName', () => { - const result = client.matchLocationFromKeyHandleName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.keyHandlePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchKeyHandleFromKeyHandleName', () => { - const result = client.matchKeyHandleFromKeyHandleName(fakePath); - assert.strictEqual(result, "keyHandleValue"); - assert((client.pathTemplates.keyHandlePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('keyHandle', async () => { + const fakePath = '/rendered/path/keyHandle'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + key_handle: 'keyHandleValue', + }; + const client = new autokeyModule.v1.AutokeyClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.keyHandlePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.keyHandlePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('keyHandlePath', () => { + const result = client.keyHandlePath( + 'projectValue', + 'locationValue', + 'keyHandleValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.keyHandlePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromKeyHandleName', () => { + const result = client.matchProjectFromKeyHandleName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.keyHandlePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromKeyHandleName', () => { + const result = client.matchLocationFromKeyHandleName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.keyHandlePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchKeyHandleFromKeyHandleName', () => { + const result = client.matchKeyHandleFromKeyHandleName(fakePath); + assert.strictEqual(result, 'keyHandleValue'); + assert( + (client.pathTemplates.keyHandlePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('keyRing', async () => { - const fakePath = "/rendered/path/keyRing"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - key_ring: "keyRingValue", - }; - const client = new autokeyModule.v1.AutokeyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.keyRingPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.keyRingPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('keyRingPath', () => { - const result = client.keyRingPath("projectValue", "locationValue", "keyRingValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.keyRingPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromKeyRingName', () => { - const result = client.matchProjectFromKeyRingName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.keyRingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromKeyRingName', () => { - const result = client.matchLocationFromKeyRingName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.keyRingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchKeyRingFromKeyRingName', () => { - const result = client.matchKeyRingFromKeyRingName(fakePath); - assert.strictEqual(result, "keyRingValue"); - assert((client.pathTemplates.keyRingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('keyRing', async () => { + const fakePath = '/rendered/path/keyRing'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + key_ring: 'keyRingValue', + }; + const client = new autokeyModule.v1.AutokeyClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.keyRingPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.keyRingPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('keyRingPath', () => { + const result = client.keyRingPath( + 'projectValue', + 'locationValue', + 'keyRingValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.keyRingPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromKeyRingName', () => { + const result = client.matchProjectFromKeyRingName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.keyRingPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromKeyRingName', () => { + const result = client.matchLocationFromKeyRingName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.keyRingPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchKeyRingFromKeyRingName', () => { + const result = client.matchKeyRingFromKeyRingName(fakePath); + assert.strictEqual(result, 'keyRingValue'); + assert( + (client.pathTemplates.keyRingPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('location', async () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new autokeyModule.v1.AutokeyClient({ - 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 autokeyModule.v1.AutokeyClient({ + 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('projectAutokeyConfig', async () => { - const fakePath = "/rendered/path/projectAutokeyConfig"; - const expectedParameters = { - project: "projectValue", - }; - const client = new autokeyModule.v1.AutokeyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectAutokeyConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectAutokeyConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectAutokeyConfigPath', () => { - const result = client.projectAutokeyConfigPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectAutokeyConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectAutokeyConfigName', () => { - const result = client.matchProjectFromProjectAutokeyConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectAutokeyConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectAutokeyConfig', async () => { + const fakePath = '/rendered/path/projectAutokeyConfig'; + const expectedParameters = { + project: 'projectValue', + }; + const client = new autokeyModule.v1.AutokeyClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectAutokeyConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectAutokeyConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectAutokeyConfigPath', () => { + const result = client.projectAutokeyConfigPath('projectValue'); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectAutokeyConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectAutokeyConfigName', () => { + const result = + client.matchProjectFromProjectAutokeyConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.projectAutokeyConfigPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('publicKey', async () => { - const fakePath = "/rendered/path/publicKey"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - key_ring: "keyRingValue", - crypto_key: "cryptoKeyValue", - crypto_key_version: "cryptoKeyVersionValue", - }; - const client = new autokeyModule.v1.AutokeyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.publicKeyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.publicKeyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('publicKeyPath', () => { - const result = client.publicKeyPath("projectValue", "locationValue", "keyRingValue", "cryptoKeyValue", "cryptoKeyVersionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.publicKeyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromPublicKeyName', () => { - const result = client.matchProjectFromPublicKeyName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.publicKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromPublicKeyName', () => { - const result = client.matchLocationFromPublicKeyName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.publicKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchKeyRingFromPublicKeyName', () => { - const result = client.matchKeyRingFromPublicKeyName(fakePath); - assert.strictEqual(result, "keyRingValue"); - assert((client.pathTemplates.publicKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCryptoKeyFromPublicKeyName', () => { - const result = client.matchCryptoKeyFromPublicKeyName(fakePath); - assert.strictEqual(result, "cryptoKeyValue"); - assert((client.pathTemplates.publicKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCryptoKeyVersionFromPublicKeyName', () => { - const result = client.matchCryptoKeyVersionFromPublicKeyName(fakePath); - assert.strictEqual(result, "cryptoKeyVersionValue"); - assert((client.pathTemplates.publicKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('publicKey', async () => { + const fakePath = '/rendered/path/publicKey'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + key_ring: 'keyRingValue', + crypto_key: 'cryptoKeyValue', + crypto_key_version: 'cryptoKeyVersionValue', + }; + const client = new autokeyModule.v1.AutokeyClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.publicKeyPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.publicKeyPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('publicKeyPath', () => { + const result = client.publicKeyPath( + 'projectValue', + 'locationValue', + 'keyRingValue', + 'cryptoKeyValue', + 'cryptoKeyVersionValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.publicKeyPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromPublicKeyName', () => { + const result = client.matchProjectFromPublicKeyName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.publicKeyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromPublicKeyName', () => { + const result = client.matchLocationFromPublicKeyName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.publicKeyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchKeyRingFromPublicKeyName', () => { + const result = client.matchKeyRingFromPublicKeyName(fakePath); + assert.strictEqual(result, 'keyRingValue'); + assert( + (client.pathTemplates.publicKeyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCryptoKeyFromPublicKeyName', () => { + const result = client.matchCryptoKeyFromPublicKeyName(fakePath); + assert.strictEqual(result, 'cryptoKeyValue'); + assert( + (client.pathTemplates.publicKeyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCryptoKeyVersionFromPublicKeyName', () => { + const result = client.matchCryptoKeyVersionFromPublicKeyName(fakePath); + assert.strictEqual(result, 'cryptoKeyVersionValue'); + assert( + (client.pathTemplates.publicKeyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('retiredResource', async () => { - const fakePath = "/rendered/path/retiredResource"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - retired_resource: "retiredResourceValue", - }; - const client = new autokeyModule.v1.AutokeyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.retiredResourcePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.retiredResourcePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('retiredResourcePath', () => { - const result = client.retiredResourcePath("projectValue", "locationValue", "retiredResourceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.retiredResourcePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromRetiredResourceName', () => { - const result = client.matchProjectFromRetiredResourceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.retiredResourcePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromRetiredResourceName', () => { - const result = client.matchLocationFromRetiredResourceName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.retiredResourcePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRetiredResourceFromRetiredResourceName', () => { - const result = client.matchRetiredResourceFromRetiredResourceName(fakePath); - assert.strictEqual(result, "retiredResourceValue"); - assert((client.pathTemplates.retiredResourcePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('retiredResource', async () => { + const fakePath = '/rendered/path/retiredResource'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + retired_resource: 'retiredResourceValue', + }; + const client = new autokeyModule.v1.AutokeyClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.retiredResourcePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.retiredResourcePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('retiredResourcePath', () => { + const result = client.retiredResourcePath( + 'projectValue', + 'locationValue', + 'retiredResourceValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.retiredResourcePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromRetiredResourceName', () => { + const result = client.matchProjectFromRetiredResourceName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.retiredResourcePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromRetiredResourceName', () => { + const result = client.matchLocationFromRetiredResourceName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.retiredResourcePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRetiredResourceFromRetiredResourceName', () => { + const result = + client.matchRetiredResourceFromRetiredResourceName(fakePath); + assert.strictEqual(result, 'retiredResourceValue'); + assert( + (client.pathTemplates.retiredResourcePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('singleTenantHsmInstance', async () => { - const fakePath = "/rendered/path/singleTenantHsmInstance"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - single_tenant_hsm_instance: "singleTenantHsmInstanceValue", - }; - const client = new autokeyModule.v1.AutokeyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.singleTenantHsmInstancePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.singleTenantHsmInstancePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('singleTenantHsmInstancePath', () => { - const result = client.singleTenantHsmInstancePath("projectValue", "locationValue", "singleTenantHsmInstanceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.singleTenantHsmInstancePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromSingleTenantHsmInstanceName', () => { - const result = client.matchProjectFromSingleTenantHsmInstanceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.singleTenantHsmInstancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromSingleTenantHsmInstanceName', () => { - const result = client.matchLocationFromSingleTenantHsmInstanceName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.singleTenantHsmInstancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceName', () => { - const result = client.matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceName(fakePath); - assert.strictEqual(result, "singleTenantHsmInstanceValue"); - assert((client.pathTemplates.singleTenantHsmInstancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('singleTenantHsmInstance', async () => { + const fakePath = '/rendered/path/singleTenantHsmInstance'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + single_tenant_hsm_instance: 'singleTenantHsmInstanceValue', + }; + const client = new autokeyModule.v1.AutokeyClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.singleTenantHsmInstancePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.singleTenantHsmInstancePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('singleTenantHsmInstancePath', () => { + const result = client.singleTenantHsmInstancePath( + 'projectValue', + 'locationValue', + 'singleTenantHsmInstanceValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.singleTenantHsmInstancePathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromSingleTenantHsmInstanceName', () => { + const result = + client.matchProjectFromSingleTenantHsmInstanceName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.singleTenantHsmInstancePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromSingleTenantHsmInstanceName', () => { + const result = + client.matchLocationFromSingleTenantHsmInstanceName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.singleTenantHsmInstancePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceName', () => { + const result = + client.matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceName( + fakePath, + ); + assert.strictEqual(result, 'singleTenantHsmInstanceValue'); + assert( + ( + client.pathTemplates.singleTenantHsmInstancePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('singleTenantHsmInstanceProposal', async () => { - const fakePath = "/rendered/path/singleTenantHsmInstanceProposal"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - single_tenant_hsm_instance: "singleTenantHsmInstanceValue", - proposal: "proposalValue", - }; - const client = new autokeyModule.v1.AutokeyClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('singleTenantHsmInstanceProposalPath', () => { - const result = client.singleTenantHsmInstanceProposalPath("projectValue", "locationValue", "singleTenantHsmInstanceValue", "proposalValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromSingleTenantHsmInstanceProposalName', () => { - const result = client.matchProjectFromSingleTenantHsmInstanceProposalName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromSingleTenantHsmInstanceProposalName', () => { - const result = client.matchLocationFromSingleTenantHsmInstanceProposalName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceProposalName', () => { - const result = client.matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceProposalName(fakePath); - assert.strictEqual(result, "singleTenantHsmInstanceValue"); - assert((client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProposalFromSingleTenantHsmInstanceProposalName', () => { - const result = client.matchProposalFromSingleTenantHsmInstanceProposalName(fakePath); - assert.strictEqual(result, "proposalValue"); - assert((client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('singleTenantHsmInstanceProposal', async () => { + const fakePath = '/rendered/path/singleTenantHsmInstanceProposal'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + single_tenant_hsm_instance: 'singleTenantHsmInstanceValue', + proposal: 'proposalValue', + }; + const client = new autokeyModule.v1.AutokeyClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('singleTenantHsmInstanceProposalPath', () => { + const result = client.singleTenantHsmInstanceProposalPath( + 'projectValue', + 'locationValue', + 'singleTenantHsmInstanceValue', + 'proposalValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromSingleTenantHsmInstanceProposalName', () => { + const result = + client.matchProjectFromSingleTenantHsmInstanceProposalName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromSingleTenantHsmInstanceProposalName', () => { + const result = + client.matchLocationFromSingleTenantHsmInstanceProposalName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceProposalName', () => { + const result = + client.matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceProposalName( + fakePath, + ); + assert.strictEqual(result, 'singleTenantHsmInstanceValue'); + assert( + ( + client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchProposalFromSingleTenantHsmInstanceProposalName', () => { + const result = + client.matchProposalFromSingleTenantHsmInstanceProposalName(fakePath); + assert.strictEqual(result, 'proposalValue'); + assert( + ( + client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-kms/test/gapic_ekm_service_v1.ts b/packages/google-cloud-kms/test/gapic_ekm_service_v1.ts index f0b3a1ef227c..135c58f0c420 100644 --- a/packages/google-cloud-kms/test/gapic_ekm_service_v1.ts +++ b/packages/google-cloud-kms/test/gapic_ekm_service_v1.ts @@ -19,2241 +19,2892 @@ 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 ekmserviceModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf, IamProtos, LocationProtos} from 'google-gax'; +import { protobuf, IamProtos, LocationProtos } from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); +const root = protobuf.Root.fromJSON( + require('../protos/protos.json'), +).resolveAll(); // eslint-disable-next-line @typescript-eslint/no-unused-vars function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; } function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, { defaults: true }); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject, + ) as T; } function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); } -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error, +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); } -function 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.EkmServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new ekmserviceModule.v1.EkmServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'cloudkms.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new ekmserviceModule.v1.EkmServiceClient(); - 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 = ekmserviceModule.v1.EkmServiceClient.servicePath; - assert.strictEqual(servicePath, 'cloudkms.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = ekmserviceModule.v1.EkmServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'cloudkms.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new ekmserviceModule.v1.EkmServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudkms.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new ekmserviceModule.v1.EkmServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudkms.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 ekmserviceModule.v1.EkmServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudkms.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 ekmserviceModule.v1.EkmServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudkms.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 ekmserviceModule.v1.EkmServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); - - it('has port', () => { - const port = ekmserviceModule.v1.EkmServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new ekmserviceModule.v1.EkmServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new ekmserviceModule.v1.EkmServiceClient({ - fallback: true, - }); - assert(client); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new ekmserviceModule.v1.EkmServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'cloudkms.googleapis.com'); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.ekmServiceStub, undefined); - await client.initialize(); - assert(client.ekmServiceStub); - }); + it('has universeDomain', () => { + const client = new ekmserviceModule.v1.EkmServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('has close method for the initialized client', done => { - const client = new ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.ekmServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = ekmserviceModule.v1.EkmServiceClient.servicePath; + assert.strictEqual(servicePath, 'cloudkms.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = ekmserviceModule.v1.EkmServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'cloudkms.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new ekmserviceModule.v1.EkmServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudkms.example.com'); + }); - it('has close method for the non-initialized client', done => { - const client = new ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.ekmServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new ekmserviceModule.v1.EkmServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudkms.example.com'); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new ekmserviceModule.v1.EkmServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudkms.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 ekmserviceModule.v1.EkmServiceClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudkms.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 ekmserviceModule.v1.EkmServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); + it('has port', () => { + const port = ekmserviceModule.v1.EkmServiceClient.port; + assert(port); + assert(typeof port === 'number'); }); - describe('getEkmConnection', () => { - it('invokes getEkmConnection without error', async () => { - const client = new ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.GetEkmConnectionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.GetEkmConnectionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.EkmConnection() - ); - client.innerApiCalls.getEkmConnection = stubSimpleCall(expectedResponse); - const [response] = await client.getEkmConnection(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getEkmConnection as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getEkmConnection 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 ekmserviceModule.v1.EkmServiceClient(); + assert(client); + }); - it('invokes getEkmConnection without error using callback', async () => { - const client = new ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.GetEkmConnectionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.GetEkmConnectionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.EkmConnection() - ); - client.innerApiCalls.getEkmConnection = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getEkmConnection( - request, - (err?: Error|null, result?: protos.google.cloud.kms.v1.IEkmConnection|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getEkmConnection as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getEkmConnection 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 ekmserviceModule.v1.EkmServiceClient({ + fallback: true, + }); + assert(client); + }); - it('invokes getEkmConnection with error', async () => { - const client = new ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.GetEkmConnectionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.GetEkmConnectionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getEkmConnection = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getEkmConnection(request), expectedError); - const actualRequest = (client.innerApiCalls.getEkmConnection as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getEkmConnection 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 ekmserviceModule.v1.EkmServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.ekmServiceStub, undefined); + await client.initialize(); + assert(client.ekmServiceStub); + }); - it('invokes getEkmConnection with closed client', async () => { - const client = new ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.GetEkmConnectionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.GetEkmConnectionRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getEkmConnection(request), expectedError); + it('has close method for the initialized client', (done) => { + const client = new ekmserviceModule.v1.EkmServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.ekmServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('createEkmConnection', () => { - it('invokes createEkmConnection without error', async () => { - const client = new ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.CreateEkmConnectionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.CreateEkmConnectionRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.EkmConnection() - ); - client.innerApiCalls.createEkmConnection = stubSimpleCall(expectedResponse); - const [response] = await client.createEkmConnection(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createEkmConnection as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createEkmConnection 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 ekmserviceModule.v1.EkmServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.ekmServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes createEkmConnection without error using callback', async () => { - const client = new ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.CreateEkmConnectionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.CreateEkmConnectionRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.EkmConnection() - ); - client.innerApiCalls.createEkmConnection = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createEkmConnection( - request, - (err?: Error|null, result?: protos.google.cloud.kms.v1.IEkmConnection|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createEkmConnection as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createEkmConnection 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 ekmserviceModule.v1.EkmServiceClient({ + 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 createEkmConnection with error', async () => { - const client = new ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.CreateEkmConnectionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.CreateEkmConnectionRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createEkmConnection = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createEkmConnection(request), expectedError); - const actualRequest = (client.innerApiCalls.createEkmConnection as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createEkmConnection 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 ekmserviceModule.v1.EkmServiceClient({ + 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('getEkmConnection', () => { + it('invokes getEkmConnection without error', async () => { + const client = new ekmserviceModule.v1.EkmServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.GetEkmConnectionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.GetEkmConnectionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.EkmConnection(), + ); + client.innerApiCalls.getEkmConnection = stubSimpleCall(expectedResponse); + const [response] = await client.getEkmConnection(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getEkmConnection as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getEkmConnection as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createEkmConnection with closed client', async () => { - const client = new ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.CreateEkmConnectionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.CreateEkmConnectionRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.createEkmConnection(request), expectedError); - }); + it('invokes getEkmConnection without error using callback', async () => { + const client = new ekmserviceModule.v1.EkmServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.GetEkmConnectionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.GetEkmConnectionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.EkmConnection(), + ); + client.innerApiCalls.getEkmConnection = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getEkmConnection( + request, + ( + err?: Error | null, + result?: protos.google.cloud.kms.v1.IEkmConnection | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getEkmConnection as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getEkmConnection as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateEkmConnection', () => { - it('invokes updateEkmConnection without error', async () => { - const client = new ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.UpdateEkmConnectionRequest() - ); - request.ekmConnection ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.UpdateEkmConnectionRequest', ['ekmConnection', 'name']); - request.ekmConnection.name = defaultValue1; - const expectedHeaderRequestParams = `ekm_connection.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.EkmConnection() - ); - client.innerApiCalls.updateEkmConnection = stubSimpleCall(expectedResponse); - const [response] = await client.updateEkmConnection(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateEkmConnection as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateEkmConnection as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getEkmConnection with error', async () => { + const client = new ekmserviceModule.v1.EkmServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.GetEkmConnectionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.GetEkmConnectionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getEkmConnection = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getEkmConnection(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getEkmConnection as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getEkmConnection as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateEkmConnection without error using callback', async () => { - const client = new ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.UpdateEkmConnectionRequest() - ); - request.ekmConnection ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.UpdateEkmConnectionRequest', ['ekmConnection', 'name']); - request.ekmConnection.name = defaultValue1; - const expectedHeaderRequestParams = `ekm_connection.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.EkmConnection() - ); - client.innerApiCalls.updateEkmConnection = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateEkmConnection( - request, - (err?: Error|null, result?: protos.google.cloud.kms.v1.IEkmConnection|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateEkmConnection as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateEkmConnection as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getEkmConnection with closed client', async () => { + const client = new ekmserviceModule.v1.EkmServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.GetEkmConnectionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.GetEkmConnectionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getEkmConnection(request), expectedError); + }); + }); + + describe('createEkmConnection', () => { + it('invokes createEkmConnection without error', async () => { + const client = new ekmserviceModule.v1.EkmServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.CreateEkmConnectionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.CreateEkmConnectionRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.EkmConnection(), + ); + client.innerApiCalls.createEkmConnection = + stubSimpleCall(expectedResponse); + const [response] = await client.createEkmConnection(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createEkmConnection as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createEkmConnection as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateEkmConnection with error', async () => { - const client = new ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.UpdateEkmConnectionRequest() - ); - request.ekmConnection ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.UpdateEkmConnectionRequest', ['ekmConnection', 'name']); - request.ekmConnection.name = defaultValue1; - const expectedHeaderRequestParams = `ekm_connection.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateEkmConnection = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateEkmConnection(request), expectedError); - const actualRequest = (client.innerApiCalls.updateEkmConnection as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateEkmConnection as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createEkmConnection without error using callback', async () => { + const client = new ekmserviceModule.v1.EkmServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.CreateEkmConnectionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.CreateEkmConnectionRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.EkmConnection(), + ); + client.innerApiCalls.createEkmConnection = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createEkmConnection( + request, + ( + err?: Error | null, + result?: protos.google.cloud.kms.v1.IEkmConnection | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createEkmConnection as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createEkmConnection as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateEkmConnection with closed client', async () => { - const client = new ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.UpdateEkmConnectionRequest() - ); - request.ekmConnection ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.UpdateEkmConnectionRequest', ['ekmConnection', 'name']); - request.ekmConnection.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.updateEkmConnection(request), expectedError); - }); + it('invokes createEkmConnection with error', async () => { + const client = new ekmserviceModule.v1.EkmServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.CreateEkmConnectionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.CreateEkmConnectionRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createEkmConnection = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.createEkmConnection(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createEkmConnection as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createEkmConnection as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getEkmConfig', () => { - it('invokes getEkmConfig without error', async () => { - const client = new ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.GetEkmConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.GetEkmConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.EkmConfig() - ); - client.innerApiCalls.getEkmConfig = stubSimpleCall(expectedResponse); - const [response] = await client.getEkmConfig(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getEkmConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getEkmConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createEkmConnection with closed client', async () => { + const client = new ekmserviceModule.v1.EkmServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.CreateEkmConnectionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.CreateEkmConnectionRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.createEkmConnection(request), expectedError); + }); + }); + + describe('updateEkmConnection', () => { + it('invokes updateEkmConnection without error', async () => { + const client = new ekmserviceModule.v1.EkmServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.UpdateEkmConnectionRequest(), + ); + request.ekmConnection ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.UpdateEkmConnectionRequest', + ['ekmConnection', 'name'], + ); + request.ekmConnection.name = defaultValue1; + const expectedHeaderRequestParams = `ekm_connection.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.EkmConnection(), + ); + client.innerApiCalls.updateEkmConnection = + stubSimpleCall(expectedResponse); + const [response] = await client.updateEkmConnection(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateEkmConnection as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateEkmConnection as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getEkmConfig without error using callback', async () => { - const client = new ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.GetEkmConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.GetEkmConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.EkmConfig() - ); - client.innerApiCalls.getEkmConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getEkmConfig( - request, - (err?: Error|null, result?: protos.google.cloud.kms.v1.IEkmConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getEkmConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getEkmConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateEkmConnection without error using callback', async () => { + const client = new ekmserviceModule.v1.EkmServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.UpdateEkmConnectionRequest(), + ); + request.ekmConnection ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.UpdateEkmConnectionRequest', + ['ekmConnection', 'name'], + ); + request.ekmConnection.name = defaultValue1; + const expectedHeaderRequestParams = `ekm_connection.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.EkmConnection(), + ); + client.innerApiCalls.updateEkmConnection = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateEkmConnection( + request, + ( + err?: Error | null, + result?: protos.google.cloud.kms.v1.IEkmConnection | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateEkmConnection as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateEkmConnection as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getEkmConfig with error', async () => { - const client = new ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.GetEkmConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.GetEkmConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getEkmConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getEkmConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.getEkmConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getEkmConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateEkmConnection with error', async () => { + const client = new ekmserviceModule.v1.EkmServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.UpdateEkmConnectionRequest(), + ); + request.ekmConnection ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.UpdateEkmConnectionRequest', + ['ekmConnection', 'name'], + ); + request.ekmConnection.name = defaultValue1; + const expectedHeaderRequestParams = `ekm_connection.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateEkmConnection = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateEkmConnection(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateEkmConnection as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateEkmConnection as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getEkmConfig with closed client', async () => { - const client = new ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.GetEkmConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.GetEkmConfigRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getEkmConfig(request), expectedError); - }); + it('invokes updateEkmConnection with closed client', async () => { + const client = new ekmserviceModule.v1.EkmServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.UpdateEkmConnectionRequest(), + ); + request.ekmConnection ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.UpdateEkmConnectionRequest', + ['ekmConnection', 'name'], + ); + request.ekmConnection.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.updateEkmConnection(request), expectedError); + }); + }); + + describe('getEkmConfig', () => { + it('invokes getEkmConfig without error', async () => { + const client = new ekmserviceModule.v1.EkmServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.GetEkmConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.GetEkmConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.EkmConfig(), + ); + client.innerApiCalls.getEkmConfig = stubSimpleCall(expectedResponse); + const [response] = await client.getEkmConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getEkmConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getEkmConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateEkmConfig', () => { - it('invokes updateEkmConfig without error', async () => { - const client = new ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.UpdateEkmConfigRequest() - ); - request.ekmConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.UpdateEkmConfigRequest', ['ekmConfig', 'name']); - request.ekmConfig.name = defaultValue1; - const expectedHeaderRequestParams = `ekm_config.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.EkmConfig() - ); - client.innerApiCalls.updateEkmConfig = stubSimpleCall(expectedResponse); - const [response] = await client.updateEkmConfig(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateEkmConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateEkmConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getEkmConfig without error using callback', async () => { + const client = new ekmserviceModule.v1.EkmServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.GetEkmConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.GetEkmConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.EkmConfig(), + ); + client.innerApiCalls.getEkmConfig = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getEkmConfig( + request, + ( + err?: Error | null, + result?: protos.google.cloud.kms.v1.IEkmConfig | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getEkmConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getEkmConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateEkmConfig without error using callback', async () => { - const client = new ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.UpdateEkmConfigRequest() - ); - request.ekmConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.UpdateEkmConfigRequest', ['ekmConfig', 'name']); - request.ekmConfig.name = defaultValue1; - const expectedHeaderRequestParams = `ekm_config.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.EkmConfig() - ); - client.innerApiCalls.updateEkmConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateEkmConfig( - request, - (err?: Error|null, result?: protos.google.cloud.kms.v1.IEkmConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateEkmConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateEkmConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getEkmConfig with error', async () => { + const client = new ekmserviceModule.v1.EkmServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.GetEkmConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.GetEkmConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getEkmConfig = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getEkmConfig(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getEkmConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getEkmConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateEkmConfig with error', async () => { - const client = new ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.UpdateEkmConfigRequest() - ); - request.ekmConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.UpdateEkmConfigRequest', ['ekmConfig', 'name']); - request.ekmConfig.name = defaultValue1; - const expectedHeaderRequestParams = `ekm_config.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateEkmConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateEkmConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.updateEkmConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateEkmConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getEkmConfig with closed client', async () => { + const client = new ekmserviceModule.v1.EkmServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.GetEkmConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.GetEkmConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getEkmConfig(request), expectedError); + }); + }); + + describe('updateEkmConfig', () => { + it('invokes updateEkmConfig without error', async () => { + const client = new ekmserviceModule.v1.EkmServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.UpdateEkmConfigRequest(), + ); + request.ekmConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.UpdateEkmConfigRequest', + ['ekmConfig', 'name'], + ); + request.ekmConfig.name = defaultValue1; + const expectedHeaderRequestParams = `ekm_config.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.EkmConfig(), + ); + client.innerApiCalls.updateEkmConfig = stubSimpleCall(expectedResponse); + const [response] = await client.updateEkmConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateEkmConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateEkmConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateEkmConfig with closed client', async () => { - const client = new ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.UpdateEkmConfigRequest() - ); - request.ekmConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.UpdateEkmConfigRequest', ['ekmConfig', 'name']); - request.ekmConfig.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.updateEkmConfig(request), expectedError); - }); + it('invokes updateEkmConfig without error using callback', async () => { + const client = new ekmserviceModule.v1.EkmServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.UpdateEkmConfigRequest(), + ); + request.ekmConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.UpdateEkmConfigRequest', + ['ekmConfig', 'name'], + ); + request.ekmConfig.name = defaultValue1; + const expectedHeaderRequestParams = `ekm_config.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.EkmConfig(), + ); + client.innerApiCalls.updateEkmConfig = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateEkmConfig( + request, + ( + err?: Error | null, + result?: protos.google.cloud.kms.v1.IEkmConfig | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateEkmConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateEkmConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('verifyConnectivity', () => { - it('invokes verifyConnectivity without error', async () => { - const client = new ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.VerifyConnectivityRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.VerifyConnectivityRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.VerifyConnectivityResponse() - ); - client.innerApiCalls.verifyConnectivity = stubSimpleCall(expectedResponse); - const [response] = await client.verifyConnectivity(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.verifyConnectivity as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.verifyConnectivity as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateEkmConfig with error', async () => { + const client = new ekmserviceModule.v1.EkmServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.UpdateEkmConfigRequest(), + ); + request.ekmConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.UpdateEkmConfigRequest', + ['ekmConfig', 'name'], + ); + request.ekmConfig.name = defaultValue1; + const expectedHeaderRequestParams = `ekm_config.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateEkmConfig = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateEkmConfig(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateEkmConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateEkmConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes verifyConnectivity without error using callback', async () => { - const client = new ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.VerifyConnectivityRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.VerifyConnectivityRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.VerifyConnectivityResponse() - ); - client.innerApiCalls.verifyConnectivity = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.verifyConnectivity( - request, - (err?: Error|null, result?: protos.google.cloud.kms.v1.IVerifyConnectivityResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.verifyConnectivity as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.verifyConnectivity as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateEkmConfig with closed client', async () => { + const client = new ekmserviceModule.v1.EkmServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.UpdateEkmConfigRequest(), + ); + request.ekmConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.UpdateEkmConfigRequest', + ['ekmConfig', 'name'], + ); + request.ekmConfig.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.updateEkmConfig(request), expectedError); + }); + }); + + describe('verifyConnectivity', () => { + it('invokes verifyConnectivity without error', async () => { + const client = new ekmserviceModule.v1.EkmServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.VerifyConnectivityRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.VerifyConnectivityRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.VerifyConnectivityResponse(), + ); + client.innerApiCalls.verifyConnectivity = + stubSimpleCall(expectedResponse); + const [response] = await client.verifyConnectivity(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.verifyConnectivity as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.verifyConnectivity as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes verifyConnectivity with error', async () => { - const client = new ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.VerifyConnectivityRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.VerifyConnectivityRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.verifyConnectivity = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.verifyConnectivity(request), expectedError); - const actualRequest = (client.innerApiCalls.verifyConnectivity as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.verifyConnectivity as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes verifyConnectivity without error using callback', async () => { + const client = new ekmserviceModule.v1.EkmServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.VerifyConnectivityRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.VerifyConnectivityRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.VerifyConnectivityResponse(), + ); + client.innerApiCalls.verifyConnectivity = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.verifyConnectivity( + request, + ( + err?: Error | null, + result?: protos.google.cloud.kms.v1.IVerifyConnectivityResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.verifyConnectivity as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.verifyConnectivity as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes verifyConnectivity with closed client', async () => { - const client = new ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.VerifyConnectivityRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.VerifyConnectivityRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.verifyConnectivity(request), expectedError); - }); + it('invokes verifyConnectivity with error', async () => { + const client = new ekmserviceModule.v1.EkmServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.VerifyConnectivityRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.VerifyConnectivityRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.verifyConnectivity = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.verifyConnectivity(request), expectedError); + const actualRequest = ( + client.innerApiCalls.verifyConnectivity as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.verifyConnectivity as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listEkmConnections', () => { - it('invokes listEkmConnections without error', async () => { - const client = new ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListEkmConnectionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListEkmConnectionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.kms.v1.EkmConnection()), - generateSampleMessage(new protos.google.cloud.kms.v1.EkmConnection()), - generateSampleMessage(new protos.google.cloud.kms.v1.EkmConnection()), - ]; - client.innerApiCalls.listEkmConnections = stubSimpleCall(expectedResponse); - const [response] = await client.listEkmConnections(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listEkmConnections as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listEkmConnections as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes verifyConnectivity with closed client', async () => { + const client = new ekmserviceModule.v1.EkmServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.VerifyConnectivityRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.VerifyConnectivityRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.verifyConnectivity(request), expectedError); + }); + }); + + describe('listEkmConnections', () => { + it('invokes listEkmConnections without error', async () => { + const client = new ekmserviceModule.v1.EkmServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListEkmConnectionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListEkmConnectionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.kms.v1.EkmConnection()), + generateSampleMessage(new protos.google.cloud.kms.v1.EkmConnection()), + generateSampleMessage(new protos.google.cloud.kms.v1.EkmConnection()), + ]; + client.innerApiCalls.listEkmConnections = + stubSimpleCall(expectedResponse); + const [response] = await client.listEkmConnections(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listEkmConnections as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listEkmConnections as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listEkmConnections without error using callback', async () => { - const client = new ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListEkmConnectionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListEkmConnectionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.kms.v1.EkmConnection()), - generateSampleMessage(new protos.google.cloud.kms.v1.EkmConnection()), - generateSampleMessage(new protos.google.cloud.kms.v1.EkmConnection()), - ]; - client.innerApiCalls.listEkmConnections = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listEkmConnections( - request, - (err?: Error|null, result?: protos.google.cloud.kms.v1.IEkmConnection[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listEkmConnections as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listEkmConnections as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listEkmConnections without error using callback', async () => { + const client = new ekmserviceModule.v1.EkmServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListEkmConnectionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListEkmConnectionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.kms.v1.EkmConnection()), + generateSampleMessage(new protos.google.cloud.kms.v1.EkmConnection()), + generateSampleMessage(new protos.google.cloud.kms.v1.EkmConnection()), + ]; + client.innerApiCalls.listEkmConnections = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listEkmConnections( + request, + ( + err?: Error | null, + result?: protos.google.cloud.kms.v1.IEkmConnection[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listEkmConnections as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listEkmConnections as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listEkmConnections with error', async () => { - const client = new ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListEkmConnectionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListEkmConnectionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listEkmConnections = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listEkmConnections(request), expectedError); - const actualRequest = (client.innerApiCalls.listEkmConnections as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listEkmConnections as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listEkmConnections with error', async () => { + const client = new ekmserviceModule.v1.EkmServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListEkmConnectionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListEkmConnectionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listEkmConnections = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listEkmConnections(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listEkmConnections as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listEkmConnections as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listEkmConnectionsStream without error', async () => { - const client = new ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListEkmConnectionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListEkmConnectionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.kms.v1.EkmConnection()), - generateSampleMessage(new protos.google.cloud.kms.v1.EkmConnection()), - generateSampleMessage(new protos.google.cloud.kms.v1.EkmConnection()), - ]; - client.descriptors.page.listEkmConnections.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listEkmConnectionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.kms.v1.EkmConnection[] = []; - stream.on('data', (response: protos.google.cloud.kms.v1.EkmConnection) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listEkmConnections.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listEkmConnections, request)); - assert( - (client.descriptors.page.listEkmConnections.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listEkmConnectionsStream without error', async () => { + const client = new ekmserviceModule.v1.EkmServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListEkmConnectionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListEkmConnectionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.kms.v1.EkmConnection()), + generateSampleMessage(new protos.google.cloud.kms.v1.EkmConnection()), + generateSampleMessage(new protos.google.cloud.kms.v1.EkmConnection()), + ]; + client.descriptors.page.listEkmConnections.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listEkmConnectionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.kms.v1.EkmConnection[] = []; + stream.on( + 'data', + (response: protos.google.cloud.kms.v1.EkmConnection) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listEkmConnections.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listEkmConnections, request), + ); + assert( + (client.descriptors.page.listEkmConnections.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listEkmConnectionsStream with error', async () => { - const client = new ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListEkmConnectionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListEkmConnectionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listEkmConnections.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listEkmConnectionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.kms.v1.EkmConnection[] = []; - stream.on('data', (response: protos.google.cloud.kms.v1.EkmConnection) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listEkmConnections.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listEkmConnections, request)); - assert( - (client.descriptors.page.listEkmConnections.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listEkmConnectionsStream with error', async () => { + const client = new ekmserviceModule.v1.EkmServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListEkmConnectionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListEkmConnectionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listEkmConnections.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listEkmConnectionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.kms.v1.EkmConnection[] = []; + stream.on( + 'data', + (response: protos.google.cloud.kms.v1.EkmConnection) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listEkmConnections.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listEkmConnections, request), + ); + assert( + (client.descriptors.page.listEkmConnections.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listEkmConnections without error', async () => { - const client = new ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListEkmConnectionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListEkmConnectionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.kms.v1.EkmConnection()), - generateSampleMessage(new protos.google.cloud.kms.v1.EkmConnection()), - generateSampleMessage(new protos.google.cloud.kms.v1.EkmConnection()), - ]; - client.descriptors.page.listEkmConnections.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.kms.v1.IEkmConnection[] = []; - const iterable = client.listEkmConnectionsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listEkmConnections.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listEkmConnections.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listEkmConnections without error', async () => { + const client = new ekmserviceModule.v1.EkmServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListEkmConnectionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListEkmConnectionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.kms.v1.EkmConnection()), + generateSampleMessage(new protos.google.cloud.kms.v1.EkmConnection()), + generateSampleMessage(new protos.google.cloud.kms.v1.EkmConnection()), + ]; + client.descriptors.page.listEkmConnections.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.kms.v1.IEkmConnection[] = []; + const iterable = client.listEkmConnectionsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listEkmConnections.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listEkmConnections.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listEkmConnections with error', async () => { - const client = new ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListEkmConnectionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListEkmConnectionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listEkmConnections.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listEkmConnectionsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.kms.v1.IEkmConnection[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listEkmConnections.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listEkmConnections.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listEkmConnections with error', async () => { + const client = new ekmserviceModule.v1.EkmServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListEkmConnectionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListEkmConnectionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listEkmConnections.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listEkmConnectionsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.kms.v1.IEkmConnection[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listEkmConnections.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listEkmConnections.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); }); - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.getIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getIamPolicy without error using callback', async () => { - const client = new ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes getIamPolicy with error', async () => { - const client = new ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new ekmserviceModule.v1.EkmServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.getIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.setIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes setIamPolicy without error using callback', async () => { - const client = new ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes setIamPolicy with error', async () => { - const client = new ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getIamPolicy without error using callback', async () => { + const client = new ekmserviceModule.v1.EkmServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .getIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.getIamPolicy as SinonStub).getCall(0)); }); - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); - const response = await client.testIamPermissions(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes testIamPermissions without error using callback', async () => { - const client = new ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.TestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0)); - }); - it('invokes testIamPermissions with error', async () => { - const client = new ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request, expectedOptions), expectedError); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getIamPolicy with error', async () => { + const client = new ekmserviceModule.v1.EkmServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.getIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - 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 ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - 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 ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new ekmserviceModule.v1.EkmServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.setIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + it('invokes setIamPolicy without error using callback', async () => { + const client = new ekmserviceModule.v1.EkmServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .setIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.setIamPolicy as SinonStub).getCall(0)); }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new ekmserviceModule.v1.EkmServiceClient({ - 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 setIamPolicy with error', async () => { + const client = new ekmserviceModule.v1.EkmServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.setIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new ekmserviceModule.v1.EkmServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); + const response = await client.testIamPermissions( + request, + expectedOptions, + ); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + it('invokes testIamPermissions without error using callback', async () => { + const client = new ekmserviceModule.v1.EkmServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .testIamPermissions( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.TestIamPermissionsResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.testIamPermissions as SinonStub).getCall(0)); + }); + it('invokes testIamPermissions with error', async () => { + const client = new ekmserviceModule.v1.EkmServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.testIamPermissions = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.testIamPermissions(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new ekmserviceModule.v1.EkmServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + 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 ekmserviceModule.v1.EkmServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + 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 ekmserviceModule.v1.EkmServiceClient({ - 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 ekmserviceModule.v1.EkmServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + 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 ekmserviceModule.v1.EkmServiceClient({ + 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 ekmserviceModule.v1.EkmServiceClient({ + 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('cryptoKey', async () => { + const fakePath = '/rendered/path/cryptoKey'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + key_ring: 'keyRingValue', + crypto_key: 'cryptoKeyValue', + }; + const client = new ekmserviceModule.v1.EkmServiceClient({ + 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('Path templates', () => { - - describe('cryptoKey', async () => { - const fakePath = "/rendered/path/cryptoKey"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - key_ring: "keyRingValue", - crypto_key: "cryptoKeyValue", - }; - const client = new ekmserviceModule.v1.EkmServiceClient({ - 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 ekmserviceModule.v1.EkmServiceClient({ - 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 ekmserviceModule.v1.EkmServiceClient({ + 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('ekmConfig', async () => { - const fakePath = "/rendered/path/ekmConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.ekmConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.ekmConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('ekmConfigPath', () => { - const result = client.ekmConfigPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.ekmConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromEkmConfigName', () => { - const result = client.matchProjectFromEkmConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.ekmConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromEkmConfigName', () => { - const result = client.matchLocationFromEkmConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.ekmConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('ekmConfig', async () => { + const fakePath = '/rendered/path/ekmConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = new ekmserviceModule.v1.EkmServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.ekmConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.ekmConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('ekmConfigPath', () => { + const result = client.ekmConfigPath('projectValue', 'locationValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.ekmConfigPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromEkmConfigName', () => { + const result = client.matchProjectFromEkmConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.ekmConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromEkmConfigName', () => { + const result = client.matchLocationFromEkmConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.ekmConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('ekmConnection', async () => { - const fakePath = "/rendered/path/ekmConnection"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - ekm_connection: "ekmConnectionValue", - }; - const client = new ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.ekmConnectionPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.ekmConnectionPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('ekmConnectionPath', () => { - const result = client.ekmConnectionPath("projectValue", "locationValue", "ekmConnectionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.ekmConnectionPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromEkmConnectionName', () => { - const result = client.matchProjectFromEkmConnectionName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.ekmConnectionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromEkmConnectionName', () => { - const result = client.matchLocationFromEkmConnectionName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.ekmConnectionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchEkmConnectionFromEkmConnectionName', () => { - const result = client.matchEkmConnectionFromEkmConnectionName(fakePath); - assert.strictEqual(result, "ekmConnectionValue"); - assert((client.pathTemplates.ekmConnectionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('ekmConnection', async () => { + const fakePath = '/rendered/path/ekmConnection'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + ekm_connection: 'ekmConnectionValue', + }; + const client = new ekmserviceModule.v1.EkmServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.ekmConnectionPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.ekmConnectionPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('ekmConnectionPath', () => { + const result = client.ekmConnectionPath( + 'projectValue', + 'locationValue', + 'ekmConnectionValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.ekmConnectionPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromEkmConnectionName', () => { + const result = client.matchProjectFromEkmConnectionName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.ekmConnectionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromEkmConnectionName', () => { + const result = client.matchLocationFromEkmConnectionName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.ekmConnectionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchEkmConnectionFromEkmConnectionName', () => { + const result = client.matchEkmConnectionFromEkmConnectionName(fakePath); + assert.strictEqual(result, 'ekmConnectionValue'); + assert( + (client.pathTemplates.ekmConnectionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('folderAutokeyConfig', async () => { - const fakePath = "/rendered/path/folderAutokeyConfig"; - const expectedParameters = { - folder: "folderValue", - }; - const client = new ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.folderAutokeyConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.folderAutokeyConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('folderAutokeyConfigPath', () => { - const result = client.folderAutokeyConfigPath("folderValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.folderAutokeyConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchFolderFromFolderAutokeyConfigName', () => { - const result = client.matchFolderFromFolderAutokeyConfigName(fakePath); - assert.strictEqual(result, "folderValue"); - assert((client.pathTemplates.folderAutokeyConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('folderAutokeyConfig', async () => { + const fakePath = '/rendered/path/folderAutokeyConfig'; + const expectedParameters = { + folder: 'folderValue', + }; + const client = new ekmserviceModule.v1.EkmServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.folderAutokeyConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.folderAutokeyConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('folderAutokeyConfigPath', () => { + const result = client.folderAutokeyConfigPath('folderValue'); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.folderAutokeyConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchFolderFromFolderAutokeyConfigName', () => { + const result = client.matchFolderFromFolderAutokeyConfigName(fakePath); + assert.strictEqual(result, 'folderValue'); + assert( + ( + client.pathTemplates.folderAutokeyConfigPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('importJob', async () => { - const fakePath = "/rendered/path/importJob"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - key_ring: "keyRingValue", - import_job: "importJobValue", - }; - const client = new ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.importJobPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.importJobPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('importJobPath', () => { - const result = client.importJobPath("projectValue", "locationValue", "keyRingValue", "importJobValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.importJobPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromImportJobName', () => { - const result = client.matchProjectFromImportJobName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.importJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromImportJobName', () => { - const result = client.matchLocationFromImportJobName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.importJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchKeyRingFromImportJobName', () => { - const result = client.matchKeyRingFromImportJobName(fakePath); - assert.strictEqual(result, "keyRingValue"); - assert((client.pathTemplates.importJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchImportJobFromImportJobName', () => { - const result = client.matchImportJobFromImportJobName(fakePath); - assert.strictEqual(result, "importJobValue"); - assert((client.pathTemplates.importJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('importJob', async () => { + const fakePath = '/rendered/path/importJob'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + key_ring: 'keyRingValue', + import_job: 'importJobValue', + }; + const client = new ekmserviceModule.v1.EkmServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.importJobPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.importJobPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('importJobPath', () => { + const result = client.importJobPath( + 'projectValue', + 'locationValue', + 'keyRingValue', + 'importJobValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.importJobPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromImportJobName', () => { + const result = client.matchProjectFromImportJobName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.importJobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromImportJobName', () => { + const result = client.matchLocationFromImportJobName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.importJobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchKeyRingFromImportJobName', () => { + const result = client.matchKeyRingFromImportJobName(fakePath); + assert.strictEqual(result, 'keyRingValue'); + assert( + (client.pathTemplates.importJobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchImportJobFromImportJobName', () => { + const result = client.matchImportJobFromImportJobName(fakePath); + assert.strictEqual(result, 'importJobValue'); + assert( + (client.pathTemplates.importJobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('keyHandle', async () => { - const fakePath = "/rendered/path/keyHandle"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - key_handle: "keyHandleValue", - }; - const client = new ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.keyHandlePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.keyHandlePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('keyHandlePath', () => { - const result = client.keyHandlePath("projectValue", "locationValue", "keyHandleValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.keyHandlePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromKeyHandleName', () => { - const result = client.matchProjectFromKeyHandleName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.keyHandlePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromKeyHandleName', () => { - const result = client.matchLocationFromKeyHandleName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.keyHandlePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchKeyHandleFromKeyHandleName', () => { - const result = client.matchKeyHandleFromKeyHandleName(fakePath); - assert.strictEqual(result, "keyHandleValue"); - assert((client.pathTemplates.keyHandlePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('keyHandle', async () => { + const fakePath = '/rendered/path/keyHandle'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + key_handle: 'keyHandleValue', + }; + const client = new ekmserviceModule.v1.EkmServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.keyHandlePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.keyHandlePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('keyHandlePath', () => { + const result = client.keyHandlePath( + 'projectValue', + 'locationValue', + 'keyHandleValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.keyHandlePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromKeyHandleName', () => { + const result = client.matchProjectFromKeyHandleName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.keyHandlePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromKeyHandleName', () => { + const result = client.matchLocationFromKeyHandleName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.keyHandlePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchKeyHandleFromKeyHandleName', () => { + const result = client.matchKeyHandleFromKeyHandleName(fakePath); + assert.strictEqual(result, 'keyHandleValue'); + assert( + (client.pathTemplates.keyHandlePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('keyRing', async () => { - const fakePath = "/rendered/path/keyRing"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - key_ring: "keyRingValue", - }; - const client = new ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.keyRingPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.keyRingPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('keyRingPath', () => { - const result = client.keyRingPath("projectValue", "locationValue", "keyRingValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.keyRingPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromKeyRingName', () => { - const result = client.matchProjectFromKeyRingName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.keyRingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromKeyRingName', () => { - const result = client.matchLocationFromKeyRingName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.keyRingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchKeyRingFromKeyRingName', () => { - const result = client.matchKeyRingFromKeyRingName(fakePath); - assert.strictEqual(result, "keyRingValue"); - assert((client.pathTemplates.keyRingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('keyRing', async () => { + const fakePath = '/rendered/path/keyRing'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + key_ring: 'keyRingValue', + }; + const client = new ekmserviceModule.v1.EkmServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.keyRingPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.keyRingPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('keyRingPath', () => { + const result = client.keyRingPath( + 'projectValue', + 'locationValue', + 'keyRingValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.keyRingPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromKeyRingName', () => { + const result = client.matchProjectFromKeyRingName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.keyRingPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromKeyRingName', () => { + const result = client.matchLocationFromKeyRingName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.keyRingPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchKeyRingFromKeyRingName', () => { + const result = client.matchKeyRingFromKeyRingName(fakePath); + assert.strictEqual(result, 'keyRingValue'); + assert( + (client.pathTemplates.keyRingPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('location', async () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new ekmserviceModule.v1.EkmServiceClient({ - 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 ekmserviceModule.v1.EkmServiceClient({ + 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('projectAutokeyConfig', async () => { - const fakePath = "/rendered/path/projectAutokeyConfig"; - const expectedParameters = { - project: "projectValue", - }; - const client = new ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectAutokeyConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectAutokeyConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectAutokeyConfigPath', () => { - const result = client.projectAutokeyConfigPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectAutokeyConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectAutokeyConfigName', () => { - const result = client.matchProjectFromProjectAutokeyConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectAutokeyConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectAutokeyConfig', async () => { + const fakePath = '/rendered/path/projectAutokeyConfig'; + const expectedParameters = { + project: 'projectValue', + }; + const client = new ekmserviceModule.v1.EkmServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectAutokeyConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectAutokeyConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectAutokeyConfigPath', () => { + const result = client.projectAutokeyConfigPath('projectValue'); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectAutokeyConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectAutokeyConfigName', () => { + const result = + client.matchProjectFromProjectAutokeyConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.projectAutokeyConfigPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('publicKey', async () => { - const fakePath = "/rendered/path/publicKey"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - key_ring: "keyRingValue", - crypto_key: "cryptoKeyValue", - crypto_key_version: "cryptoKeyVersionValue", - }; - const client = new ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.publicKeyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.publicKeyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('publicKeyPath', () => { - const result = client.publicKeyPath("projectValue", "locationValue", "keyRingValue", "cryptoKeyValue", "cryptoKeyVersionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.publicKeyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromPublicKeyName', () => { - const result = client.matchProjectFromPublicKeyName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.publicKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromPublicKeyName', () => { - const result = client.matchLocationFromPublicKeyName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.publicKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchKeyRingFromPublicKeyName', () => { - const result = client.matchKeyRingFromPublicKeyName(fakePath); - assert.strictEqual(result, "keyRingValue"); - assert((client.pathTemplates.publicKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCryptoKeyFromPublicKeyName', () => { - const result = client.matchCryptoKeyFromPublicKeyName(fakePath); - assert.strictEqual(result, "cryptoKeyValue"); - assert((client.pathTemplates.publicKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCryptoKeyVersionFromPublicKeyName', () => { - const result = client.matchCryptoKeyVersionFromPublicKeyName(fakePath); - assert.strictEqual(result, "cryptoKeyVersionValue"); - assert((client.pathTemplates.publicKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('publicKey', async () => { + const fakePath = '/rendered/path/publicKey'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + key_ring: 'keyRingValue', + crypto_key: 'cryptoKeyValue', + crypto_key_version: 'cryptoKeyVersionValue', + }; + const client = new ekmserviceModule.v1.EkmServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.publicKeyPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.publicKeyPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('publicKeyPath', () => { + const result = client.publicKeyPath( + 'projectValue', + 'locationValue', + 'keyRingValue', + 'cryptoKeyValue', + 'cryptoKeyVersionValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.publicKeyPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromPublicKeyName', () => { + const result = client.matchProjectFromPublicKeyName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.publicKeyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromPublicKeyName', () => { + const result = client.matchLocationFromPublicKeyName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.publicKeyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchKeyRingFromPublicKeyName', () => { + const result = client.matchKeyRingFromPublicKeyName(fakePath); + assert.strictEqual(result, 'keyRingValue'); + assert( + (client.pathTemplates.publicKeyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCryptoKeyFromPublicKeyName', () => { + const result = client.matchCryptoKeyFromPublicKeyName(fakePath); + assert.strictEqual(result, 'cryptoKeyValue'); + assert( + (client.pathTemplates.publicKeyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCryptoKeyVersionFromPublicKeyName', () => { + const result = client.matchCryptoKeyVersionFromPublicKeyName(fakePath); + assert.strictEqual(result, 'cryptoKeyVersionValue'); + assert( + (client.pathTemplates.publicKeyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('retiredResource', async () => { - const fakePath = "/rendered/path/retiredResource"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - retired_resource: "retiredResourceValue", - }; - const client = new ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.retiredResourcePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.retiredResourcePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('retiredResourcePath', () => { - const result = client.retiredResourcePath("projectValue", "locationValue", "retiredResourceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.retiredResourcePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromRetiredResourceName', () => { - const result = client.matchProjectFromRetiredResourceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.retiredResourcePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromRetiredResourceName', () => { - const result = client.matchLocationFromRetiredResourceName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.retiredResourcePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRetiredResourceFromRetiredResourceName', () => { - const result = client.matchRetiredResourceFromRetiredResourceName(fakePath); - assert.strictEqual(result, "retiredResourceValue"); - assert((client.pathTemplates.retiredResourcePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('retiredResource', async () => { + const fakePath = '/rendered/path/retiredResource'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + retired_resource: 'retiredResourceValue', + }; + const client = new ekmserviceModule.v1.EkmServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.retiredResourcePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.retiredResourcePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('retiredResourcePath', () => { + const result = client.retiredResourcePath( + 'projectValue', + 'locationValue', + 'retiredResourceValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.retiredResourcePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromRetiredResourceName', () => { + const result = client.matchProjectFromRetiredResourceName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.retiredResourcePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromRetiredResourceName', () => { + const result = client.matchLocationFromRetiredResourceName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.retiredResourcePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRetiredResourceFromRetiredResourceName', () => { + const result = + client.matchRetiredResourceFromRetiredResourceName(fakePath); + assert.strictEqual(result, 'retiredResourceValue'); + assert( + (client.pathTemplates.retiredResourcePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('singleTenantHsmInstance', async () => { - const fakePath = "/rendered/path/singleTenantHsmInstance"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - single_tenant_hsm_instance: "singleTenantHsmInstanceValue", - }; - const client = new ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.singleTenantHsmInstancePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.singleTenantHsmInstancePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('singleTenantHsmInstancePath', () => { - const result = client.singleTenantHsmInstancePath("projectValue", "locationValue", "singleTenantHsmInstanceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.singleTenantHsmInstancePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromSingleTenantHsmInstanceName', () => { - const result = client.matchProjectFromSingleTenantHsmInstanceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.singleTenantHsmInstancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromSingleTenantHsmInstanceName', () => { - const result = client.matchLocationFromSingleTenantHsmInstanceName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.singleTenantHsmInstancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceName', () => { - const result = client.matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceName(fakePath); - assert.strictEqual(result, "singleTenantHsmInstanceValue"); - assert((client.pathTemplates.singleTenantHsmInstancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('singleTenantHsmInstance', async () => { + const fakePath = '/rendered/path/singleTenantHsmInstance'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + single_tenant_hsm_instance: 'singleTenantHsmInstanceValue', + }; + const client = new ekmserviceModule.v1.EkmServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.singleTenantHsmInstancePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.singleTenantHsmInstancePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('singleTenantHsmInstancePath', () => { + const result = client.singleTenantHsmInstancePath( + 'projectValue', + 'locationValue', + 'singleTenantHsmInstanceValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.singleTenantHsmInstancePathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromSingleTenantHsmInstanceName', () => { + const result = + client.matchProjectFromSingleTenantHsmInstanceName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.singleTenantHsmInstancePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromSingleTenantHsmInstanceName', () => { + const result = + client.matchLocationFromSingleTenantHsmInstanceName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.singleTenantHsmInstancePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceName', () => { + const result = + client.matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceName( + fakePath, + ); + assert.strictEqual(result, 'singleTenantHsmInstanceValue'); + assert( + ( + client.pathTemplates.singleTenantHsmInstancePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('singleTenantHsmInstanceProposal', async () => { - const fakePath = "/rendered/path/singleTenantHsmInstanceProposal"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - single_tenant_hsm_instance: "singleTenantHsmInstanceValue", - proposal: "proposalValue", - }; - const client = new ekmserviceModule.v1.EkmServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('singleTenantHsmInstanceProposalPath', () => { - const result = client.singleTenantHsmInstanceProposalPath("projectValue", "locationValue", "singleTenantHsmInstanceValue", "proposalValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromSingleTenantHsmInstanceProposalName', () => { - const result = client.matchProjectFromSingleTenantHsmInstanceProposalName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromSingleTenantHsmInstanceProposalName', () => { - const result = client.matchLocationFromSingleTenantHsmInstanceProposalName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceProposalName', () => { - const result = client.matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceProposalName(fakePath); - assert.strictEqual(result, "singleTenantHsmInstanceValue"); - assert((client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProposalFromSingleTenantHsmInstanceProposalName', () => { - const result = client.matchProposalFromSingleTenantHsmInstanceProposalName(fakePath); - assert.strictEqual(result, "proposalValue"); - assert((client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('singleTenantHsmInstanceProposal', async () => { + const fakePath = '/rendered/path/singleTenantHsmInstanceProposal'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + single_tenant_hsm_instance: 'singleTenantHsmInstanceValue', + proposal: 'proposalValue', + }; + const client = new ekmserviceModule.v1.EkmServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('singleTenantHsmInstanceProposalPath', () => { + const result = client.singleTenantHsmInstanceProposalPath( + 'projectValue', + 'locationValue', + 'singleTenantHsmInstanceValue', + 'proposalValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromSingleTenantHsmInstanceProposalName', () => { + const result = + client.matchProjectFromSingleTenantHsmInstanceProposalName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromSingleTenantHsmInstanceProposalName', () => { + const result = + client.matchLocationFromSingleTenantHsmInstanceProposalName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceProposalName', () => { + const result = + client.matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceProposalName( + fakePath, + ); + assert.strictEqual(result, 'singleTenantHsmInstanceValue'); + assert( + ( + client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchProposalFromSingleTenantHsmInstanceProposalName', () => { + const result = + client.matchProposalFromSingleTenantHsmInstanceProposalName(fakePath); + assert.strictEqual(result, 'proposalValue'); + assert( + ( + client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-kms/test/gapic_hsm_management_v1.ts b/packages/google-cloud-kms/test/gapic_hsm_management_v1.ts index 038808179951..11d86d595fe3 100644 --- a/packages/google-cloud-kms/test/gapic_hsm_management_v1.ts +++ b/packages/google-cloud-kms/test/gapic_hsm_management_v1.ts @@ -19,2995 +19,4012 @@ 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 hsmmanagementModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf, LROperation, operationsProtos, IamProtos, LocationProtos} from 'google-gax'; +import { + protobuf, + LROperation, + operationsProtos, + IamProtos, + LocationProtos, +} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); +const root = protobuf.Root.fromJSON( + require('../protos/protos.json'), +).resolveAll(); // eslint-disable-next-line @typescript-eslint/no-unused-vars function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; } function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, { defaults: true }); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject, + ) as T; } function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); } -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error, +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); } -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +function stubLongRunningCall( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().rejects(callError) + : sinon.stub().resolves([mockOperation]); } -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +function stubLongRunningCallWithCallback( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().callsArgWith(2, callError) + : sinon.stub().callsArgWith(2, null, mockOperation); } -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error, +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); } - return sinon.stub().returns(mockStream); + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); } -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error, +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({ done: true, value: undefined }); + } + return Promise.resolve({ done: false, value: responses![counter++] }); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); } describe('v1.HsmManagementClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new hsmmanagementModule.v1.HsmManagementClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'cloudkms.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new hsmmanagementModule.v1.HsmManagementClient(); - 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 = hsmmanagementModule.v1.HsmManagementClient.servicePath; - assert.strictEqual(servicePath, 'cloudkms.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = hsmmanagementModule.v1.HsmManagementClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'cloudkms.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudkms.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudkms.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 hsmmanagementModule.v1.HsmManagementClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudkms.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 hsmmanagementModule.v1.HsmManagementClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudkms.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 hsmmanagementModule.v1.HsmManagementClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); - - it('has port', () => { - const port = hsmmanagementModule.v1.HsmManagementClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new hsmmanagementModule.v1.HsmManagementClient(); - assert(client); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new hsmmanagementModule.v1.HsmManagementClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'cloudkms.googleapis.com'); + }); - it('should create a client with gRPC fallback', () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - fallback: true, - }); - assert(client); - }); + it('has universeDomain', () => { + const client = new hsmmanagementModule.v1.HsmManagementClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.hsmManagementStub, undefined); - await client.initialize(); - assert(client.hsmManagementStub); - }); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + hsmmanagementModule.v1.HsmManagementClient.servicePath; + assert.strictEqual(servicePath, 'cloudkms.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + hsmmanagementModule.v1.HsmManagementClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'cloudkms.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudkms.example.com'); + }); - it('has close method for the initialized client', done => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.hsmManagementStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudkms.example.com'); + }); - it('has close method for the non-initialized client', done => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.hsmManagementStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new hsmmanagementModule.v1.HsmManagementClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudkms.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 hsmmanagementModule.v1.HsmManagementClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudkms.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 hsmmanagementModule.v1.HsmManagementClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new hsmmanagementModule.v1.HsmManagementClient({ - 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 port', () => { + const port = hsmmanagementModule.v1.HsmManagementClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new hsmmanagementModule.v1.HsmManagementClient({ - 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 no option', () => { + const client = new hsmmanagementModule.v1.HsmManagementClient(); + assert(client); }); - describe('getSingleTenantHsmInstance', () => { - it('invokes getSingleTenantHsmInstance without error', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.GetSingleTenantHsmInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.GetSingleTenantHsmInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.SingleTenantHsmInstance() - ); - client.innerApiCalls.getSingleTenantHsmInstance = stubSimpleCall(expectedResponse); - const [response] = await client.getSingleTenantHsmInstance(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getSingleTenantHsmInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getSingleTenantHsmInstance 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 hsmmanagementModule.v1.HsmManagementClient({ + fallback: true, + }); + assert(client); + }); - it('invokes getSingleTenantHsmInstance without error using callback', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.GetSingleTenantHsmInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.GetSingleTenantHsmInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.SingleTenantHsmInstance() - ); - client.innerApiCalls.getSingleTenantHsmInstance = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getSingleTenantHsmInstance( - request, - (err?: Error|null, result?: protos.google.cloud.kms.v1.ISingleTenantHsmInstance|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getSingleTenantHsmInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getSingleTenantHsmInstance 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 hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.hsmManagementStub, undefined); + await client.initialize(); + assert(client.hsmManagementStub); + }); - it('invokes getSingleTenantHsmInstance with error', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.GetSingleTenantHsmInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.GetSingleTenantHsmInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getSingleTenantHsmInstance = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getSingleTenantHsmInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.getSingleTenantHsmInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getSingleTenantHsmInstance 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 hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.hsmManagementStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes getSingleTenantHsmInstance with closed client', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.GetSingleTenantHsmInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.GetSingleTenantHsmInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getSingleTenantHsmInstance(request), expectedError); + it('has close method for the non-initialized client', (done) => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.hsmManagementStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('approveSingleTenantHsmInstanceProposal', () => { - it('invokes approveSingleTenantHsmInstanceProposal without error', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ApproveSingleTenantHsmInstanceProposalRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ApproveSingleTenantHsmInstanceProposalRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.ApproveSingleTenantHsmInstanceProposalResponse() - ); - client.innerApiCalls.approveSingleTenantHsmInstanceProposal = stubSimpleCall(expectedResponse); - const [response] = await client.approveSingleTenantHsmInstanceProposal(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.approveSingleTenantHsmInstanceProposal as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.approveSingleTenantHsmInstanceProposal 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 hsmmanagementModule.v1.HsmManagementClient({ + 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 approveSingleTenantHsmInstanceProposal without error using callback', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ApproveSingleTenantHsmInstanceProposalRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ApproveSingleTenantHsmInstanceProposalRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.ApproveSingleTenantHsmInstanceProposalResponse() - ); - client.innerApiCalls.approveSingleTenantHsmInstanceProposal = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.approveSingleTenantHsmInstanceProposal( - request, - (err?: Error|null, result?: protos.google.cloud.kms.v1.IApproveSingleTenantHsmInstanceProposalResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.approveSingleTenantHsmInstanceProposal as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.approveSingleTenantHsmInstanceProposal 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 hsmmanagementModule.v1.HsmManagementClient({ + 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('getSingleTenantHsmInstance', () => { + it('invokes getSingleTenantHsmInstance without error', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.GetSingleTenantHsmInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.GetSingleTenantHsmInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.SingleTenantHsmInstance(), + ); + client.innerApiCalls.getSingleTenantHsmInstance = + stubSimpleCall(expectedResponse); + const [response] = await client.getSingleTenantHsmInstance(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getSingleTenantHsmInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getSingleTenantHsmInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes approveSingleTenantHsmInstanceProposal with error', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ApproveSingleTenantHsmInstanceProposalRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ApproveSingleTenantHsmInstanceProposalRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.approveSingleTenantHsmInstanceProposal = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.approveSingleTenantHsmInstanceProposal(request), expectedError); - const actualRequest = (client.innerApiCalls.approveSingleTenantHsmInstanceProposal as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.approveSingleTenantHsmInstanceProposal as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getSingleTenantHsmInstance without error using callback', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.GetSingleTenantHsmInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.GetSingleTenantHsmInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.SingleTenantHsmInstance(), + ); + client.innerApiCalls.getSingleTenantHsmInstance = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getSingleTenantHsmInstance( + request, + ( + err?: Error | null, + result?: protos.google.cloud.kms.v1.ISingleTenantHsmInstance | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getSingleTenantHsmInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getSingleTenantHsmInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes approveSingleTenantHsmInstanceProposal with closed client', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ApproveSingleTenantHsmInstanceProposalRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ApproveSingleTenantHsmInstanceProposalRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.approveSingleTenantHsmInstanceProposal(request), expectedError); - }); + it('invokes getSingleTenantHsmInstance with error', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.GetSingleTenantHsmInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.GetSingleTenantHsmInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getSingleTenantHsmInstance = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getSingleTenantHsmInstance(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.getSingleTenantHsmInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getSingleTenantHsmInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getSingleTenantHsmInstanceProposal', () => { - it('invokes getSingleTenantHsmInstanceProposal without error', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.GetSingleTenantHsmInstanceProposalRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.GetSingleTenantHsmInstanceProposalRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal() - ); - client.innerApiCalls.getSingleTenantHsmInstanceProposal = stubSimpleCall(expectedResponse); - const [response] = await client.getSingleTenantHsmInstanceProposal(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getSingleTenantHsmInstanceProposal as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getSingleTenantHsmInstanceProposal as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getSingleTenantHsmInstance with closed client', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.GetSingleTenantHsmInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.GetSingleTenantHsmInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.getSingleTenantHsmInstance(request), + expectedError, + ); + }); + }); + + describe('approveSingleTenantHsmInstanceProposal', () => { + it('invokes approveSingleTenantHsmInstanceProposal without error', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ApproveSingleTenantHsmInstanceProposalRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ApproveSingleTenantHsmInstanceProposalRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.ApproveSingleTenantHsmInstanceProposalResponse(), + ); + client.innerApiCalls.approveSingleTenantHsmInstanceProposal = + stubSimpleCall(expectedResponse); + const [response] = + await client.approveSingleTenantHsmInstanceProposal(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.approveSingleTenantHsmInstanceProposal as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.approveSingleTenantHsmInstanceProposal as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getSingleTenantHsmInstanceProposal without error using callback', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.GetSingleTenantHsmInstanceProposalRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.GetSingleTenantHsmInstanceProposalRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal() - ); - client.innerApiCalls.getSingleTenantHsmInstanceProposal = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getSingleTenantHsmInstanceProposal( - request, - (err?: Error|null, result?: protos.google.cloud.kms.v1.ISingleTenantHsmInstanceProposal|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getSingleTenantHsmInstanceProposal as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getSingleTenantHsmInstanceProposal as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes approveSingleTenantHsmInstanceProposal without error using callback', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ApproveSingleTenantHsmInstanceProposalRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ApproveSingleTenantHsmInstanceProposalRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.ApproveSingleTenantHsmInstanceProposalResponse(), + ); + client.innerApiCalls.approveSingleTenantHsmInstanceProposal = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.approveSingleTenantHsmInstanceProposal( + request, + ( + err?: Error | null, + result?: protos.google.cloud.kms.v1.IApproveSingleTenantHsmInstanceProposalResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.approveSingleTenantHsmInstanceProposal as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.approveSingleTenantHsmInstanceProposal as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getSingleTenantHsmInstanceProposal with error', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.GetSingleTenantHsmInstanceProposalRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.GetSingleTenantHsmInstanceProposalRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getSingleTenantHsmInstanceProposal = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getSingleTenantHsmInstanceProposal(request), expectedError); - const actualRequest = (client.innerApiCalls.getSingleTenantHsmInstanceProposal as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getSingleTenantHsmInstanceProposal as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes approveSingleTenantHsmInstanceProposal with error', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ApproveSingleTenantHsmInstanceProposalRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ApproveSingleTenantHsmInstanceProposalRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.approveSingleTenantHsmInstanceProposal = + stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.approveSingleTenantHsmInstanceProposal(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.approveSingleTenantHsmInstanceProposal as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.approveSingleTenantHsmInstanceProposal as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getSingleTenantHsmInstanceProposal with closed client', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.GetSingleTenantHsmInstanceProposalRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.GetSingleTenantHsmInstanceProposalRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getSingleTenantHsmInstanceProposal(request), expectedError); - }); + it('invokes approveSingleTenantHsmInstanceProposal with closed client', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ApproveSingleTenantHsmInstanceProposalRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ApproveSingleTenantHsmInstanceProposalRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.approveSingleTenantHsmInstanceProposal(request), + expectedError, + ); + }); + }); + + describe('getSingleTenantHsmInstanceProposal', () => { + it('invokes getSingleTenantHsmInstanceProposal without error', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.GetSingleTenantHsmInstanceProposalRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.GetSingleTenantHsmInstanceProposalRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal(), + ); + client.innerApiCalls.getSingleTenantHsmInstanceProposal = + stubSimpleCall(expectedResponse); + const [response] = + await client.getSingleTenantHsmInstanceProposal(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getSingleTenantHsmInstanceProposal as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getSingleTenantHsmInstanceProposal as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteSingleTenantHsmInstanceProposal', () => { - it('invokes deleteSingleTenantHsmInstanceProposal without error', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.DeleteSingleTenantHsmInstanceProposalRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.DeleteSingleTenantHsmInstanceProposalRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteSingleTenantHsmInstanceProposal = stubSimpleCall(expectedResponse); - const [response] = await client.deleteSingleTenantHsmInstanceProposal(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteSingleTenantHsmInstanceProposal as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteSingleTenantHsmInstanceProposal as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getSingleTenantHsmInstanceProposal without error using callback', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.GetSingleTenantHsmInstanceProposalRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.GetSingleTenantHsmInstanceProposalRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal(), + ); + client.innerApiCalls.getSingleTenantHsmInstanceProposal = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getSingleTenantHsmInstanceProposal( + request, + ( + err?: Error | null, + result?: protos.google.cloud.kms.v1.ISingleTenantHsmInstanceProposal | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getSingleTenantHsmInstanceProposal as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getSingleTenantHsmInstanceProposal as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteSingleTenantHsmInstanceProposal without error using callback', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.DeleteSingleTenantHsmInstanceProposalRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.DeleteSingleTenantHsmInstanceProposalRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteSingleTenantHsmInstanceProposal = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteSingleTenantHsmInstanceProposal( - 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.deleteSingleTenantHsmInstanceProposal as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteSingleTenantHsmInstanceProposal as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getSingleTenantHsmInstanceProposal with error', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.GetSingleTenantHsmInstanceProposalRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.GetSingleTenantHsmInstanceProposalRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getSingleTenantHsmInstanceProposal = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getSingleTenantHsmInstanceProposal(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.getSingleTenantHsmInstanceProposal as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getSingleTenantHsmInstanceProposal as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteSingleTenantHsmInstanceProposal with error', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.DeleteSingleTenantHsmInstanceProposalRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.DeleteSingleTenantHsmInstanceProposalRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteSingleTenantHsmInstanceProposal = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteSingleTenantHsmInstanceProposal(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteSingleTenantHsmInstanceProposal as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteSingleTenantHsmInstanceProposal as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getSingleTenantHsmInstanceProposal with closed client', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.GetSingleTenantHsmInstanceProposalRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.GetSingleTenantHsmInstanceProposalRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.getSingleTenantHsmInstanceProposal(request), + expectedError, + ); + }); + }); + + describe('deleteSingleTenantHsmInstanceProposal', () => { + it('invokes deleteSingleTenantHsmInstanceProposal without error', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.DeleteSingleTenantHsmInstanceProposalRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.DeleteSingleTenantHsmInstanceProposalRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteSingleTenantHsmInstanceProposal = + stubSimpleCall(expectedResponse); + const [response] = + await client.deleteSingleTenantHsmInstanceProposal(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteSingleTenantHsmInstanceProposal as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteSingleTenantHsmInstanceProposal as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteSingleTenantHsmInstanceProposal with closed client', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.DeleteSingleTenantHsmInstanceProposalRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.DeleteSingleTenantHsmInstanceProposalRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.deleteSingleTenantHsmInstanceProposal(request), expectedError); - }); + it('invokes deleteSingleTenantHsmInstanceProposal without error using callback', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.DeleteSingleTenantHsmInstanceProposalRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.DeleteSingleTenantHsmInstanceProposalRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteSingleTenantHsmInstanceProposal = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteSingleTenantHsmInstanceProposal( + 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.deleteSingleTenantHsmInstanceProposal as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteSingleTenantHsmInstanceProposal as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createSingleTenantHsmInstance', () => { - it('invokes createSingleTenantHsmInstance without error', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.CreateSingleTenantHsmInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.CreateSingleTenantHsmInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createSingleTenantHsmInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.createSingleTenantHsmInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createSingleTenantHsmInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createSingleTenantHsmInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteSingleTenantHsmInstanceProposal with error', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.DeleteSingleTenantHsmInstanceProposalRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.DeleteSingleTenantHsmInstanceProposalRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteSingleTenantHsmInstanceProposal = + stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.deleteSingleTenantHsmInstanceProposal(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.deleteSingleTenantHsmInstanceProposal as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteSingleTenantHsmInstanceProposal as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createSingleTenantHsmInstance without error using callback', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.CreateSingleTenantHsmInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.CreateSingleTenantHsmInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createSingleTenantHsmInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createSingleTenantHsmInstance( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createSingleTenantHsmInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createSingleTenantHsmInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteSingleTenantHsmInstanceProposal with closed client', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.DeleteSingleTenantHsmInstanceProposalRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.DeleteSingleTenantHsmInstanceProposalRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.deleteSingleTenantHsmInstanceProposal(request), + expectedError, + ); + }); + }); + + describe('createSingleTenantHsmInstance', () => { + it('invokes createSingleTenantHsmInstance without error', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.CreateSingleTenantHsmInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.CreateSingleTenantHsmInstanceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createSingleTenantHsmInstance = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createSingleTenantHsmInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createSingleTenantHsmInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createSingleTenantHsmInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createSingleTenantHsmInstance with call error', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.CreateSingleTenantHsmInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.CreateSingleTenantHsmInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createSingleTenantHsmInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createSingleTenantHsmInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.createSingleTenantHsmInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createSingleTenantHsmInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createSingleTenantHsmInstance without error using callback', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.CreateSingleTenantHsmInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.CreateSingleTenantHsmInstanceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createSingleTenantHsmInstance = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createSingleTenantHsmInstance( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.kms.v1.ISingleTenantHsmInstance, + protos.google.cloud.kms.v1.ICreateSingleTenantHsmInstanceMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.kms.v1.ISingleTenantHsmInstance, + protos.google.cloud.kms.v1.ICreateSingleTenantHsmInstanceMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createSingleTenantHsmInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createSingleTenantHsmInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createSingleTenantHsmInstance with LRO error', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.CreateSingleTenantHsmInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.CreateSingleTenantHsmInstanceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createSingleTenantHsmInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createSingleTenantHsmInstance(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createSingleTenantHsmInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createSingleTenantHsmInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createSingleTenantHsmInstance with call error', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.CreateSingleTenantHsmInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.CreateSingleTenantHsmInstanceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createSingleTenantHsmInstance = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.createSingleTenantHsmInstance(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.createSingleTenantHsmInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createSingleTenantHsmInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateSingleTenantHsmInstanceProgress without error', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateSingleTenantHsmInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createSingleTenantHsmInstance with LRO error', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.CreateSingleTenantHsmInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.CreateSingleTenantHsmInstanceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createSingleTenantHsmInstance = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createSingleTenantHsmInstance(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createSingleTenantHsmInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createSingleTenantHsmInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateSingleTenantHsmInstanceProgress with error', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateSingleTenantHsmInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkCreateSingleTenantHsmInstanceProgress without error', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = + await client.checkCreateSingleTenantHsmInstanceProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('createSingleTenantHsmInstanceProposal', () => { - it('invokes createSingleTenantHsmInstanceProposal without error', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.CreateSingleTenantHsmInstanceProposalRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.CreateSingleTenantHsmInstanceProposalRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createSingleTenantHsmInstanceProposal = stubLongRunningCall(expectedResponse); - const [operation] = await client.createSingleTenantHsmInstanceProposal(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createSingleTenantHsmInstanceProposal as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createSingleTenantHsmInstanceProposal as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateSingleTenantHsmInstanceProgress with error', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateSingleTenantHsmInstanceProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createSingleTenantHsmInstanceProposal', () => { + it('invokes createSingleTenantHsmInstanceProposal without error', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.CreateSingleTenantHsmInstanceProposalRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.CreateSingleTenantHsmInstanceProposalRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createSingleTenantHsmInstanceProposal = + stubLongRunningCall(expectedResponse); + const [operation] = + await client.createSingleTenantHsmInstanceProposal(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createSingleTenantHsmInstanceProposal as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createSingleTenantHsmInstanceProposal as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createSingleTenantHsmInstanceProposal without error using callback', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.CreateSingleTenantHsmInstanceProposalRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.CreateSingleTenantHsmInstanceProposalRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createSingleTenantHsmInstanceProposal = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createSingleTenantHsmInstanceProposal( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createSingleTenantHsmInstanceProposal as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createSingleTenantHsmInstanceProposal as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createSingleTenantHsmInstanceProposal without error using callback', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.CreateSingleTenantHsmInstanceProposalRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.CreateSingleTenantHsmInstanceProposalRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createSingleTenantHsmInstanceProposal = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createSingleTenantHsmInstanceProposal( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.kms.v1.ISingleTenantHsmInstanceProposal, + protos.google.cloud.kms.v1.ICreateSingleTenantHsmInstanceProposalMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.kms.v1.ISingleTenantHsmInstanceProposal, + protos.google.cloud.kms.v1.ICreateSingleTenantHsmInstanceProposalMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createSingleTenantHsmInstanceProposal as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createSingleTenantHsmInstanceProposal as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createSingleTenantHsmInstanceProposal with call error', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.CreateSingleTenantHsmInstanceProposalRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.CreateSingleTenantHsmInstanceProposalRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createSingleTenantHsmInstanceProposal = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createSingleTenantHsmInstanceProposal(request), expectedError); - const actualRequest = (client.innerApiCalls.createSingleTenantHsmInstanceProposal as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createSingleTenantHsmInstanceProposal as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createSingleTenantHsmInstanceProposal with call error', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.CreateSingleTenantHsmInstanceProposalRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.CreateSingleTenantHsmInstanceProposalRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createSingleTenantHsmInstanceProposal = + stubLongRunningCall(undefined, expectedError); + await assert.rejects( + client.createSingleTenantHsmInstanceProposal(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.createSingleTenantHsmInstanceProposal as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createSingleTenantHsmInstanceProposal as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createSingleTenantHsmInstanceProposal with LRO error', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.CreateSingleTenantHsmInstanceProposalRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.CreateSingleTenantHsmInstanceProposalRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createSingleTenantHsmInstanceProposal = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createSingleTenantHsmInstanceProposal(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createSingleTenantHsmInstanceProposal as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createSingleTenantHsmInstanceProposal as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createSingleTenantHsmInstanceProposal with LRO error', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.CreateSingleTenantHsmInstanceProposalRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.CreateSingleTenantHsmInstanceProposalRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createSingleTenantHsmInstanceProposal = + stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = + await client.createSingleTenantHsmInstanceProposal(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createSingleTenantHsmInstanceProposal as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createSingleTenantHsmInstanceProposal as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateSingleTenantHsmInstanceProposalProgress without error', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateSingleTenantHsmInstanceProposalProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkCreateSingleTenantHsmInstanceProposalProgress without error', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = + await client.checkCreateSingleTenantHsmInstanceProposalProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkCreateSingleTenantHsmInstanceProposalProgress with error', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateSingleTenantHsmInstanceProposalProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkCreateSingleTenantHsmInstanceProposalProgress with error', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateSingleTenantHsmInstanceProposalProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('executeSingleTenantHsmInstanceProposal', () => { + it('invokes executeSingleTenantHsmInstanceProposal without error', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ExecuteSingleTenantHsmInstanceProposalRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ExecuteSingleTenantHsmInstanceProposalRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.executeSingleTenantHsmInstanceProposal = + stubLongRunningCall(expectedResponse); + const [operation] = + await client.executeSingleTenantHsmInstanceProposal(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.executeSingleTenantHsmInstanceProposal as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.executeSingleTenantHsmInstanceProposal as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('executeSingleTenantHsmInstanceProposal', () => { - it('invokes executeSingleTenantHsmInstanceProposal without error', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ExecuteSingleTenantHsmInstanceProposalRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ExecuteSingleTenantHsmInstanceProposalRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.executeSingleTenantHsmInstanceProposal = stubLongRunningCall(expectedResponse); - const [operation] = await client.executeSingleTenantHsmInstanceProposal(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.executeSingleTenantHsmInstanceProposal as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.executeSingleTenantHsmInstanceProposal as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes executeSingleTenantHsmInstanceProposal without error using callback', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ExecuteSingleTenantHsmInstanceProposalRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ExecuteSingleTenantHsmInstanceProposalRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.executeSingleTenantHsmInstanceProposal = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.executeSingleTenantHsmInstanceProposal( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.kms.v1.IExecuteSingleTenantHsmInstanceProposalResponse, + protos.google.cloud.kms.v1.IExecuteSingleTenantHsmInstanceProposalMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.kms.v1.IExecuteSingleTenantHsmInstanceProposalResponse, + protos.google.cloud.kms.v1.IExecuteSingleTenantHsmInstanceProposalMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.executeSingleTenantHsmInstanceProposal as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.executeSingleTenantHsmInstanceProposal as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes executeSingleTenantHsmInstanceProposal without error using callback', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ExecuteSingleTenantHsmInstanceProposalRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ExecuteSingleTenantHsmInstanceProposalRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.executeSingleTenantHsmInstanceProposal = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.executeSingleTenantHsmInstanceProposal( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.executeSingleTenantHsmInstanceProposal as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.executeSingleTenantHsmInstanceProposal as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes executeSingleTenantHsmInstanceProposal with call error', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ExecuteSingleTenantHsmInstanceProposalRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ExecuteSingleTenantHsmInstanceProposalRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.executeSingleTenantHsmInstanceProposal = + stubLongRunningCall(undefined, expectedError); + await assert.rejects( + client.executeSingleTenantHsmInstanceProposal(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.executeSingleTenantHsmInstanceProposal as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.executeSingleTenantHsmInstanceProposal as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes executeSingleTenantHsmInstanceProposal with call error', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ExecuteSingleTenantHsmInstanceProposalRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ExecuteSingleTenantHsmInstanceProposalRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.executeSingleTenantHsmInstanceProposal = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.executeSingleTenantHsmInstanceProposal(request), expectedError); - const actualRequest = (client.innerApiCalls.executeSingleTenantHsmInstanceProposal as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.executeSingleTenantHsmInstanceProposal as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes executeSingleTenantHsmInstanceProposal with LRO error', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ExecuteSingleTenantHsmInstanceProposalRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ExecuteSingleTenantHsmInstanceProposalRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.executeSingleTenantHsmInstanceProposal = + stubLongRunningCall(undefined, undefined, expectedError); + const [operation] = + await client.executeSingleTenantHsmInstanceProposal(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.executeSingleTenantHsmInstanceProposal as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.executeSingleTenantHsmInstanceProposal as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes executeSingleTenantHsmInstanceProposal with LRO error', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ExecuteSingleTenantHsmInstanceProposalRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ExecuteSingleTenantHsmInstanceProposalRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.executeSingleTenantHsmInstanceProposal = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.executeSingleTenantHsmInstanceProposal(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.executeSingleTenantHsmInstanceProposal as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.executeSingleTenantHsmInstanceProposal as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkExecuteSingleTenantHsmInstanceProposalProgress without error', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = + await client.checkExecuteSingleTenantHsmInstanceProposalProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkExecuteSingleTenantHsmInstanceProposalProgress without error', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkExecuteSingleTenantHsmInstanceProposalProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkExecuteSingleTenantHsmInstanceProposalProgress with error', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkExecuteSingleTenantHsmInstanceProposalProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listSingleTenantHsmInstances', () => { + it('invokes listSingleTenantHsmInstances without error', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListSingleTenantHsmInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListSingleTenantHsmInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.kms.v1.SingleTenantHsmInstance(), + ), + generateSampleMessage( + new protos.google.cloud.kms.v1.SingleTenantHsmInstance(), + ), + generateSampleMessage( + new protos.google.cloud.kms.v1.SingleTenantHsmInstance(), + ), + ]; + client.innerApiCalls.listSingleTenantHsmInstances = + stubSimpleCall(expectedResponse); + const [response] = await client.listSingleTenantHsmInstances(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listSingleTenantHsmInstances as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listSingleTenantHsmInstances as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkExecuteSingleTenantHsmInstanceProposalProgress with error', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkExecuteSingleTenantHsmInstanceProposalProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes listSingleTenantHsmInstances without error using callback', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListSingleTenantHsmInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListSingleTenantHsmInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.kms.v1.SingleTenantHsmInstance(), + ), + generateSampleMessage( + new protos.google.cloud.kms.v1.SingleTenantHsmInstance(), + ), + generateSampleMessage( + new protos.google.cloud.kms.v1.SingleTenantHsmInstance(), + ), + ]; + client.innerApiCalls.listSingleTenantHsmInstances = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listSingleTenantHsmInstances( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.kms.v1.ISingleTenantHsmInstance[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listSingleTenantHsmInstances as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listSingleTenantHsmInstances as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listSingleTenantHsmInstances', () => { - it('invokes listSingleTenantHsmInstances without error', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListSingleTenantHsmInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListSingleTenantHsmInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.kms.v1.SingleTenantHsmInstance()), - generateSampleMessage(new protos.google.cloud.kms.v1.SingleTenantHsmInstance()), - generateSampleMessage(new protos.google.cloud.kms.v1.SingleTenantHsmInstance()), - ]; - client.innerApiCalls.listSingleTenantHsmInstances = stubSimpleCall(expectedResponse); - const [response] = await client.listSingleTenantHsmInstances(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listSingleTenantHsmInstances as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listSingleTenantHsmInstances as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listSingleTenantHsmInstances with error', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListSingleTenantHsmInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListSingleTenantHsmInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listSingleTenantHsmInstances = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.listSingleTenantHsmInstances(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.listSingleTenantHsmInstances as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listSingleTenantHsmInstances as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listSingleTenantHsmInstances without error using callback', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListSingleTenantHsmInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListSingleTenantHsmInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.kms.v1.SingleTenantHsmInstance()), - generateSampleMessage(new protos.google.cloud.kms.v1.SingleTenantHsmInstance()), - generateSampleMessage(new protos.google.cloud.kms.v1.SingleTenantHsmInstance()), - ]; - client.innerApiCalls.listSingleTenantHsmInstances = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listSingleTenantHsmInstances( - request, - (err?: Error|null, result?: protos.google.cloud.kms.v1.ISingleTenantHsmInstance[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listSingleTenantHsmInstances as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listSingleTenantHsmInstances as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listSingleTenantHsmInstancesStream without error', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListSingleTenantHsmInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListSingleTenantHsmInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.kms.v1.SingleTenantHsmInstance(), + ), + generateSampleMessage( + new protos.google.cloud.kms.v1.SingleTenantHsmInstance(), + ), + generateSampleMessage( + new protos.google.cloud.kms.v1.SingleTenantHsmInstance(), + ), + ]; + client.descriptors.page.listSingleTenantHsmInstances.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listSingleTenantHsmInstancesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.kms.v1.SingleTenantHsmInstance[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.kms.v1.SingleTenantHsmInstance) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + ( + client.descriptors.page.listSingleTenantHsmInstances + .createStream as SinonStub + ) + .getCall(0) + .calledWith( + client.innerApiCalls.listSingleTenantHsmInstances, + request, + ), + ); + assert( + ( + client.descriptors.page.listSingleTenantHsmInstances + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listSingleTenantHsmInstances with error', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListSingleTenantHsmInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListSingleTenantHsmInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listSingleTenantHsmInstances = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listSingleTenantHsmInstances(request), expectedError); - const actualRequest = (client.innerApiCalls.listSingleTenantHsmInstances as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listSingleTenantHsmInstances as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listSingleTenantHsmInstancesStream with error', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListSingleTenantHsmInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListSingleTenantHsmInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listSingleTenantHsmInstances.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listSingleTenantHsmInstancesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.kms.v1.SingleTenantHsmInstance[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.kms.v1.SingleTenantHsmInstance) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + ( + client.descriptors.page.listSingleTenantHsmInstances + .createStream as SinonStub + ) + .getCall(0) + .calledWith( + client.innerApiCalls.listSingleTenantHsmInstances, + request, + ), + ); + assert( + ( + client.descriptors.page.listSingleTenantHsmInstances + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listSingleTenantHsmInstancesStream without error', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListSingleTenantHsmInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListSingleTenantHsmInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.kms.v1.SingleTenantHsmInstance()), - generateSampleMessage(new protos.google.cloud.kms.v1.SingleTenantHsmInstance()), - generateSampleMessage(new protos.google.cloud.kms.v1.SingleTenantHsmInstance()), - ]; - client.descriptors.page.listSingleTenantHsmInstances.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listSingleTenantHsmInstancesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.kms.v1.SingleTenantHsmInstance[] = []; - stream.on('data', (response: protos.google.cloud.kms.v1.SingleTenantHsmInstance) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listSingleTenantHsmInstances.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listSingleTenantHsmInstances, request)); - assert( - (client.descriptors.page.listSingleTenantHsmInstances.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listSingleTenantHsmInstances without error', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListSingleTenantHsmInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListSingleTenantHsmInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.kms.v1.SingleTenantHsmInstance(), + ), + generateSampleMessage( + new protos.google.cloud.kms.v1.SingleTenantHsmInstance(), + ), + generateSampleMessage( + new protos.google.cloud.kms.v1.SingleTenantHsmInstance(), + ), + ]; + client.descriptors.page.listSingleTenantHsmInstances.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.kms.v1.ISingleTenantHsmInstance[] = + []; + const iterable = client.listSingleTenantHsmInstancesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listSingleTenantHsmInstances + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listSingleTenantHsmInstances + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listSingleTenantHsmInstancesStream with error', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListSingleTenantHsmInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListSingleTenantHsmInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listSingleTenantHsmInstances.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listSingleTenantHsmInstancesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.kms.v1.SingleTenantHsmInstance[] = []; - stream.on('data', (response: protos.google.cloud.kms.v1.SingleTenantHsmInstance) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listSingleTenantHsmInstances.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listSingleTenantHsmInstances, request)); - assert( - (client.descriptors.page.listSingleTenantHsmInstances.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listSingleTenantHsmInstances with error', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListSingleTenantHsmInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListSingleTenantHsmInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listSingleTenantHsmInstances.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listSingleTenantHsmInstancesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.kms.v1.ISingleTenantHsmInstance[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listSingleTenantHsmInstances + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listSingleTenantHsmInstances + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + + describe('listSingleTenantHsmInstanceProposals', () => { + it('invokes listSingleTenantHsmInstanceProposals without error', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListSingleTenantHsmInstanceProposalsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListSingleTenantHsmInstanceProposalsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal(), + ), + generateSampleMessage( + new protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal(), + ), + generateSampleMessage( + new protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal(), + ), + ]; + client.innerApiCalls.listSingleTenantHsmInstanceProposals = + stubSimpleCall(expectedResponse); + const [response] = + await client.listSingleTenantHsmInstanceProposals(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listSingleTenantHsmInstanceProposals as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listSingleTenantHsmInstanceProposals as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listSingleTenantHsmInstances without error', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListSingleTenantHsmInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListSingleTenantHsmInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.kms.v1.SingleTenantHsmInstance()), - generateSampleMessage(new protos.google.cloud.kms.v1.SingleTenantHsmInstance()), - generateSampleMessage(new protos.google.cloud.kms.v1.SingleTenantHsmInstance()), - ]; - client.descriptors.page.listSingleTenantHsmInstances.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.kms.v1.ISingleTenantHsmInstance[] = []; - const iterable = client.listSingleTenantHsmInstancesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listSingleTenantHsmInstanceProposals without error using callback', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListSingleTenantHsmInstanceProposalsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListSingleTenantHsmInstanceProposalsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal(), + ), + generateSampleMessage( + new protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal(), + ), + generateSampleMessage( + new protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal(), + ), + ]; + client.innerApiCalls.listSingleTenantHsmInstanceProposals = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listSingleTenantHsmInstanceProposals( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.kms.v1.ISingleTenantHsmInstanceProposal[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listSingleTenantHsmInstances.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listSingleTenantHsmInstances.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listSingleTenantHsmInstances with error', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListSingleTenantHsmInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListSingleTenantHsmInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listSingleTenantHsmInstances.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listSingleTenantHsmInstancesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.kms.v1.ISingleTenantHsmInstance[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listSingleTenantHsmInstances.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listSingleTenantHsmInstances.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.listSingleTenantHsmInstanceProposals as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listSingleTenantHsmInstanceProposals as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listSingleTenantHsmInstanceProposals', () => { - it('invokes listSingleTenantHsmInstanceProposals without error', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListSingleTenantHsmInstanceProposalsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListSingleTenantHsmInstanceProposalsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal()), - generateSampleMessage(new protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal()), - generateSampleMessage(new protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal()), - ]; - client.innerApiCalls.listSingleTenantHsmInstanceProposals = stubSimpleCall(expectedResponse); - const [response] = await client.listSingleTenantHsmInstanceProposals(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listSingleTenantHsmInstanceProposals as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listSingleTenantHsmInstanceProposals as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listSingleTenantHsmInstanceProposals without error using callback', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListSingleTenantHsmInstanceProposalsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListSingleTenantHsmInstanceProposalsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal()), - generateSampleMessage(new protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal()), - generateSampleMessage(new protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal()), - ]; - client.innerApiCalls.listSingleTenantHsmInstanceProposals = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listSingleTenantHsmInstanceProposals( - request, - (err?: Error|null, result?: protos.google.cloud.kms.v1.ISingleTenantHsmInstanceProposal[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listSingleTenantHsmInstanceProposals as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listSingleTenantHsmInstanceProposals as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listSingleTenantHsmInstanceProposals with error', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListSingleTenantHsmInstanceProposalsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListSingleTenantHsmInstanceProposalsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listSingleTenantHsmInstanceProposals = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listSingleTenantHsmInstanceProposals(request), expectedError); - const actualRequest = (client.innerApiCalls.listSingleTenantHsmInstanceProposals as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listSingleTenantHsmInstanceProposals as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listSingleTenantHsmInstanceProposals with error', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListSingleTenantHsmInstanceProposalsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListSingleTenantHsmInstanceProposalsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listSingleTenantHsmInstanceProposals = + stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.listSingleTenantHsmInstanceProposals(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.listSingleTenantHsmInstanceProposals as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listSingleTenantHsmInstanceProposals as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listSingleTenantHsmInstanceProposalsStream without error', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListSingleTenantHsmInstanceProposalsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListSingleTenantHsmInstanceProposalsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal()), - generateSampleMessage(new protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal()), - generateSampleMessage(new protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal()), - ]; - client.descriptors.page.listSingleTenantHsmInstanceProposals.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listSingleTenantHsmInstanceProposalsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal[] = []; - stream.on('data', (response: protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listSingleTenantHsmInstanceProposals.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listSingleTenantHsmInstanceProposals, request)); - assert( - (client.descriptors.page.listSingleTenantHsmInstanceProposals.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listSingleTenantHsmInstanceProposalsStream without error', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListSingleTenantHsmInstanceProposalsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListSingleTenantHsmInstanceProposalsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal(), + ), + generateSampleMessage( + new protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal(), + ), + generateSampleMessage( + new protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal(), + ), + ]; + client.descriptors.page.listSingleTenantHsmInstanceProposals.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listSingleTenantHsmInstanceProposalsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + ( + client.descriptors.page.listSingleTenantHsmInstanceProposals + .createStream as SinonStub + ) + .getCall(0) + .calledWith( + client.innerApiCalls.listSingleTenantHsmInstanceProposals, + request, + ), + ); + assert( + ( + client.descriptors.page.listSingleTenantHsmInstanceProposals + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listSingleTenantHsmInstanceProposalsStream with error', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListSingleTenantHsmInstanceProposalsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListSingleTenantHsmInstanceProposalsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listSingleTenantHsmInstanceProposals.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listSingleTenantHsmInstanceProposalsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal[] = []; - stream.on('data', (response: protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listSingleTenantHsmInstanceProposals.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listSingleTenantHsmInstanceProposals, request)); - assert( - (client.descriptors.page.listSingleTenantHsmInstanceProposals.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listSingleTenantHsmInstanceProposalsStream with error', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListSingleTenantHsmInstanceProposalsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListSingleTenantHsmInstanceProposalsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listSingleTenantHsmInstanceProposals.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listSingleTenantHsmInstanceProposalsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + ( + client.descriptors.page.listSingleTenantHsmInstanceProposals + .createStream as SinonStub + ) + .getCall(0) + .calledWith( + client.innerApiCalls.listSingleTenantHsmInstanceProposals, + request, + ), + ); + assert( + ( + client.descriptors.page.listSingleTenantHsmInstanceProposals + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('uses async iteration with listSingleTenantHsmInstanceProposals without error', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListSingleTenantHsmInstanceProposalsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListSingleTenantHsmInstanceProposalsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal()), - generateSampleMessage(new protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal()), - generateSampleMessage(new protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal()), - ]; - client.descriptors.page.listSingleTenantHsmInstanceProposals.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.kms.v1.ISingleTenantHsmInstanceProposal[] = []; - const iterable = client.listSingleTenantHsmInstanceProposalsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listSingleTenantHsmInstanceProposals.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listSingleTenantHsmInstanceProposals.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listSingleTenantHsmInstanceProposals without error', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListSingleTenantHsmInstanceProposalsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListSingleTenantHsmInstanceProposalsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal(), + ), + generateSampleMessage( + new protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal(), + ), + generateSampleMessage( + new protos.google.cloud.kms.v1.SingleTenantHsmInstanceProposal(), + ), + ]; + client.descriptors.page.listSingleTenantHsmInstanceProposals.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.kms.v1.ISingleTenantHsmInstanceProposal[] = + []; + const iterable = + client.listSingleTenantHsmInstanceProposalsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listSingleTenantHsmInstanceProposals + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listSingleTenantHsmInstanceProposals + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('uses async iteration with listSingleTenantHsmInstanceProposals with error', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListSingleTenantHsmInstanceProposalsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListSingleTenantHsmInstanceProposalsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listSingleTenantHsmInstanceProposals.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listSingleTenantHsmInstanceProposalsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.kms.v1.ISingleTenantHsmInstanceProposal[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listSingleTenantHsmInstanceProposals.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listSingleTenantHsmInstanceProposals.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listSingleTenantHsmInstanceProposals with error', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListSingleTenantHsmInstanceProposalsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListSingleTenantHsmInstanceProposalsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listSingleTenantHsmInstanceProposals.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = + client.listSingleTenantHsmInstanceProposalsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.kms.v1.ISingleTenantHsmInstanceProposal[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listSingleTenantHsmInstanceProposals + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listSingleTenantHsmInstanceProposals + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); }); - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.getIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getIamPolicy without error using callback', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes getIamPolicy with error', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.getIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.setIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes setIamPolicy without error using callback', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes setIamPolicy with error', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getIamPolicy without error using callback', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .getIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.getIamPolicy as SinonStub).getCall(0)); }); - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); - const response = await client.testIamPermissions(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes testIamPermissions without error using callback', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.TestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0)); - }); - it('invokes testIamPermissions with error', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request, expectedOptions), expectedError); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getIamPolicy with error', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.getIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - 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 hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - 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 hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + }); + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.setIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - 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 hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes setIamPolicy without error using callback', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .setIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.setIamPolicy as SinonStub).getCall(0)); }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - 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 hsmmanagementModule.v1.HsmManagementClient({ - 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 hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('invokes setIamPolicy with error', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.setIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - 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 hsmmanagementModule.v1.HsmManagementClient({ - 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 hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + }); + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); + const response = await client.testIamPermissions( + request, + expectedOptions, + ); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - 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 hsmmanagementModule.v1.HsmManagementClient({ - 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 hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('invokes testIamPermissions without error using callback', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .testIamPermissions( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.TestIamPermissionsResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.testIamPermissions as SinonStub).getCall(0)); + }); + it('invokes testIamPermissions with error', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.testIamPermissions = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.testIamPermissions(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.IOperation[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes getLocation without error using callback', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.IOperation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + 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 hsmmanagementModule.v1.HsmManagementClient({ + 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 hsmmanagementModule.v1.HsmManagementClient({ + 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 hsmmanagementModule.v1.HsmManagementClient({ + 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 hsmmanagementModule.v1.HsmManagementClient({ + 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 hsmmanagementModule.v1.HsmManagementClient({ + 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 hsmmanagementModule.v1.HsmManagementClient({ + 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 hsmmanagementModule.v1.HsmManagementClient({ + 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 hsmmanagementModule.v1.HsmManagementClient({ + 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 hsmmanagementModule.v1.HsmManagementClient({ + 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 hsmmanagementModule.v1.HsmManagementClient({ + 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 hsmmanagementModule.v1.HsmManagementClient({ + 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 hsmmanagementModule.v1.HsmManagementClient({ + 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 hsmmanagementModule.v1.HsmManagementClient({ + 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('cryptoKey', async () => { + const fakePath = '/rendered/path/cryptoKey'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + key_ring: 'keyRingValue', + crypto_key: 'cryptoKeyValue', + }; + const client = new hsmmanagementModule.v1.HsmManagementClient({ + 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('Path templates', () => { - - describe('cryptoKey', async () => { - const fakePath = "/rendered/path/cryptoKey"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - key_ring: "keyRingValue", - crypto_key: "cryptoKeyValue", - }; - const client = new hsmmanagementModule.v1.HsmManagementClient({ - 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 hsmmanagementModule.v1.HsmManagementClient({ - 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 hsmmanagementModule.v1.HsmManagementClient({ + 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('ekmConfig', async () => { - const fakePath = "/rendered/path/ekmConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.ekmConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.ekmConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('ekmConfigPath', () => { - const result = client.ekmConfigPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.ekmConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromEkmConfigName', () => { - const result = client.matchProjectFromEkmConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.ekmConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromEkmConfigName', () => { - const result = client.matchLocationFromEkmConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.ekmConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('ekmConfig', async () => { + const fakePath = '/rendered/path/ekmConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.ekmConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.ekmConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('ekmConfigPath', () => { + const result = client.ekmConfigPath('projectValue', 'locationValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.ekmConfigPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromEkmConfigName', () => { + const result = client.matchProjectFromEkmConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.ekmConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromEkmConfigName', () => { + const result = client.matchLocationFromEkmConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.ekmConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('ekmConnection', async () => { - const fakePath = "/rendered/path/ekmConnection"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - ekm_connection: "ekmConnectionValue", - }; - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.ekmConnectionPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.ekmConnectionPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('ekmConnectionPath', () => { - const result = client.ekmConnectionPath("projectValue", "locationValue", "ekmConnectionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.ekmConnectionPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromEkmConnectionName', () => { - const result = client.matchProjectFromEkmConnectionName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.ekmConnectionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromEkmConnectionName', () => { - const result = client.matchLocationFromEkmConnectionName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.ekmConnectionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchEkmConnectionFromEkmConnectionName', () => { - const result = client.matchEkmConnectionFromEkmConnectionName(fakePath); - assert.strictEqual(result, "ekmConnectionValue"); - assert((client.pathTemplates.ekmConnectionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('ekmConnection', async () => { + const fakePath = '/rendered/path/ekmConnection'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + ekm_connection: 'ekmConnectionValue', + }; + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.ekmConnectionPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.ekmConnectionPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('ekmConnectionPath', () => { + const result = client.ekmConnectionPath( + 'projectValue', + 'locationValue', + 'ekmConnectionValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.ekmConnectionPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromEkmConnectionName', () => { + const result = client.matchProjectFromEkmConnectionName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.ekmConnectionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromEkmConnectionName', () => { + const result = client.matchLocationFromEkmConnectionName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.ekmConnectionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchEkmConnectionFromEkmConnectionName', () => { + const result = client.matchEkmConnectionFromEkmConnectionName(fakePath); + assert.strictEqual(result, 'ekmConnectionValue'); + assert( + (client.pathTemplates.ekmConnectionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('folderAutokeyConfig', async () => { - const fakePath = "/rendered/path/folderAutokeyConfig"; - const expectedParameters = { - folder: "folderValue", - }; - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.folderAutokeyConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.folderAutokeyConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('folderAutokeyConfigPath', () => { - const result = client.folderAutokeyConfigPath("folderValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.folderAutokeyConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchFolderFromFolderAutokeyConfigName', () => { - const result = client.matchFolderFromFolderAutokeyConfigName(fakePath); - assert.strictEqual(result, "folderValue"); - assert((client.pathTemplates.folderAutokeyConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('folderAutokeyConfig', async () => { + const fakePath = '/rendered/path/folderAutokeyConfig'; + const expectedParameters = { + folder: 'folderValue', + }; + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.folderAutokeyConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.folderAutokeyConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('folderAutokeyConfigPath', () => { + const result = client.folderAutokeyConfigPath('folderValue'); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.folderAutokeyConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchFolderFromFolderAutokeyConfigName', () => { + const result = client.matchFolderFromFolderAutokeyConfigName(fakePath); + assert.strictEqual(result, 'folderValue'); + assert( + ( + client.pathTemplates.folderAutokeyConfigPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('importJob', async () => { - const fakePath = "/rendered/path/importJob"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - key_ring: "keyRingValue", - import_job: "importJobValue", - }; - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.importJobPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.importJobPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('importJobPath', () => { - const result = client.importJobPath("projectValue", "locationValue", "keyRingValue", "importJobValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.importJobPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromImportJobName', () => { - const result = client.matchProjectFromImportJobName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.importJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromImportJobName', () => { - const result = client.matchLocationFromImportJobName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.importJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchKeyRingFromImportJobName', () => { - const result = client.matchKeyRingFromImportJobName(fakePath); - assert.strictEqual(result, "keyRingValue"); - assert((client.pathTemplates.importJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchImportJobFromImportJobName', () => { - const result = client.matchImportJobFromImportJobName(fakePath); - assert.strictEqual(result, "importJobValue"); - assert((client.pathTemplates.importJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('importJob', async () => { + const fakePath = '/rendered/path/importJob'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + key_ring: 'keyRingValue', + import_job: 'importJobValue', + }; + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.importJobPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.importJobPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('importJobPath', () => { + const result = client.importJobPath( + 'projectValue', + 'locationValue', + 'keyRingValue', + 'importJobValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.importJobPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromImportJobName', () => { + const result = client.matchProjectFromImportJobName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.importJobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromImportJobName', () => { + const result = client.matchLocationFromImportJobName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.importJobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchKeyRingFromImportJobName', () => { + const result = client.matchKeyRingFromImportJobName(fakePath); + assert.strictEqual(result, 'keyRingValue'); + assert( + (client.pathTemplates.importJobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchImportJobFromImportJobName', () => { + const result = client.matchImportJobFromImportJobName(fakePath); + assert.strictEqual(result, 'importJobValue'); + assert( + (client.pathTemplates.importJobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('keyHandle', async () => { - const fakePath = "/rendered/path/keyHandle"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - key_handle: "keyHandleValue", - }; - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.keyHandlePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.keyHandlePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('keyHandlePath', () => { - const result = client.keyHandlePath("projectValue", "locationValue", "keyHandleValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.keyHandlePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromKeyHandleName', () => { - const result = client.matchProjectFromKeyHandleName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.keyHandlePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromKeyHandleName', () => { - const result = client.matchLocationFromKeyHandleName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.keyHandlePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchKeyHandleFromKeyHandleName', () => { - const result = client.matchKeyHandleFromKeyHandleName(fakePath); - assert.strictEqual(result, "keyHandleValue"); - assert((client.pathTemplates.keyHandlePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('keyHandle', async () => { + const fakePath = '/rendered/path/keyHandle'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + key_handle: 'keyHandleValue', + }; + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.keyHandlePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.keyHandlePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('keyHandlePath', () => { + const result = client.keyHandlePath( + 'projectValue', + 'locationValue', + 'keyHandleValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.keyHandlePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromKeyHandleName', () => { + const result = client.matchProjectFromKeyHandleName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.keyHandlePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromKeyHandleName', () => { + const result = client.matchLocationFromKeyHandleName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.keyHandlePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchKeyHandleFromKeyHandleName', () => { + const result = client.matchKeyHandleFromKeyHandleName(fakePath); + assert.strictEqual(result, 'keyHandleValue'); + assert( + (client.pathTemplates.keyHandlePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('keyRing', async () => { - const fakePath = "/rendered/path/keyRing"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - key_ring: "keyRingValue", - }; - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.keyRingPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.keyRingPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('keyRingPath', () => { - const result = client.keyRingPath("projectValue", "locationValue", "keyRingValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.keyRingPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromKeyRingName', () => { - const result = client.matchProjectFromKeyRingName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.keyRingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromKeyRingName', () => { - const result = client.matchLocationFromKeyRingName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.keyRingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchKeyRingFromKeyRingName', () => { - const result = client.matchKeyRingFromKeyRingName(fakePath); - assert.strictEqual(result, "keyRingValue"); - assert((client.pathTemplates.keyRingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('keyRing', async () => { + const fakePath = '/rendered/path/keyRing'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + key_ring: 'keyRingValue', + }; + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.keyRingPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.keyRingPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('keyRingPath', () => { + const result = client.keyRingPath( + 'projectValue', + 'locationValue', + 'keyRingValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.keyRingPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromKeyRingName', () => { + const result = client.matchProjectFromKeyRingName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.keyRingPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromKeyRingName', () => { + const result = client.matchLocationFromKeyRingName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.keyRingPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchKeyRingFromKeyRingName', () => { + const result = client.matchKeyRingFromKeyRingName(fakePath); + assert.strictEqual(result, 'keyRingValue'); + assert( + (client.pathTemplates.keyRingPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('location', async () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new hsmmanagementModule.v1.HsmManagementClient({ - 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 hsmmanagementModule.v1.HsmManagementClient({ + 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('projectAutokeyConfig', async () => { - const fakePath = "/rendered/path/projectAutokeyConfig"; - const expectedParameters = { - project: "projectValue", - }; - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectAutokeyConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectAutokeyConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectAutokeyConfigPath', () => { - const result = client.projectAutokeyConfigPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectAutokeyConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectAutokeyConfigName', () => { - const result = client.matchProjectFromProjectAutokeyConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectAutokeyConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectAutokeyConfig', async () => { + const fakePath = '/rendered/path/projectAutokeyConfig'; + const expectedParameters = { + project: 'projectValue', + }; + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectAutokeyConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectAutokeyConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectAutokeyConfigPath', () => { + const result = client.projectAutokeyConfigPath('projectValue'); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectAutokeyConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectAutokeyConfigName', () => { + const result = + client.matchProjectFromProjectAutokeyConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.projectAutokeyConfigPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('publicKey', async () => { - const fakePath = "/rendered/path/publicKey"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - key_ring: "keyRingValue", - crypto_key: "cryptoKeyValue", - crypto_key_version: "cryptoKeyVersionValue", - }; - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.publicKeyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.publicKeyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('publicKeyPath', () => { - const result = client.publicKeyPath("projectValue", "locationValue", "keyRingValue", "cryptoKeyValue", "cryptoKeyVersionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.publicKeyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromPublicKeyName', () => { - const result = client.matchProjectFromPublicKeyName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.publicKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromPublicKeyName', () => { - const result = client.matchLocationFromPublicKeyName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.publicKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchKeyRingFromPublicKeyName', () => { - const result = client.matchKeyRingFromPublicKeyName(fakePath); - assert.strictEqual(result, "keyRingValue"); - assert((client.pathTemplates.publicKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCryptoKeyFromPublicKeyName', () => { - const result = client.matchCryptoKeyFromPublicKeyName(fakePath); - assert.strictEqual(result, "cryptoKeyValue"); - assert((client.pathTemplates.publicKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCryptoKeyVersionFromPublicKeyName', () => { - const result = client.matchCryptoKeyVersionFromPublicKeyName(fakePath); - assert.strictEqual(result, "cryptoKeyVersionValue"); - assert((client.pathTemplates.publicKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('publicKey', async () => { + const fakePath = '/rendered/path/publicKey'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + key_ring: 'keyRingValue', + crypto_key: 'cryptoKeyValue', + crypto_key_version: 'cryptoKeyVersionValue', + }; + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.publicKeyPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.publicKeyPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('publicKeyPath', () => { + const result = client.publicKeyPath( + 'projectValue', + 'locationValue', + 'keyRingValue', + 'cryptoKeyValue', + 'cryptoKeyVersionValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.publicKeyPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromPublicKeyName', () => { + const result = client.matchProjectFromPublicKeyName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.publicKeyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromPublicKeyName', () => { + const result = client.matchLocationFromPublicKeyName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.publicKeyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchKeyRingFromPublicKeyName', () => { + const result = client.matchKeyRingFromPublicKeyName(fakePath); + assert.strictEqual(result, 'keyRingValue'); + assert( + (client.pathTemplates.publicKeyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCryptoKeyFromPublicKeyName', () => { + const result = client.matchCryptoKeyFromPublicKeyName(fakePath); + assert.strictEqual(result, 'cryptoKeyValue'); + assert( + (client.pathTemplates.publicKeyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCryptoKeyVersionFromPublicKeyName', () => { + const result = client.matchCryptoKeyVersionFromPublicKeyName(fakePath); + assert.strictEqual(result, 'cryptoKeyVersionValue'); + assert( + (client.pathTemplates.publicKeyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('retiredResource', async () => { - const fakePath = "/rendered/path/retiredResource"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - retired_resource: "retiredResourceValue", - }; - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.retiredResourcePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.retiredResourcePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('retiredResourcePath', () => { - const result = client.retiredResourcePath("projectValue", "locationValue", "retiredResourceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.retiredResourcePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromRetiredResourceName', () => { - const result = client.matchProjectFromRetiredResourceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.retiredResourcePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromRetiredResourceName', () => { - const result = client.matchLocationFromRetiredResourceName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.retiredResourcePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRetiredResourceFromRetiredResourceName', () => { - const result = client.matchRetiredResourceFromRetiredResourceName(fakePath); - assert.strictEqual(result, "retiredResourceValue"); - assert((client.pathTemplates.retiredResourcePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('retiredResource', async () => { + const fakePath = '/rendered/path/retiredResource'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + retired_resource: 'retiredResourceValue', + }; + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.retiredResourcePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.retiredResourcePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('retiredResourcePath', () => { + const result = client.retiredResourcePath( + 'projectValue', + 'locationValue', + 'retiredResourceValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.retiredResourcePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromRetiredResourceName', () => { + const result = client.matchProjectFromRetiredResourceName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.retiredResourcePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromRetiredResourceName', () => { + const result = client.matchLocationFromRetiredResourceName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.retiredResourcePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRetiredResourceFromRetiredResourceName', () => { + const result = + client.matchRetiredResourceFromRetiredResourceName(fakePath); + assert.strictEqual(result, 'retiredResourceValue'); + assert( + (client.pathTemplates.retiredResourcePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('singleTenantHsmInstance', async () => { - const fakePath = "/rendered/path/singleTenantHsmInstance"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - single_tenant_hsm_instance: "singleTenantHsmInstanceValue", - }; - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.singleTenantHsmInstancePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.singleTenantHsmInstancePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('singleTenantHsmInstancePath', () => { - const result = client.singleTenantHsmInstancePath("projectValue", "locationValue", "singleTenantHsmInstanceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.singleTenantHsmInstancePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromSingleTenantHsmInstanceName', () => { - const result = client.matchProjectFromSingleTenantHsmInstanceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.singleTenantHsmInstancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromSingleTenantHsmInstanceName', () => { - const result = client.matchLocationFromSingleTenantHsmInstanceName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.singleTenantHsmInstancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceName', () => { - const result = client.matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceName(fakePath); - assert.strictEqual(result, "singleTenantHsmInstanceValue"); - assert((client.pathTemplates.singleTenantHsmInstancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('singleTenantHsmInstance', async () => { + const fakePath = '/rendered/path/singleTenantHsmInstance'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + single_tenant_hsm_instance: 'singleTenantHsmInstanceValue', + }; + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.singleTenantHsmInstancePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.singleTenantHsmInstancePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('singleTenantHsmInstancePath', () => { + const result = client.singleTenantHsmInstancePath( + 'projectValue', + 'locationValue', + 'singleTenantHsmInstanceValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.singleTenantHsmInstancePathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromSingleTenantHsmInstanceName', () => { + const result = + client.matchProjectFromSingleTenantHsmInstanceName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.singleTenantHsmInstancePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromSingleTenantHsmInstanceName', () => { + const result = + client.matchLocationFromSingleTenantHsmInstanceName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.singleTenantHsmInstancePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceName', () => { + const result = + client.matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceName( + fakePath, + ); + assert.strictEqual(result, 'singleTenantHsmInstanceValue'); + assert( + ( + client.pathTemplates.singleTenantHsmInstancePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('singleTenantHsmInstanceProposal', async () => { - const fakePath = "/rendered/path/singleTenantHsmInstanceProposal"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - single_tenant_hsm_instance: "singleTenantHsmInstanceValue", - proposal: "proposalValue", - }; - const client = new hsmmanagementModule.v1.HsmManagementClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('singleTenantHsmInstanceProposalPath', () => { - const result = client.singleTenantHsmInstanceProposalPath("projectValue", "locationValue", "singleTenantHsmInstanceValue", "proposalValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromSingleTenantHsmInstanceProposalName', () => { - const result = client.matchProjectFromSingleTenantHsmInstanceProposalName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromSingleTenantHsmInstanceProposalName', () => { - const result = client.matchLocationFromSingleTenantHsmInstanceProposalName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceProposalName', () => { - const result = client.matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceProposalName(fakePath); - assert.strictEqual(result, "singleTenantHsmInstanceValue"); - assert((client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProposalFromSingleTenantHsmInstanceProposalName', () => { - const result = client.matchProposalFromSingleTenantHsmInstanceProposalName(fakePath); - assert.strictEqual(result, "proposalValue"); - assert((client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('singleTenantHsmInstanceProposal', async () => { + const fakePath = '/rendered/path/singleTenantHsmInstanceProposal'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + single_tenant_hsm_instance: 'singleTenantHsmInstanceValue', + proposal: 'proposalValue', + }; + const client = new hsmmanagementModule.v1.HsmManagementClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('singleTenantHsmInstanceProposalPath', () => { + const result = client.singleTenantHsmInstanceProposalPath( + 'projectValue', + 'locationValue', + 'singleTenantHsmInstanceValue', + 'proposalValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromSingleTenantHsmInstanceProposalName', () => { + const result = + client.matchProjectFromSingleTenantHsmInstanceProposalName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromSingleTenantHsmInstanceProposalName', () => { + const result = + client.matchLocationFromSingleTenantHsmInstanceProposalName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceProposalName', () => { + const result = + client.matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceProposalName( + fakePath, + ); + assert.strictEqual(result, 'singleTenantHsmInstanceValue'); + assert( + ( + client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchProposalFromSingleTenantHsmInstanceProposalName', () => { + const result = + client.matchProposalFromSingleTenantHsmInstanceProposalName(fakePath); + assert.strictEqual(result, 'proposalValue'); + assert( + ( + client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-kms/test/gapic_key_management_service_v1.ts b/packages/google-cloud-kms/test/gapic_key_management_service_v1.ts index b446271a9cd2..0918cad5e952 100644 --- a/packages/google-cloud-kms/test/gapic_key_management_service_v1.ts +++ b/packages/google-cloud-kms/test/gapic_key_management_service_v1.ts @@ -19,5990 +19,7787 @@ 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 keymanagementserviceModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf, LROperation, operationsProtos, IamProtos, LocationProtos} from 'google-gax'; +import { + protobuf, + LROperation, + operationsProtos, + IamProtos, + LocationProtos, +} from 'google-gax'; // Dynamically loaded proto JSON is needed to get the type information // to fill in default values for request objects -const root = protobuf.Root.fromJSON(require('../protos/protos.json')).resolveAll(); +const root = protobuf.Root.fromJSON( + require('../protos/protos.json'), +).resolveAll(); // eslint-disable-next-line @typescript-eslint/no-unused-vars function getTypeDefaultValue(typeName: string, fields: string[]) { - let type = root.lookupType(typeName) as protobuf.Type; - for (const field of fields.slice(0, -1)) { - type = type.fields[field]?.resolvedType as protobuf.Type; - } - return type.fields[fields[fields.length - 1]]?.defaultValue; + let type = root.lookupType(typeName) as protobuf.Type; + for (const field of fields.slice(0, -1)) { + type = type.fields[field]?.resolvedType as protobuf.Type; + } + return type.fields[fields[fields.length - 1]]?.defaultValue; } function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, { defaults: true }); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject, + ) as T; } function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); } -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error, +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); } -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +function stubLongRunningCall( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().rejects(callError) + : sinon.stub().resolves([mockOperation]); } -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +function stubLongRunningCallWithCallback( + response?: ResponseType, + callError?: Error, + lroError?: Error, +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().callsArgWith(2, callError) + : sinon.stub().callsArgWith(2, null, mockOperation); } -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error, +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); } - return sinon.stub().returns(mockStream); + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + return sinon.stub().returns(mockStream); } -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); +function stubAsyncIterationCall( + responses?: ResponseType[], + error?: Error, +) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({ done: true, value: undefined }); + } + return Promise.resolve({ done: false, value: responses![counter++] }); + }, + }; + }, + }; + return sinon.stub().returns(asyncIterable); } describe('v1.KeyManagementServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'cloudkms.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient(); - 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 = keymanagementserviceModule.v1.KeyManagementServiceClient.servicePath; - assert.strictEqual(servicePath, 'cloudkms.googleapis.com'); - assert(stub.called); - stub.restore(); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'cloudkms.googleapis.com'); + }); - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = keymanagementserviceModule.v1.KeyManagementServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'cloudkms.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudkms.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudkms.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 keymanagementserviceModule.v1.KeyManagementServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudkms.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 keymanagementserviceModule.v1.KeyManagementServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudkms.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 keymanagementserviceModule.v1.KeyManagementServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); + it('has universeDomain', () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('has port', () => { - const port = keymanagementserviceModule.v1.KeyManagementServiceClient.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 = + keymanagementserviceModule.v1.KeyManagementServiceClient.servicePath; + assert.strictEqual(servicePath, 'cloudkms.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + keymanagementserviceModule.v1.KeyManagementServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'cloudkms.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + universeDomain: 'example.com', }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudkms.example.com'); + }); - it('should create a client with no option', () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient(); - assert(client); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + universe_domain: 'example.com', }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudkms.example.com'); + }); - it('should create a client with gRPC fallback', () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - 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 keymanagementserviceModule.v1.KeyManagementServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudkms.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 keymanagementserviceModule.v1.KeyManagementServiceClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudkms.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 keymanagementserviceModule.v1.KeyManagementServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.keyManagementServiceStub, undefined); - await client.initialize(); - assert(client.keyManagementServiceStub); - }); + it('has port', () => { + const port = + keymanagementserviceModule.v1.KeyManagementServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has close method for the initialized client', done => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.keyManagementServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('should create a client with no option', () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + fallback: true, }); + assert(client); + }); - it('has close method for the non-initialized client', done => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.keyManagementServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('has initialize method and supports deferred initialization', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + assert.strictEqual(client.keyManagementServiceStub, undefined); + await client.initialize(); + assert(client.keyManagementServiceStub); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - 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 keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.keyManagementServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - 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 keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.keyManagementServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('getKeyRing', () => { - it('invokes getKeyRing without error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.GetKeyRingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.GetKeyRingRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.KeyRing() - ); - client.innerApiCalls.getKeyRing = stubSimpleCall(expectedResponse); - const [response] = await client.getKeyRing(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getKeyRing as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getKeyRing as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getKeyRing without error using callback', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.GetKeyRingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.GetKeyRingRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.KeyRing() - ); - client.innerApiCalls.getKeyRing = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getKeyRing( - request, - (err?: Error|null, result?: protos.google.cloud.kms.v1.IKeyRing|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getKeyRing as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getKeyRing as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getKeyRing with error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.GetKeyRingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.GetKeyRingRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getKeyRing = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getKeyRing(request), expectedError); - const actualRequest = (client.innerApiCalls.getKeyRing as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getKeyRing as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getKeyRing with closed client', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.GetKeyRingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.GetKeyRingRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getKeyRing(request), expectedError); - }); - }); - - describe('getCryptoKey', () => { - it('invokes getCryptoKey without error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.GetCryptoKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.GetCryptoKeyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.CryptoKey() - ); - client.innerApiCalls.getCryptoKey = stubSimpleCall(expectedResponse); - const [response] = await client.getCryptoKey(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getCryptoKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCryptoKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getCryptoKey without error using callback', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.GetCryptoKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.GetCryptoKeyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.CryptoKey() - ); - client.innerApiCalls.getCryptoKey = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getCryptoKey( - request, - (err?: Error|null, result?: protos.google.cloud.kms.v1.ICryptoKey|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getCryptoKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCryptoKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getCryptoKey with error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.GetCryptoKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.GetCryptoKeyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getCryptoKey = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getCryptoKey(request), expectedError); - const actualRequest = (client.innerApiCalls.getCryptoKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCryptoKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getCryptoKey with closed client', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.GetCryptoKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.GetCryptoKeyRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getCryptoKey(request), expectedError); - }); - }); - - describe('getCryptoKeyVersion', () => { - it('invokes getCryptoKeyVersion without error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.GetCryptoKeyVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.GetCryptoKeyVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.CryptoKeyVersion() - ); - client.innerApiCalls.getCryptoKeyVersion = stubSimpleCall(expectedResponse); - const [response] = await client.getCryptoKeyVersion(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getCryptoKeyVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCryptoKeyVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getCryptoKeyVersion without error using callback', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.GetCryptoKeyVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.GetCryptoKeyVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.CryptoKeyVersion() - ); - client.innerApiCalls.getCryptoKeyVersion = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getCryptoKeyVersion( - request, - (err?: Error|null, result?: protos.google.cloud.kms.v1.ICryptoKeyVersion|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getCryptoKeyVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCryptoKeyVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getCryptoKeyVersion with error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.GetCryptoKeyVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.GetCryptoKeyVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getCryptoKeyVersion = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getCryptoKeyVersion(request), expectedError); - const actualRequest = (client.innerApiCalls.getCryptoKeyVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCryptoKeyVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getCryptoKeyVersion with closed client', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.GetCryptoKeyVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.GetCryptoKeyVersionRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getCryptoKeyVersion(request), expectedError); - }); - }); - - describe('getPublicKey', () => { - it('invokes getPublicKey without error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.GetPublicKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.GetPublicKeyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.PublicKey() - ); - client.innerApiCalls.getPublicKey = stubSimpleCall(expectedResponse); - const [response] = await client.getPublicKey(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getPublicKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getPublicKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getPublicKey without error using callback', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.GetPublicKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.GetPublicKeyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.PublicKey() - ); - client.innerApiCalls.getPublicKey = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getPublicKey( - request, - (err?: Error|null, result?: protos.google.cloud.kms.v1.IPublicKey|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getPublicKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getPublicKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getPublicKey with error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.GetPublicKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.GetPublicKeyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getPublicKey = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getPublicKey(request), expectedError); - const actualRequest = (client.innerApiCalls.getPublicKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getPublicKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getPublicKey with closed client', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.GetPublicKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.GetPublicKeyRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getPublicKey(request), expectedError); - }); - }); - - describe('getImportJob', () => { - it('invokes getImportJob without error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.GetImportJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.GetImportJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.ImportJob() - ); - client.innerApiCalls.getImportJob = stubSimpleCall(expectedResponse); - const [response] = await client.getImportJob(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getImportJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getImportJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getImportJob without error using callback', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.GetImportJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.GetImportJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.ImportJob() - ); - client.innerApiCalls.getImportJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getImportJob( - request, - (err?: Error|null, result?: protos.google.cloud.kms.v1.IImportJob|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getImportJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getImportJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getImportJob with error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.GetImportJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.GetImportJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getImportJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getImportJob(request), expectedError); - const actualRequest = (client.innerApiCalls.getImportJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getImportJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getImportJob with closed client', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.GetImportJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.GetImportJobRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getImportJob(request), expectedError); - }); - }); - - describe('getRetiredResource', () => { - it('invokes getRetiredResource without error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.GetRetiredResourceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.GetRetiredResourceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.RetiredResource() - ); - client.innerApiCalls.getRetiredResource = stubSimpleCall(expectedResponse); - const [response] = await client.getRetiredResource(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getRetiredResource as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getRetiredResource as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getRetiredResource without error using callback', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.GetRetiredResourceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.GetRetiredResourceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.RetiredResource() - ); - client.innerApiCalls.getRetiredResource = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getRetiredResource( - request, - (err?: Error|null, result?: protos.google.cloud.kms.v1.IRetiredResource|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getRetiredResource as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getRetiredResource as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getRetiredResource with error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.GetRetiredResourceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.GetRetiredResourceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getRetiredResource = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getRetiredResource(request), expectedError); - const actualRequest = (client.innerApiCalls.getRetiredResource as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getRetiredResource as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getRetiredResource with closed client', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.GetRetiredResourceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.GetRetiredResourceRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getRetiredResource(request), expectedError); - }); - }); - - describe('createKeyRing', () => { - it('invokes createKeyRing without error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.CreateKeyRingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.CreateKeyRingRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.KeyRing() - ); - client.innerApiCalls.createKeyRing = stubSimpleCall(expectedResponse); - const [response] = await client.createKeyRing(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createKeyRing as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createKeyRing as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createKeyRing without error using callback', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.CreateKeyRingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.CreateKeyRingRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.KeyRing() - ); - client.innerApiCalls.createKeyRing = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createKeyRing( - request, - (err?: Error|null, result?: protos.google.cloud.kms.v1.IKeyRing|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createKeyRing as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createKeyRing as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createKeyRing with error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.CreateKeyRingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.CreateKeyRingRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createKeyRing = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createKeyRing(request), expectedError); - const actualRequest = (client.innerApiCalls.createKeyRing as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createKeyRing as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createKeyRing with closed client', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.CreateKeyRingRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.CreateKeyRingRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.createKeyRing(request), expectedError); - }); - }); - - describe('createCryptoKey', () => { - it('invokes createCryptoKey without error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.CreateCryptoKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.CreateCryptoKeyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.CryptoKey() - ); - client.innerApiCalls.createCryptoKey = stubSimpleCall(expectedResponse); - const [response] = await client.createCryptoKey(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createCryptoKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCryptoKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createCryptoKey without error using callback', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.CreateCryptoKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.CreateCryptoKeyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.CryptoKey() - ); - client.innerApiCalls.createCryptoKey = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createCryptoKey( - request, - (err?: Error|null, result?: protos.google.cloud.kms.v1.ICryptoKey|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createCryptoKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCryptoKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createCryptoKey with error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.CreateCryptoKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.CreateCryptoKeyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createCryptoKey = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createCryptoKey(request), expectedError); - const actualRequest = (client.innerApiCalls.createCryptoKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCryptoKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createCryptoKey with closed client', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.CreateCryptoKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.CreateCryptoKeyRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.createCryptoKey(request), expectedError); - }); - }); - - describe('createCryptoKeyVersion', () => { - it('invokes createCryptoKeyVersion without error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.CreateCryptoKeyVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.CreateCryptoKeyVersionRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.CryptoKeyVersion() - ); - client.innerApiCalls.createCryptoKeyVersion = stubSimpleCall(expectedResponse); - const [response] = await client.createCryptoKeyVersion(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createCryptoKeyVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCryptoKeyVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createCryptoKeyVersion without error using callback', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.CreateCryptoKeyVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.CreateCryptoKeyVersionRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.CryptoKeyVersion() - ); - client.innerApiCalls.createCryptoKeyVersion = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createCryptoKeyVersion( - request, - (err?: Error|null, result?: protos.google.cloud.kms.v1.ICryptoKeyVersion|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createCryptoKeyVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCryptoKeyVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createCryptoKeyVersion with error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.CreateCryptoKeyVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.CreateCryptoKeyVersionRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createCryptoKeyVersion = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createCryptoKeyVersion(request), expectedError); - const actualRequest = (client.innerApiCalls.createCryptoKeyVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCryptoKeyVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createCryptoKeyVersion with closed client', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.CreateCryptoKeyVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.CreateCryptoKeyVersionRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.createCryptoKeyVersion(request), expectedError); - }); - }); - - describe('importCryptoKeyVersion', () => { - it('invokes importCryptoKeyVersion without error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ImportCryptoKeyVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ImportCryptoKeyVersionRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.CryptoKeyVersion() - ); - client.innerApiCalls.importCryptoKeyVersion = stubSimpleCall(expectedResponse); - const [response] = await client.importCryptoKeyVersion(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.importCryptoKeyVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importCryptoKeyVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes importCryptoKeyVersion without error using callback', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ImportCryptoKeyVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ImportCryptoKeyVersionRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.CryptoKeyVersion() - ); - client.innerApiCalls.importCryptoKeyVersion = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.importCryptoKeyVersion( - request, - (err?: Error|null, result?: protos.google.cloud.kms.v1.ICryptoKeyVersion|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.importCryptoKeyVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importCryptoKeyVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes importCryptoKeyVersion with error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ImportCryptoKeyVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ImportCryptoKeyVersionRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.importCryptoKeyVersion = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.importCryptoKeyVersion(request), expectedError); - const actualRequest = (client.innerApiCalls.importCryptoKeyVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.importCryptoKeyVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes importCryptoKeyVersion with closed client', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ImportCryptoKeyVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ImportCryptoKeyVersionRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.importCryptoKeyVersion(request), expectedError); - }); - }); - - describe('createImportJob', () => { - it('invokes createImportJob without error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.CreateImportJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.CreateImportJobRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.ImportJob() - ); - client.innerApiCalls.createImportJob = stubSimpleCall(expectedResponse); - const [response] = await client.createImportJob(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createImportJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createImportJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createImportJob without error using callback', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.CreateImportJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.CreateImportJobRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.ImportJob() - ); - client.innerApiCalls.createImportJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createImportJob( - request, - (err?: Error|null, result?: protos.google.cloud.kms.v1.IImportJob|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createImportJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createImportJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createImportJob with error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.CreateImportJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.CreateImportJobRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createImportJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createImportJob(request), expectedError); - const actualRequest = (client.innerApiCalls.createImportJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createImportJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createImportJob with closed client', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.CreateImportJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.CreateImportJobRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.createImportJob(request), expectedError); - }); - }); - - describe('updateCryptoKey', () => { - it('invokes updateCryptoKey without error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.UpdateCryptoKeyRequest() - ); - request.cryptoKey ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.UpdateCryptoKeyRequest', ['cryptoKey', 'name']); - request.cryptoKey.name = defaultValue1; - const expectedHeaderRequestParams = `crypto_key.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.CryptoKey() - ); - client.innerApiCalls.updateCryptoKey = stubSimpleCall(expectedResponse); - const [response] = await client.updateCryptoKey(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateCryptoKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCryptoKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateCryptoKey without error using callback', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.UpdateCryptoKeyRequest() - ); - request.cryptoKey ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.UpdateCryptoKeyRequest', ['cryptoKey', 'name']); - request.cryptoKey.name = defaultValue1; - const expectedHeaderRequestParams = `crypto_key.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.CryptoKey() - ); - client.innerApiCalls.updateCryptoKey = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateCryptoKey( - request, - (err?: Error|null, result?: protos.google.cloud.kms.v1.ICryptoKey|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateCryptoKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCryptoKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateCryptoKey with error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.UpdateCryptoKeyRequest() - ); - request.cryptoKey ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.UpdateCryptoKeyRequest', ['cryptoKey', 'name']); - request.cryptoKey.name = defaultValue1; - const expectedHeaderRequestParams = `crypto_key.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateCryptoKey = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateCryptoKey(request), expectedError); - const actualRequest = (client.innerApiCalls.updateCryptoKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCryptoKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateCryptoKey with closed client', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.UpdateCryptoKeyRequest() - ); - request.cryptoKey ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.UpdateCryptoKeyRequest', ['cryptoKey', 'name']); - request.cryptoKey.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.updateCryptoKey(request), expectedError); - }); - }); - - describe('updateCryptoKeyVersion', () => { - it('invokes updateCryptoKeyVersion without error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.UpdateCryptoKeyVersionRequest() - ); - request.cryptoKeyVersion ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.UpdateCryptoKeyVersionRequest', ['cryptoKeyVersion', 'name']); - request.cryptoKeyVersion.name = defaultValue1; - const expectedHeaderRequestParams = `crypto_key_version.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.CryptoKeyVersion() - ); - client.innerApiCalls.updateCryptoKeyVersion = stubSimpleCall(expectedResponse); - const [response] = await client.updateCryptoKeyVersion(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateCryptoKeyVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCryptoKeyVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateCryptoKeyVersion without error using callback', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.UpdateCryptoKeyVersionRequest() - ); - request.cryptoKeyVersion ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.UpdateCryptoKeyVersionRequest', ['cryptoKeyVersion', 'name']); - request.cryptoKeyVersion.name = defaultValue1; - const expectedHeaderRequestParams = `crypto_key_version.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.CryptoKeyVersion() - ); - client.innerApiCalls.updateCryptoKeyVersion = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateCryptoKeyVersion( - request, - (err?: Error|null, result?: protos.google.cloud.kms.v1.ICryptoKeyVersion|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateCryptoKeyVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCryptoKeyVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateCryptoKeyVersion with error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.UpdateCryptoKeyVersionRequest() - ); - request.cryptoKeyVersion ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.UpdateCryptoKeyVersionRequest', ['cryptoKeyVersion', 'name']); - request.cryptoKeyVersion.name = defaultValue1; - const expectedHeaderRequestParams = `crypto_key_version.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateCryptoKeyVersion = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateCryptoKeyVersion(request), expectedError); - const actualRequest = (client.innerApiCalls.updateCryptoKeyVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCryptoKeyVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateCryptoKeyVersion with closed client', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.UpdateCryptoKeyVersionRequest() - ); - request.cryptoKeyVersion ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.UpdateCryptoKeyVersionRequest', ['cryptoKeyVersion', 'name']); - request.cryptoKeyVersion.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.updateCryptoKeyVersion(request), expectedError); - }); - }); - - describe('updateCryptoKeyPrimaryVersion', () => { - it('invokes updateCryptoKeyPrimaryVersion without error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.UpdateCryptoKeyPrimaryVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.UpdateCryptoKeyPrimaryVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.CryptoKey() - ); - client.innerApiCalls.updateCryptoKeyPrimaryVersion = stubSimpleCall(expectedResponse); - const [response] = await client.updateCryptoKeyPrimaryVersion(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateCryptoKeyPrimaryVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCryptoKeyPrimaryVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateCryptoKeyPrimaryVersion without error using callback', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.UpdateCryptoKeyPrimaryVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.UpdateCryptoKeyPrimaryVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.CryptoKey() - ); - client.innerApiCalls.updateCryptoKeyPrimaryVersion = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateCryptoKeyPrimaryVersion( - request, - (err?: Error|null, result?: protos.google.cloud.kms.v1.ICryptoKey|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateCryptoKeyPrimaryVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCryptoKeyPrimaryVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateCryptoKeyPrimaryVersion with error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.UpdateCryptoKeyPrimaryVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.UpdateCryptoKeyPrimaryVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateCryptoKeyPrimaryVersion = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateCryptoKeyPrimaryVersion(request), expectedError); - const actualRequest = (client.innerApiCalls.updateCryptoKeyPrimaryVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCryptoKeyPrimaryVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateCryptoKeyPrimaryVersion with closed client', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.UpdateCryptoKeyPrimaryVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.UpdateCryptoKeyPrimaryVersionRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.updateCryptoKeyPrimaryVersion(request), expectedError); - }); - }); - - describe('destroyCryptoKeyVersion', () => { - it('invokes destroyCryptoKeyVersion without error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.DestroyCryptoKeyVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.DestroyCryptoKeyVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.CryptoKeyVersion() - ); - client.innerApiCalls.destroyCryptoKeyVersion = stubSimpleCall(expectedResponse); - const [response] = await client.destroyCryptoKeyVersion(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.destroyCryptoKeyVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.destroyCryptoKeyVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes destroyCryptoKeyVersion without error using callback', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.DestroyCryptoKeyVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.DestroyCryptoKeyVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.CryptoKeyVersion() - ); - client.innerApiCalls.destroyCryptoKeyVersion = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.destroyCryptoKeyVersion( - request, - (err?: Error|null, result?: protos.google.cloud.kms.v1.ICryptoKeyVersion|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.destroyCryptoKeyVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.destroyCryptoKeyVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes destroyCryptoKeyVersion with error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.DestroyCryptoKeyVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.DestroyCryptoKeyVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.destroyCryptoKeyVersion = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.destroyCryptoKeyVersion(request), expectedError); - const actualRequest = (client.innerApiCalls.destroyCryptoKeyVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.destroyCryptoKeyVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes destroyCryptoKeyVersion with closed client', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.DestroyCryptoKeyVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.DestroyCryptoKeyVersionRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.destroyCryptoKeyVersion(request), expectedError); - }); - }); - - describe('restoreCryptoKeyVersion', () => { - it('invokes restoreCryptoKeyVersion without error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.RestoreCryptoKeyVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.RestoreCryptoKeyVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.CryptoKeyVersion() - ); - client.innerApiCalls.restoreCryptoKeyVersion = stubSimpleCall(expectedResponse); - const [response] = await client.restoreCryptoKeyVersion(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.restoreCryptoKeyVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.restoreCryptoKeyVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes restoreCryptoKeyVersion without error using callback', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.RestoreCryptoKeyVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.RestoreCryptoKeyVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.CryptoKeyVersion() - ); - client.innerApiCalls.restoreCryptoKeyVersion = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.restoreCryptoKeyVersion( - request, - (err?: Error|null, result?: protos.google.cloud.kms.v1.ICryptoKeyVersion|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.restoreCryptoKeyVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.restoreCryptoKeyVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes restoreCryptoKeyVersion with error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.RestoreCryptoKeyVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.RestoreCryptoKeyVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.restoreCryptoKeyVersion = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.restoreCryptoKeyVersion(request), expectedError); - const actualRequest = (client.innerApiCalls.restoreCryptoKeyVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.restoreCryptoKeyVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes restoreCryptoKeyVersion with closed client', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.RestoreCryptoKeyVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.RestoreCryptoKeyVersionRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.restoreCryptoKeyVersion(request), expectedError); - }); - }); - - describe('encrypt', () => { - it('invokes encrypt without error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.EncryptRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.EncryptRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.EncryptResponse() - ); - client.innerApiCalls.encrypt = stubSimpleCall(expectedResponse); - const [response] = await client.encrypt(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.encrypt as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.encrypt as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes encrypt without error using callback', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.EncryptRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.EncryptRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.EncryptResponse() - ); - client.innerApiCalls.encrypt = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.encrypt( - request, - (err?: Error|null, result?: protos.google.cloud.kms.v1.IEncryptResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.encrypt as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.encrypt as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes encrypt with error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.EncryptRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.EncryptRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.encrypt = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.encrypt(request), expectedError); - const actualRequest = (client.innerApiCalls.encrypt as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.encrypt as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes encrypt with closed client', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.EncryptRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.EncryptRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.encrypt(request), expectedError); - }); - }); - - describe('decrypt', () => { - it('invokes decrypt without error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.DecryptRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.DecryptRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.DecryptResponse() - ); - client.innerApiCalls.decrypt = stubSimpleCall(expectedResponse); - const [response] = await client.decrypt(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.decrypt as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.decrypt as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes decrypt without error using callback', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.DecryptRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.DecryptRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.DecryptResponse() - ); - client.innerApiCalls.decrypt = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.decrypt( - request, - (err?: Error|null, result?: protos.google.cloud.kms.v1.IDecryptResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.decrypt as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.decrypt as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes decrypt with error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.DecryptRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.DecryptRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.decrypt = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.decrypt(request), expectedError); - const actualRequest = (client.innerApiCalls.decrypt as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.decrypt as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes decrypt with closed client', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.DecryptRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.DecryptRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.decrypt(request), expectedError); - }); - }); - - describe('rawEncrypt', () => { - it('invokes rawEncrypt without error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.RawEncryptRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.RawEncryptRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.RawEncryptResponse() - ); - client.innerApiCalls.rawEncrypt = stubSimpleCall(expectedResponse); - const [response] = await client.rawEncrypt(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.rawEncrypt as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rawEncrypt as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes rawEncrypt without error using callback', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.RawEncryptRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.RawEncryptRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.RawEncryptResponse() - ); - client.innerApiCalls.rawEncrypt = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.rawEncrypt( - request, - (err?: Error|null, result?: protos.google.cloud.kms.v1.IRawEncryptResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.rawEncrypt as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rawEncrypt as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes rawEncrypt with error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.RawEncryptRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.RawEncryptRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.rawEncrypt = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.rawEncrypt(request), expectedError); - const actualRequest = (client.innerApiCalls.rawEncrypt as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rawEncrypt as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes rawEncrypt with closed client', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.RawEncryptRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.RawEncryptRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.rawEncrypt(request), expectedError); - }); - }); - - describe('rawDecrypt', () => { - it('invokes rawDecrypt without error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.RawDecryptRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.RawDecryptRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.RawDecryptResponse() - ); - client.innerApiCalls.rawDecrypt = stubSimpleCall(expectedResponse); - const [response] = await client.rawDecrypt(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.rawDecrypt as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rawDecrypt as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes rawDecrypt without error using callback', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.RawDecryptRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.RawDecryptRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.RawDecryptResponse() - ); - client.innerApiCalls.rawDecrypt = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.rawDecrypt( - request, - (err?: Error|null, result?: protos.google.cloud.kms.v1.IRawDecryptResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.rawDecrypt as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rawDecrypt as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes rawDecrypt with error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.RawDecryptRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.RawDecryptRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.rawDecrypt = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.rawDecrypt(request), expectedError); - const actualRequest = (client.innerApiCalls.rawDecrypt as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rawDecrypt as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes rawDecrypt with closed client', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.RawDecryptRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.RawDecryptRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.rawDecrypt(request), expectedError); - }); - }); - - describe('asymmetricSign', () => { - it('invokes asymmetricSign without error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.AsymmetricSignRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.AsymmetricSignRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.AsymmetricSignResponse() - ); - client.innerApiCalls.asymmetricSign = stubSimpleCall(expectedResponse); - const [response] = await client.asymmetricSign(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.asymmetricSign as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.asymmetricSign as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes asymmetricSign without error using callback', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.AsymmetricSignRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.AsymmetricSignRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.AsymmetricSignResponse() - ); - client.innerApiCalls.asymmetricSign = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.asymmetricSign( - request, - (err?: Error|null, result?: protos.google.cloud.kms.v1.IAsymmetricSignResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.asymmetricSign as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.asymmetricSign as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes asymmetricSign with error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.AsymmetricSignRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.AsymmetricSignRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.asymmetricSign = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.asymmetricSign(request), expectedError); - const actualRequest = (client.innerApiCalls.asymmetricSign as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.asymmetricSign as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes asymmetricSign with closed client', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.AsymmetricSignRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.AsymmetricSignRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.asymmetricSign(request), expectedError); - }); - }); - - describe('asymmetricDecrypt', () => { - it('invokes asymmetricDecrypt without error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.AsymmetricDecryptRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.AsymmetricDecryptRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.AsymmetricDecryptResponse() - ); - client.innerApiCalls.asymmetricDecrypt = stubSimpleCall(expectedResponse); - const [response] = await client.asymmetricDecrypt(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.asymmetricDecrypt as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.asymmetricDecrypt as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes asymmetricDecrypt without error using callback', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.AsymmetricDecryptRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.AsymmetricDecryptRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.AsymmetricDecryptResponse() - ); - client.innerApiCalls.asymmetricDecrypt = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.asymmetricDecrypt( - request, - (err?: Error|null, result?: protos.google.cloud.kms.v1.IAsymmetricDecryptResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.asymmetricDecrypt as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.asymmetricDecrypt as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes asymmetricDecrypt with error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.AsymmetricDecryptRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.AsymmetricDecryptRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.asymmetricDecrypt = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.asymmetricDecrypt(request), expectedError); - const actualRequest = (client.innerApiCalls.asymmetricDecrypt as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.asymmetricDecrypt as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes asymmetricDecrypt with closed client', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.AsymmetricDecryptRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.AsymmetricDecryptRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.asymmetricDecrypt(request), expectedError); - }); - }); - - describe('macSign', () => { - it('invokes macSign without error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.MacSignRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.MacSignRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.MacSignResponse() - ); - client.innerApiCalls.macSign = stubSimpleCall(expectedResponse); - const [response] = await client.macSign(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.macSign as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.macSign as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes macSign without error using callback', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.MacSignRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.MacSignRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.MacSignResponse() - ); - client.innerApiCalls.macSign = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.macSign( - request, - (err?: Error|null, result?: protos.google.cloud.kms.v1.IMacSignResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.macSign as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.macSign as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes macSign with error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.MacSignRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.MacSignRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.macSign = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.macSign(request), expectedError); - const actualRequest = (client.innerApiCalls.macSign as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.macSign as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes macSign with closed client', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.MacSignRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.MacSignRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.macSign(request), expectedError); - }); - }); - - describe('macVerify', () => { - it('invokes macVerify without error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.MacVerifyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.MacVerifyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.MacVerifyResponse() - ); - client.innerApiCalls.macVerify = stubSimpleCall(expectedResponse); - const [response] = await client.macVerify(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.macVerify as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.macVerify as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes macVerify without error using callback', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.MacVerifyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.MacVerifyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.MacVerifyResponse() - ); - client.innerApiCalls.macVerify = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.macVerify( - request, - (err?: Error|null, result?: protos.google.cloud.kms.v1.IMacVerifyResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.macVerify as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.macVerify as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes macVerify with error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.MacVerifyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.MacVerifyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.macVerify = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.macVerify(request), expectedError); - const actualRequest = (client.innerApiCalls.macVerify as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.macVerify as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes macVerify with closed client', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.MacVerifyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.MacVerifyRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.macVerify(request), expectedError); - }); - }); - - describe('decapsulate', () => { - it('invokes decapsulate without error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.DecapsulateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.DecapsulateRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.DecapsulateResponse() - ); - client.innerApiCalls.decapsulate = stubSimpleCall(expectedResponse); - const [response] = await client.decapsulate(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.decapsulate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.decapsulate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes decapsulate without error using callback', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.DecapsulateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.DecapsulateRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.DecapsulateResponse() - ); - client.innerApiCalls.decapsulate = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.decapsulate( - request, - (err?: Error|null, result?: protos.google.cloud.kms.v1.IDecapsulateResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.decapsulate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.decapsulate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes decapsulate with error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.DecapsulateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.DecapsulateRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.decapsulate = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.decapsulate(request), expectedError); - const actualRequest = (client.innerApiCalls.decapsulate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.decapsulate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes decapsulate with closed client', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.DecapsulateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.DecapsulateRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.decapsulate(request), expectedError); - }); - }); - - describe('generateRandomBytes', () => { - it('invokes generateRandomBytes without error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.GenerateRandomBytesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.GenerateRandomBytesRequest', ['location']); - request.location = defaultValue1; - const expectedHeaderRequestParams = `location=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.GenerateRandomBytesResponse() - ); - client.innerApiCalls.generateRandomBytes = stubSimpleCall(expectedResponse); - const [response] = await client.generateRandomBytes(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.generateRandomBytes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.generateRandomBytes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes generateRandomBytes without error using callback', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.GenerateRandomBytesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.GenerateRandomBytesRequest', ['location']); - request.location = defaultValue1; - const expectedHeaderRequestParams = `location=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.kms.v1.GenerateRandomBytesResponse() - ); - client.innerApiCalls.generateRandomBytes = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.generateRandomBytes( - request, - (err?: Error|null, result?: protos.google.cloud.kms.v1.IGenerateRandomBytesResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.generateRandomBytes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.generateRandomBytes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes generateRandomBytes with error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.GenerateRandomBytesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.GenerateRandomBytesRequest', ['location']); - request.location = defaultValue1; - const expectedHeaderRequestParams = `location=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.generateRandomBytes = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.generateRandomBytes(request), expectedError); - const actualRequest = (client.innerApiCalls.generateRandomBytes as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.generateRandomBytes as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes generateRandomBytes with closed client', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.GenerateRandomBytesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.GenerateRandomBytesRequest', ['location']); - request.location = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.generateRandomBytes(request), expectedError); - }); - }); - - describe('deleteCryptoKey', () => { - it('invokes deleteCryptoKey without error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.DeleteCryptoKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.DeleteCryptoKeyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteCryptoKey = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteCryptoKey(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteCryptoKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteCryptoKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteCryptoKey without error using callback', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.DeleteCryptoKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.DeleteCryptoKeyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteCryptoKey = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteCryptoKey( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteCryptoKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteCryptoKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteCryptoKey with call error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.DeleteCryptoKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.DeleteCryptoKeyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteCryptoKey = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteCryptoKey(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteCryptoKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteCryptoKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteCryptoKey with LRO error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.DeleteCryptoKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.DeleteCryptoKeyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteCryptoKey = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteCryptoKey(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteCryptoKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteCryptoKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteCryptoKeyProgress without error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteCryptoKeyProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteCryptoKeyProgress with error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - 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 keymanagementserviceModule.v1.KeyManagementServiceClient({ + 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.checkDeleteCryptoKeyProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + 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('getKeyRing', () => { + it('invokes getKeyRing without error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.GetKeyRingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.GetKeyRingRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.KeyRing(), + ); + client.innerApiCalls.getKeyRing = stubSimpleCall(expectedResponse); + const [response] = await client.getKeyRing(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getKeyRing as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getKeyRing as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteCryptoKeyVersion', () => { - it('invokes deleteCryptoKeyVersion without error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.DeleteCryptoKeyVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.DeleteCryptoKeyVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteCryptoKeyVersion = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteCryptoKeyVersion(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteCryptoKeyVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteCryptoKeyVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteCryptoKeyVersion without error using callback', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.DeleteCryptoKeyVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.DeleteCryptoKeyVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteCryptoKeyVersion = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteCryptoKeyVersion( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteCryptoKeyVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteCryptoKeyVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteCryptoKeyVersion with call error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.DeleteCryptoKeyVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.DeleteCryptoKeyVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteCryptoKeyVersion = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteCryptoKeyVersion(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteCryptoKeyVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteCryptoKeyVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteCryptoKeyVersion with LRO error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.DeleteCryptoKeyVersionRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.DeleteCryptoKeyVersionRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteCryptoKeyVersion = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteCryptoKeyVersion(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteCryptoKeyVersion as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteCryptoKeyVersion as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkDeleteCryptoKeyVersionProgress without error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteCryptoKeyVersionProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkDeleteCryptoKeyVersionProgress with error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); + it('invokes getKeyRing without error using callback', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.GetKeyRingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.GetKeyRingRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.KeyRing(), + ); + client.innerApiCalls.getKeyRing = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getKeyRing( + request, + ( + err?: Error | null, + result?: protos.google.cloud.kms.v1.IKeyRing | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getKeyRing as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getKeyRing as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteCryptoKeyVersionProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes getKeyRing with error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.GetKeyRingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.GetKeyRingRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getKeyRing = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getKeyRing(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getKeyRing as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getKeyRing as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listKeyRings', () => { - it('invokes listKeyRings without error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListKeyRingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListKeyRingsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.kms.v1.KeyRing()), - generateSampleMessage(new protos.google.cloud.kms.v1.KeyRing()), - generateSampleMessage(new protos.google.cloud.kms.v1.KeyRing()), - ]; - client.innerApiCalls.listKeyRings = stubSimpleCall(expectedResponse); - const [response] = await client.listKeyRings(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listKeyRings as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listKeyRings as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listKeyRings without error using callback', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListKeyRingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListKeyRingsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.kms.v1.KeyRing()), - generateSampleMessage(new protos.google.cloud.kms.v1.KeyRing()), - generateSampleMessage(new protos.google.cloud.kms.v1.KeyRing()), - ]; - client.innerApiCalls.listKeyRings = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listKeyRings( - request, - (err?: Error|null, result?: protos.google.cloud.kms.v1.IKeyRing[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listKeyRings as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listKeyRings as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listKeyRings with error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListKeyRingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListKeyRingsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listKeyRings = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listKeyRings(request), expectedError); - const actualRequest = (client.innerApiCalls.listKeyRings as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listKeyRings as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listKeyRingsStream without error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListKeyRingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListKeyRingsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.kms.v1.KeyRing()), - generateSampleMessage(new protos.google.cloud.kms.v1.KeyRing()), - generateSampleMessage(new protos.google.cloud.kms.v1.KeyRing()), - ]; - client.descriptors.page.listKeyRings.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listKeyRingsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.kms.v1.KeyRing[] = []; - stream.on('data', (response: protos.google.cloud.kms.v1.KeyRing) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listKeyRings.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listKeyRings, request)); - assert( - (client.descriptors.page.listKeyRings.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listKeyRingsStream with error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListKeyRingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListKeyRingsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listKeyRings.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listKeyRingsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.kms.v1.KeyRing[] = []; - stream.on('data', (response: protos.google.cloud.kms.v1.KeyRing) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listKeyRings.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listKeyRings, request)); - assert( - (client.descriptors.page.listKeyRings.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listKeyRings without error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListKeyRingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListKeyRingsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.kms.v1.KeyRing()), - generateSampleMessage(new protos.google.cloud.kms.v1.KeyRing()), - generateSampleMessage(new protos.google.cloud.kms.v1.KeyRing()), - ]; - client.descriptors.page.listKeyRings.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.kms.v1.IKeyRing[] = []; - const iterable = client.listKeyRingsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes getKeyRing with closed client', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.GetKeyRingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.GetKeyRingRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getKeyRing(request), expectedError); + }); + }); + + describe('getCryptoKey', () => { + it('invokes getCryptoKey without error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.GetCryptoKeyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.GetCryptoKeyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.CryptoKey(), + ); + client.innerApiCalls.getCryptoKey = stubSimpleCall(expectedResponse); + const [response] = await client.getCryptoKey(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getCryptoKey as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCryptoKey as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getCryptoKey without error using callback', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.GetCryptoKeyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.GetCryptoKeyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.CryptoKey(), + ); + client.innerApiCalls.getCryptoKey = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getCryptoKey( + request, + ( + err?: Error | null, + result?: protos.google.cloud.kms.v1.ICryptoKey | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listKeyRings.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listKeyRings.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listKeyRings with error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListKeyRingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListKeyRingsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listKeyRings.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listKeyRingsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.kms.v1.IKeyRing[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listKeyRings.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listKeyRings.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listCryptoKeys', () => { - it('invokes listCryptoKeys without error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListCryptoKeysRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListCryptoKeysRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKey()), - generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKey()), - generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKey()), - ]; - client.innerApiCalls.listCryptoKeys = stubSimpleCall(expectedResponse); - const [response] = await client.listCryptoKeys(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listCryptoKeys as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCryptoKeys as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listCryptoKeys without error using callback', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListCryptoKeysRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListCryptoKeysRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKey()), - generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKey()), - generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKey()), - ]; - client.innerApiCalls.listCryptoKeys = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listCryptoKeys( - request, - (err?: Error|null, result?: protos.google.cloud.kms.v1.ICryptoKey[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listCryptoKeys as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCryptoKeys as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listCryptoKeys with error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListCryptoKeysRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListCryptoKeysRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listCryptoKeys = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listCryptoKeys(request), expectedError); - const actualRequest = (client.innerApiCalls.listCryptoKeys as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCryptoKeys as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listCryptoKeysStream without error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListCryptoKeysRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListCryptoKeysRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKey()), - generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKey()), - generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKey()), - ]; - client.descriptors.page.listCryptoKeys.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listCryptoKeysStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.kms.v1.CryptoKey[] = []; - stream.on('data', (response: protos.google.cloud.kms.v1.CryptoKey) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listCryptoKeys.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listCryptoKeys, request)); - assert( - (client.descriptors.page.listCryptoKeys.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listCryptoKeysStream with error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListCryptoKeysRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListCryptoKeysRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listCryptoKeys.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listCryptoKeysStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.kms.v1.CryptoKey[] = []; - stream.on('data', (response: protos.google.cloud.kms.v1.CryptoKey) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listCryptoKeys.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listCryptoKeys, request)); - assert( - (client.descriptors.page.listCryptoKeys.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listCryptoKeys without error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListCryptoKeysRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListCryptoKeysRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKey()), - generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKey()), - generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKey()), - ]; - client.descriptors.page.listCryptoKeys.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.kms.v1.ICryptoKey[] = []; - const iterable = client.listCryptoKeysAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getCryptoKey as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCryptoKey as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getCryptoKey with error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.GetCryptoKeyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.GetCryptoKeyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getCryptoKey = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getCryptoKey(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getCryptoKey as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCryptoKey as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getCryptoKey with closed client', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.GetCryptoKeyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.GetCryptoKeyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getCryptoKey(request), expectedError); + }); + }); + + describe('getCryptoKeyVersion', () => { + it('invokes getCryptoKeyVersion without error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.GetCryptoKeyVersionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.GetCryptoKeyVersionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.CryptoKeyVersion(), + ); + client.innerApiCalls.getCryptoKeyVersion = + stubSimpleCall(expectedResponse); + const [response] = await client.getCryptoKeyVersion(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getCryptoKeyVersion as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCryptoKeyVersion as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getCryptoKeyVersion without error using callback', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.GetCryptoKeyVersionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.GetCryptoKeyVersionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.CryptoKeyVersion(), + ); + client.innerApiCalls.getCryptoKeyVersion = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getCryptoKeyVersion( + request, + ( + err?: Error | null, + result?: protos.google.cloud.kms.v1.ICryptoKeyVersion | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listCryptoKeys.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listCryptoKeys.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listCryptoKeys with error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListCryptoKeysRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListCryptoKeysRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listCryptoKeys.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listCryptoKeysAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.kms.v1.ICryptoKey[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listCryptoKeys.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listCryptoKeys.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listCryptoKeyVersions', () => { - it('invokes listCryptoKeyVersions without error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListCryptoKeyVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListCryptoKeyVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKeyVersion()), - generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKeyVersion()), - generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKeyVersion()), - ]; - client.innerApiCalls.listCryptoKeyVersions = stubSimpleCall(expectedResponse); - const [response] = await client.listCryptoKeyVersions(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listCryptoKeyVersions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCryptoKeyVersions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listCryptoKeyVersions without error using callback', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListCryptoKeyVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListCryptoKeyVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKeyVersion()), - generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKeyVersion()), - generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKeyVersion()), - ]; - client.innerApiCalls.listCryptoKeyVersions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listCryptoKeyVersions( - request, - (err?: Error|null, result?: protos.google.cloud.kms.v1.ICryptoKeyVersion[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listCryptoKeyVersions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCryptoKeyVersions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listCryptoKeyVersions with error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListCryptoKeyVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListCryptoKeyVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listCryptoKeyVersions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listCryptoKeyVersions(request), expectedError); - const actualRequest = (client.innerApiCalls.listCryptoKeyVersions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCryptoKeyVersions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listCryptoKeyVersionsStream without error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListCryptoKeyVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListCryptoKeyVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKeyVersion()), - generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKeyVersion()), - generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKeyVersion()), - ]; - client.descriptors.page.listCryptoKeyVersions.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listCryptoKeyVersionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.kms.v1.CryptoKeyVersion[] = []; - stream.on('data', (response: protos.google.cloud.kms.v1.CryptoKeyVersion) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listCryptoKeyVersions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listCryptoKeyVersions, request)); - assert( - (client.descriptors.page.listCryptoKeyVersions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listCryptoKeyVersionsStream with error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListCryptoKeyVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListCryptoKeyVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listCryptoKeyVersions.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listCryptoKeyVersionsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.kms.v1.CryptoKeyVersion[] = []; - stream.on('data', (response: protos.google.cloud.kms.v1.CryptoKeyVersion) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listCryptoKeyVersions.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listCryptoKeyVersions, request)); - assert( - (client.descriptors.page.listCryptoKeyVersions.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listCryptoKeyVersions without error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListCryptoKeyVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListCryptoKeyVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKeyVersion()), - generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKeyVersion()), - generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKeyVersion()), - ]; - client.descriptors.page.listCryptoKeyVersions.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.kms.v1.ICryptoKeyVersion[] = []; - const iterable = client.listCryptoKeyVersionsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getCryptoKeyVersion as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCryptoKeyVersion as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getCryptoKeyVersion with error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.GetCryptoKeyVersionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.GetCryptoKeyVersionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getCryptoKeyVersion = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getCryptoKeyVersion(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getCryptoKeyVersion as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCryptoKeyVersion as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getCryptoKeyVersion with closed client', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.GetCryptoKeyVersionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.GetCryptoKeyVersionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getCryptoKeyVersion(request), expectedError); + }); + }); + + describe('getPublicKey', () => { + it('invokes getPublicKey without error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.GetPublicKeyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.GetPublicKeyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.PublicKey(), + ); + client.innerApiCalls.getPublicKey = stubSimpleCall(expectedResponse); + const [response] = await client.getPublicKey(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getPublicKey as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getPublicKey as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getPublicKey without error using callback', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.GetPublicKeyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.GetPublicKeyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.PublicKey(), + ); + client.innerApiCalls.getPublicKey = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getPublicKey( + request, + ( + err?: Error | null, + result?: protos.google.cloud.kms.v1.IPublicKey | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listCryptoKeyVersions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listCryptoKeyVersions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listCryptoKeyVersions with error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListCryptoKeyVersionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListCryptoKeyVersionsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listCryptoKeyVersions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listCryptoKeyVersionsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.kms.v1.ICryptoKeyVersion[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listCryptoKeyVersions.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listCryptoKeyVersions.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listImportJobs', () => { - it('invokes listImportJobs without error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListImportJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListImportJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.kms.v1.ImportJob()), - generateSampleMessage(new protos.google.cloud.kms.v1.ImportJob()), - generateSampleMessage(new protos.google.cloud.kms.v1.ImportJob()), - ]; - client.innerApiCalls.listImportJobs = stubSimpleCall(expectedResponse); - const [response] = await client.listImportJobs(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listImportJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listImportJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listImportJobs without error using callback', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListImportJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListImportJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.kms.v1.ImportJob()), - generateSampleMessage(new protos.google.cloud.kms.v1.ImportJob()), - generateSampleMessage(new protos.google.cloud.kms.v1.ImportJob()), - ]; - client.innerApiCalls.listImportJobs = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listImportJobs( - request, - (err?: Error|null, result?: protos.google.cloud.kms.v1.IImportJob[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listImportJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listImportJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listImportJobs with error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListImportJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListImportJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listImportJobs = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listImportJobs(request), expectedError); - const actualRequest = (client.innerApiCalls.listImportJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listImportJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listImportJobsStream without error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListImportJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListImportJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.kms.v1.ImportJob()), - generateSampleMessage(new protos.google.cloud.kms.v1.ImportJob()), - generateSampleMessage(new protos.google.cloud.kms.v1.ImportJob()), - ]; - client.descriptors.page.listImportJobs.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listImportJobsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.kms.v1.ImportJob[] = []; - stream.on('data', (response: protos.google.cloud.kms.v1.ImportJob) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listImportJobs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listImportJobs, request)); - assert( - (client.descriptors.page.listImportJobs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listImportJobsStream with error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListImportJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListImportJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listImportJobs.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listImportJobsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.kms.v1.ImportJob[] = []; - stream.on('data', (response: protos.google.cloud.kms.v1.ImportJob) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listImportJobs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listImportJobs, request)); - assert( - (client.descriptors.page.listImportJobs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listImportJobs without error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListImportJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListImportJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.kms.v1.ImportJob()), - generateSampleMessage(new protos.google.cloud.kms.v1.ImportJob()), - generateSampleMessage(new protos.google.cloud.kms.v1.ImportJob()), - ]; - client.descriptors.page.listImportJobs.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.kms.v1.IImportJob[] = []; - const iterable = client.listImportJobsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getPublicKey as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getPublicKey as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getPublicKey with error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.GetPublicKeyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.GetPublicKeyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getPublicKey = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getPublicKey(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getPublicKey as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getPublicKey as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getPublicKey with closed client', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.GetPublicKeyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.GetPublicKeyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getPublicKey(request), expectedError); + }); + }); + + describe('getImportJob', () => { + it('invokes getImportJob without error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.GetImportJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.GetImportJobRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.ImportJob(), + ); + client.innerApiCalls.getImportJob = stubSimpleCall(expectedResponse); + const [response] = await client.getImportJob(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getImportJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getImportJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getImportJob without error using callback', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.GetImportJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.GetImportJobRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.ImportJob(), + ); + client.innerApiCalls.getImportJob = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getImportJob( + request, + ( + err?: Error | null, + result?: protos.google.cloud.kms.v1.IImportJob | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listImportJobs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listImportJobs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listImportJobs with error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListImportJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListImportJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listImportJobs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listImportJobsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.kms.v1.IImportJob[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listImportJobs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listImportJobs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listRetiredResources', () => { - it('invokes listRetiredResources without error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListRetiredResourcesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListRetiredResourcesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.kms.v1.RetiredResource()), - generateSampleMessage(new protos.google.cloud.kms.v1.RetiredResource()), - generateSampleMessage(new protos.google.cloud.kms.v1.RetiredResource()), - ]; - client.innerApiCalls.listRetiredResources = stubSimpleCall(expectedResponse); - const [response] = await client.listRetiredResources(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listRetiredResources as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listRetiredResources as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listRetiredResources without error using callback', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListRetiredResourcesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListRetiredResourcesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.kms.v1.RetiredResource()), - generateSampleMessage(new protos.google.cloud.kms.v1.RetiredResource()), - generateSampleMessage(new protos.google.cloud.kms.v1.RetiredResource()), - ]; - client.innerApiCalls.listRetiredResources = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listRetiredResources( - request, - (err?: Error|null, result?: protos.google.cloud.kms.v1.IRetiredResource[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listRetiredResources as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listRetiredResources as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listRetiredResources with error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListRetiredResourcesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListRetiredResourcesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listRetiredResources = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listRetiredResources(request), expectedError); - const actualRequest = (client.innerApiCalls.listRetiredResources as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listRetiredResources as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listRetiredResourcesStream without error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListRetiredResourcesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListRetiredResourcesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.kms.v1.RetiredResource()), - generateSampleMessage(new protos.google.cloud.kms.v1.RetiredResource()), - generateSampleMessage(new protos.google.cloud.kms.v1.RetiredResource()), - ]; - client.descriptors.page.listRetiredResources.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listRetiredResourcesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.kms.v1.RetiredResource[] = []; - stream.on('data', (response: protos.google.cloud.kms.v1.RetiredResource) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listRetiredResources.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listRetiredResources, request)); - assert( - (client.descriptors.page.listRetiredResources.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listRetiredResourcesStream with error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListRetiredResourcesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListRetiredResourcesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listRetiredResources.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listRetiredResourcesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.kms.v1.RetiredResource[] = []; - stream.on('data', (response: protos.google.cloud.kms.v1.RetiredResource) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listRetiredResources.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listRetiredResources, request)); - assert( - (client.descriptors.page.listRetiredResources.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listRetiredResources without error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListRetiredResourcesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListRetiredResourcesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.kms.v1.RetiredResource()), - generateSampleMessage(new protos.google.cloud.kms.v1.RetiredResource()), - generateSampleMessage(new protos.google.cloud.kms.v1.RetiredResource()), - ]; - client.descriptors.page.listRetiredResources.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.kms.v1.IRetiredResource[] = []; - const iterable = client.listRetiredResourcesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getImportJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getImportJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getImportJob with error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.GetImportJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.GetImportJobRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getImportJob = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getImportJob(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getImportJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getImportJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getImportJob with closed client', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.GetImportJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.GetImportJobRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getImportJob(request), expectedError); + }); + }); + + describe('getRetiredResource', () => { + it('invokes getRetiredResource without error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.GetRetiredResourceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.GetRetiredResourceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.RetiredResource(), + ); + client.innerApiCalls.getRetiredResource = + stubSimpleCall(expectedResponse); + const [response] = await client.getRetiredResource(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getRetiredResource as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getRetiredResource as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getRetiredResource without error using callback', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.GetRetiredResourceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.GetRetiredResourceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.RetiredResource(), + ); + client.innerApiCalls.getRetiredResource = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getRetiredResource( + request, + ( + err?: Error | null, + result?: protos.google.cloud.kms.v1.IRetiredResource | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getRetiredResource as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getRetiredResource as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getRetiredResource with error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.GetRetiredResourceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.GetRetiredResourceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getRetiredResource = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getRetiredResource(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getRetiredResource as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getRetiredResource as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getRetiredResource with closed client', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.GetRetiredResourceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.GetRetiredResourceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getRetiredResource(request), expectedError); + }); + }); + + describe('createKeyRing', () => { + it('invokes createKeyRing without error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.CreateKeyRingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.CreateKeyRingRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.KeyRing(), + ); + client.innerApiCalls.createKeyRing = stubSimpleCall(expectedResponse); + const [response] = await client.createKeyRing(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createKeyRing as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createKeyRing as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createKeyRing without error using callback', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.CreateKeyRingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.CreateKeyRingRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.KeyRing(), + ); + client.innerApiCalls.createKeyRing = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createKeyRing( + request, + ( + err?: Error | null, + result?: protos.google.cloud.kms.v1.IKeyRing | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createKeyRing as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createKeyRing as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createKeyRing with error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.CreateKeyRingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.CreateKeyRingRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createKeyRing = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.createKeyRing(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createKeyRing as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createKeyRing as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createKeyRing with closed client', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.CreateKeyRingRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.CreateKeyRingRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.createKeyRing(request), expectedError); + }); + }); + + describe('createCryptoKey', () => { + it('invokes createCryptoKey without error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.CreateCryptoKeyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.CreateCryptoKeyRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.CryptoKey(), + ); + client.innerApiCalls.createCryptoKey = stubSimpleCall(expectedResponse); + const [response] = await client.createCryptoKey(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createCryptoKey as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCryptoKey as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createCryptoKey without error using callback', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.CreateCryptoKeyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.CreateCryptoKeyRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.CryptoKey(), + ); + client.innerApiCalls.createCryptoKey = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createCryptoKey( + request, + ( + err?: Error | null, + result?: protos.google.cloud.kms.v1.ICryptoKey | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createCryptoKey as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCryptoKey as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createCryptoKey with error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.CreateCryptoKeyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.CreateCryptoKeyRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createCryptoKey = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.createCryptoKey(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createCryptoKey as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCryptoKey as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createCryptoKey with closed client', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.CreateCryptoKeyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.CreateCryptoKeyRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.createCryptoKey(request), expectedError); + }); + }); + + describe('createCryptoKeyVersion', () => { + it('invokes createCryptoKeyVersion without error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.CreateCryptoKeyVersionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.CreateCryptoKeyVersionRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.CryptoKeyVersion(), + ); + client.innerApiCalls.createCryptoKeyVersion = + stubSimpleCall(expectedResponse); + const [response] = await client.createCryptoKeyVersion(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createCryptoKeyVersion as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCryptoKeyVersion as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createCryptoKeyVersion without error using callback', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.CreateCryptoKeyVersionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.CreateCryptoKeyVersionRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.CryptoKeyVersion(), + ); + client.innerApiCalls.createCryptoKeyVersion = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createCryptoKeyVersion( + request, + ( + err?: Error | null, + result?: protos.google.cloud.kms.v1.ICryptoKeyVersion | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createCryptoKeyVersion as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCryptoKeyVersion as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createCryptoKeyVersion with error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.CreateCryptoKeyVersionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.CreateCryptoKeyVersionRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createCryptoKeyVersion = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.createCryptoKeyVersion(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.createCryptoKeyVersion as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCryptoKeyVersion as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createCryptoKeyVersion with closed client', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.CreateCryptoKeyVersionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.CreateCryptoKeyVersionRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.createCryptoKeyVersion(request), + expectedError, + ); + }); + }); + + describe('importCryptoKeyVersion', () => { + it('invokes importCryptoKeyVersion without error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ImportCryptoKeyVersionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ImportCryptoKeyVersionRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.CryptoKeyVersion(), + ); + client.innerApiCalls.importCryptoKeyVersion = + stubSimpleCall(expectedResponse); + const [response] = await client.importCryptoKeyVersion(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.importCryptoKeyVersion as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importCryptoKeyVersion as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importCryptoKeyVersion without error using callback', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ImportCryptoKeyVersionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ImportCryptoKeyVersionRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.CryptoKeyVersion(), + ); + client.innerApiCalls.importCryptoKeyVersion = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.importCryptoKeyVersion( + request, + ( + err?: Error | null, + result?: protos.google.cloud.kms.v1.ICryptoKeyVersion | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.importCryptoKeyVersion as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importCryptoKeyVersion as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importCryptoKeyVersion with error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ImportCryptoKeyVersionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ImportCryptoKeyVersionRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importCryptoKeyVersion = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.importCryptoKeyVersion(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.importCryptoKeyVersion as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importCryptoKeyVersion as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importCryptoKeyVersion with closed client', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ImportCryptoKeyVersionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ImportCryptoKeyVersionRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.importCryptoKeyVersion(request), + expectedError, + ); + }); + }); + + describe('createImportJob', () => { + it('invokes createImportJob without error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.CreateImportJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.CreateImportJobRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.ImportJob(), + ); + client.innerApiCalls.createImportJob = stubSimpleCall(expectedResponse); + const [response] = await client.createImportJob(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createImportJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createImportJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createImportJob without error using callback', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.CreateImportJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.CreateImportJobRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.ImportJob(), + ); + client.innerApiCalls.createImportJob = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createImportJob( + request, + ( + err?: Error | null, + result?: protos.google.cloud.kms.v1.IImportJob | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createImportJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createImportJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createImportJob with error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.CreateImportJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.CreateImportJobRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createImportJob = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.createImportJob(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createImportJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createImportJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createImportJob with closed client', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.CreateImportJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.CreateImportJobRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.createImportJob(request), expectedError); + }); + }); + + describe('updateCryptoKey', () => { + it('invokes updateCryptoKey without error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.UpdateCryptoKeyRequest(), + ); + request.cryptoKey ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.UpdateCryptoKeyRequest', + ['cryptoKey', 'name'], + ); + request.cryptoKey.name = defaultValue1; + const expectedHeaderRequestParams = `crypto_key.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.CryptoKey(), + ); + client.innerApiCalls.updateCryptoKey = stubSimpleCall(expectedResponse); + const [response] = await client.updateCryptoKey(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateCryptoKey as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCryptoKey as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateCryptoKey without error using callback', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.UpdateCryptoKeyRequest(), + ); + request.cryptoKey ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.UpdateCryptoKeyRequest', + ['cryptoKey', 'name'], + ); + request.cryptoKey.name = defaultValue1; + const expectedHeaderRequestParams = `crypto_key.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.CryptoKey(), + ); + client.innerApiCalls.updateCryptoKey = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateCryptoKey( + request, + ( + err?: Error | null, + result?: protos.google.cloud.kms.v1.ICryptoKey | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateCryptoKey as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCryptoKey as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateCryptoKey with error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.UpdateCryptoKeyRequest(), + ); + request.cryptoKey ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.UpdateCryptoKeyRequest', + ['cryptoKey', 'name'], + ); + request.cryptoKey.name = defaultValue1; + const expectedHeaderRequestParams = `crypto_key.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateCryptoKey = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateCryptoKey(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateCryptoKey as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCryptoKey as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateCryptoKey with closed client', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.UpdateCryptoKeyRequest(), + ); + request.cryptoKey ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.UpdateCryptoKeyRequest', + ['cryptoKey', 'name'], + ); + request.cryptoKey.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.updateCryptoKey(request), expectedError); + }); + }); + + describe('updateCryptoKeyVersion', () => { + it('invokes updateCryptoKeyVersion without error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.UpdateCryptoKeyVersionRequest(), + ); + request.cryptoKeyVersion ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.UpdateCryptoKeyVersionRequest', + ['cryptoKeyVersion', 'name'], + ); + request.cryptoKeyVersion.name = defaultValue1; + const expectedHeaderRequestParams = `crypto_key_version.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.CryptoKeyVersion(), + ); + client.innerApiCalls.updateCryptoKeyVersion = + stubSimpleCall(expectedResponse); + const [response] = await client.updateCryptoKeyVersion(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateCryptoKeyVersion as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCryptoKeyVersion as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateCryptoKeyVersion without error using callback', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.UpdateCryptoKeyVersionRequest(), + ); + request.cryptoKeyVersion ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.UpdateCryptoKeyVersionRequest', + ['cryptoKeyVersion', 'name'], + ); + request.cryptoKeyVersion.name = defaultValue1; + const expectedHeaderRequestParams = `crypto_key_version.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.CryptoKeyVersion(), + ); + client.innerApiCalls.updateCryptoKeyVersion = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateCryptoKeyVersion( + request, + ( + err?: Error | null, + result?: protos.google.cloud.kms.v1.ICryptoKeyVersion | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateCryptoKeyVersion as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCryptoKeyVersion as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateCryptoKeyVersion with error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.UpdateCryptoKeyVersionRequest(), + ); + request.cryptoKeyVersion ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.UpdateCryptoKeyVersionRequest', + ['cryptoKeyVersion', 'name'], + ); + request.cryptoKeyVersion.name = defaultValue1; + const expectedHeaderRequestParams = `crypto_key_version.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateCryptoKeyVersion = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.updateCryptoKeyVersion(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.updateCryptoKeyVersion as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCryptoKeyVersion as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateCryptoKeyVersion with closed client', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.UpdateCryptoKeyVersionRequest(), + ); + request.cryptoKeyVersion ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.UpdateCryptoKeyVersionRequest', + ['cryptoKeyVersion', 'name'], + ); + request.cryptoKeyVersion.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.updateCryptoKeyVersion(request), + expectedError, + ); + }); + }); + + describe('updateCryptoKeyPrimaryVersion', () => { + it('invokes updateCryptoKeyPrimaryVersion without error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.UpdateCryptoKeyPrimaryVersionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.UpdateCryptoKeyPrimaryVersionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.CryptoKey(), + ); + client.innerApiCalls.updateCryptoKeyPrimaryVersion = + stubSimpleCall(expectedResponse); + const [response] = await client.updateCryptoKeyPrimaryVersion(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateCryptoKeyPrimaryVersion as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCryptoKeyPrimaryVersion as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateCryptoKeyPrimaryVersion without error using callback', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.UpdateCryptoKeyPrimaryVersionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.UpdateCryptoKeyPrimaryVersionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.CryptoKey(), + ); + client.innerApiCalls.updateCryptoKeyPrimaryVersion = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateCryptoKeyPrimaryVersion( + request, + ( + err?: Error | null, + result?: protos.google.cloud.kms.v1.ICryptoKey | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateCryptoKeyPrimaryVersion as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCryptoKeyPrimaryVersion as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateCryptoKeyPrimaryVersion with error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.UpdateCryptoKeyPrimaryVersionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.UpdateCryptoKeyPrimaryVersionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateCryptoKeyPrimaryVersion = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.updateCryptoKeyPrimaryVersion(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.updateCryptoKeyPrimaryVersion as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCryptoKeyPrimaryVersion as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateCryptoKeyPrimaryVersion with closed client', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.UpdateCryptoKeyPrimaryVersionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.UpdateCryptoKeyPrimaryVersionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.updateCryptoKeyPrimaryVersion(request), + expectedError, + ); + }); + }); + + describe('destroyCryptoKeyVersion', () => { + it('invokes destroyCryptoKeyVersion without error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.DestroyCryptoKeyVersionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.DestroyCryptoKeyVersionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.CryptoKeyVersion(), + ); + client.innerApiCalls.destroyCryptoKeyVersion = + stubSimpleCall(expectedResponse); + const [response] = await client.destroyCryptoKeyVersion(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.destroyCryptoKeyVersion as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.destroyCryptoKeyVersion as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes destroyCryptoKeyVersion without error using callback', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.DestroyCryptoKeyVersionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.DestroyCryptoKeyVersionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.CryptoKeyVersion(), + ); + client.innerApiCalls.destroyCryptoKeyVersion = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.destroyCryptoKeyVersion( + request, + ( + err?: Error | null, + result?: protos.google.cloud.kms.v1.ICryptoKeyVersion | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.destroyCryptoKeyVersion as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.destroyCryptoKeyVersion as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes destroyCryptoKeyVersion with error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.DestroyCryptoKeyVersionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.DestroyCryptoKeyVersionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.destroyCryptoKeyVersion = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.destroyCryptoKeyVersion(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.destroyCryptoKeyVersion as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.destroyCryptoKeyVersion as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes destroyCryptoKeyVersion with closed client', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.DestroyCryptoKeyVersionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.DestroyCryptoKeyVersionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.destroyCryptoKeyVersion(request), + expectedError, + ); + }); + }); + + describe('restoreCryptoKeyVersion', () => { + it('invokes restoreCryptoKeyVersion without error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.RestoreCryptoKeyVersionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.RestoreCryptoKeyVersionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.CryptoKeyVersion(), + ); + client.innerApiCalls.restoreCryptoKeyVersion = + stubSimpleCall(expectedResponse); + const [response] = await client.restoreCryptoKeyVersion(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.restoreCryptoKeyVersion as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.restoreCryptoKeyVersion as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes restoreCryptoKeyVersion without error using callback', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.RestoreCryptoKeyVersionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.RestoreCryptoKeyVersionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.CryptoKeyVersion(), + ); + client.innerApiCalls.restoreCryptoKeyVersion = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.restoreCryptoKeyVersion( + request, + ( + err?: Error | null, + result?: protos.google.cloud.kms.v1.ICryptoKeyVersion | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.restoreCryptoKeyVersion as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.restoreCryptoKeyVersion as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes restoreCryptoKeyVersion with error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.RestoreCryptoKeyVersionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.RestoreCryptoKeyVersionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.restoreCryptoKeyVersion = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.restoreCryptoKeyVersion(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.restoreCryptoKeyVersion as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.restoreCryptoKeyVersion as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes restoreCryptoKeyVersion with closed client', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.RestoreCryptoKeyVersionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.RestoreCryptoKeyVersionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.restoreCryptoKeyVersion(request), + expectedError, + ); + }); + }); + + describe('encrypt', () => { + it('invokes encrypt without error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.EncryptRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.EncryptRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.EncryptResponse(), + ); + client.innerApiCalls.encrypt = stubSimpleCall(expectedResponse); + const [response] = await client.encrypt(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.encrypt as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.encrypt as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes encrypt without error using callback', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.EncryptRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.EncryptRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.EncryptResponse(), + ); + client.innerApiCalls.encrypt = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.encrypt( + request, + ( + err?: Error | null, + result?: protos.google.cloud.kms.v1.IEncryptResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.encrypt as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.encrypt as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes encrypt with error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.EncryptRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.EncryptRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.encrypt = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.encrypt(request), expectedError); + const actualRequest = (client.innerApiCalls.encrypt as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.encrypt as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes encrypt with closed client', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.EncryptRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.EncryptRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.encrypt(request), expectedError); + }); + }); + + describe('decrypt', () => { + it('invokes decrypt without error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.DecryptRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.DecryptRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.DecryptResponse(), + ); + client.innerApiCalls.decrypt = stubSimpleCall(expectedResponse); + const [response] = await client.decrypt(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.decrypt as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.decrypt as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes decrypt without error using callback', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.DecryptRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.DecryptRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.DecryptResponse(), + ); + client.innerApiCalls.decrypt = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.decrypt( + request, + ( + err?: Error | null, + result?: protos.google.cloud.kms.v1.IDecryptResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.decrypt as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.decrypt as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes decrypt with error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.DecryptRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.DecryptRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.decrypt = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.decrypt(request), expectedError); + const actualRequest = (client.innerApiCalls.decrypt as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.decrypt as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes decrypt with closed client', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.DecryptRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.DecryptRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.decrypt(request), expectedError); + }); + }); + + describe('rawEncrypt', () => { + it('invokes rawEncrypt without error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.RawEncryptRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.RawEncryptRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.RawEncryptResponse(), + ); + client.innerApiCalls.rawEncrypt = stubSimpleCall(expectedResponse); + const [response] = await client.rawEncrypt(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.rawEncrypt as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rawEncrypt as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes rawEncrypt without error using callback', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.RawEncryptRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.RawEncryptRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.RawEncryptResponse(), + ); + client.innerApiCalls.rawEncrypt = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.rawEncrypt( + request, + ( + err?: Error | null, + result?: protos.google.cloud.kms.v1.IRawEncryptResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.rawEncrypt as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rawEncrypt as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes rawEncrypt with error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.RawEncryptRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.RawEncryptRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rawEncrypt = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.rawEncrypt(request), expectedError); + const actualRequest = ( + client.innerApiCalls.rawEncrypt as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rawEncrypt as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes rawEncrypt with closed client', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.RawEncryptRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.RawEncryptRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.rawEncrypt(request), expectedError); + }); + }); + + describe('rawDecrypt', () => { + it('invokes rawDecrypt without error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.RawDecryptRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.RawDecryptRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.RawDecryptResponse(), + ); + client.innerApiCalls.rawDecrypt = stubSimpleCall(expectedResponse); + const [response] = await client.rawDecrypt(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.rawDecrypt as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rawDecrypt as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes rawDecrypt without error using callback', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.RawDecryptRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.RawDecryptRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.RawDecryptResponse(), + ); + client.innerApiCalls.rawDecrypt = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.rawDecrypt( + request, + ( + err?: Error | null, + result?: protos.google.cloud.kms.v1.IRawDecryptResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.rawDecrypt as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rawDecrypt as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes rawDecrypt with error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.RawDecryptRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.RawDecryptRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rawDecrypt = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.rawDecrypt(request), expectedError); + const actualRequest = ( + client.innerApiCalls.rawDecrypt as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rawDecrypt as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes rawDecrypt with closed client', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.RawDecryptRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.RawDecryptRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.rawDecrypt(request), expectedError); + }); + }); + + describe('asymmetricSign', () => { + it('invokes asymmetricSign without error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.AsymmetricSignRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.AsymmetricSignRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.AsymmetricSignResponse(), + ); + client.innerApiCalls.asymmetricSign = stubSimpleCall(expectedResponse); + const [response] = await client.asymmetricSign(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.asymmetricSign as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.asymmetricSign as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes asymmetricSign without error using callback', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.AsymmetricSignRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.AsymmetricSignRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.AsymmetricSignResponse(), + ); + client.innerApiCalls.asymmetricSign = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.asymmetricSign( + request, + ( + err?: Error | null, + result?: protos.google.cloud.kms.v1.IAsymmetricSignResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.asymmetricSign as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.asymmetricSign as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes asymmetricSign with error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.AsymmetricSignRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.AsymmetricSignRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.asymmetricSign = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.asymmetricSign(request), expectedError); + const actualRequest = ( + client.innerApiCalls.asymmetricSign as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.asymmetricSign as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes asymmetricSign with closed client', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.AsymmetricSignRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.AsymmetricSignRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.asymmetricSign(request), expectedError); + }); + }); + + describe('asymmetricDecrypt', () => { + it('invokes asymmetricDecrypt without error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.AsymmetricDecryptRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.AsymmetricDecryptRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.AsymmetricDecryptResponse(), + ); + client.innerApiCalls.asymmetricDecrypt = stubSimpleCall(expectedResponse); + const [response] = await client.asymmetricDecrypt(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.asymmetricDecrypt as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.asymmetricDecrypt as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes asymmetricDecrypt without error using callback', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.AsymmetricDecryptRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.AsymmetricDecryptRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.AsymmetricDecryptResponse(), + ); + client.innerApiCalls.asymmetricDecrypt = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.asymmetricDecrypt( + request, + ( + err?: Error | null, + result?: protos.google.cloud.kms.v1.IAsymmetricDecryptResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listRetiredResources.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listRetiredResources.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listRetiredResources with error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.kms.v1.ListRetiredResourcesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.kms.v1.ListRetiredResourcesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listRetiredResources.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listRetiredResourcesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.kms.v1.IRetiredResource[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listRetiredResources.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listRetiredResources.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.getIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getIamPolicy without error using callback', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.getIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes getIamPolicy with error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.GetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); - const response = await client.setIamPolicy(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes setIamPolicy without error using callback', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.Policy() - ); - client.iamClient.setIamPolicy = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.Policy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0)); - }); - it('invokes setIamPolicy with error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.SetIamPolicyRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request, expectedOptions), expectedError); - assert((client.iamClient.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); - const response = await client.testIamPermissions(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes testIamPermissions without error using callback', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsResponse() - ); - client.iamClient.testIamPermissions = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - expectedOptions, - (err?: Error|null, result?: IamProtos.google.iam.v1.TestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }).catch(err => {throw err}); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0)); - }); - it('invokes testIamPermissions with error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new IamProtos.google.iam.v1.TestIamPermissionsRequest() - ); - request.resource = ''; - const expectedHeaderRequestParams = 'resource='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.iamClient.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request, expectedOptions), expectedError); - assert((client.iamClient.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - 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 keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - 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 keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - 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 keymanagementserviceModule.v1.KeyManagementServiceClient({ - 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.asymmetricDecrypt as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.asymmetricDecrypt as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes asymmetricDecrypt with error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.AsymmetricDecryptRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.AsymmetricDecryptRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.asymmetricDecrypt = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.asymmetricDecrypt(request), expectedError); + const actualRequest = ( + client.innerApiCalls.asymmetricDecrypt as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.asymmetricDecrypt as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes asymmetricDecrypt with closed client', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.AsymmetricDecryptRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.AsymmetricDecryptRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.asymmetricDecrypt(request), expectedError); + }); + }); + + describe('macSign', () => { + it('invokes macSign without error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.MacSignRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.MacSignRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.MacSignResponse(), + ); + client.innerApiCalls.macSign = stubSimpleCall(expectedResponse); + const [response] = await client.macSign(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.macSign as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.macSign as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes macSign without error using callback', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.MacSignRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.MacSignRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.MacSignResponse(), + ); + client.innerApiCalls.macSign = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.macSign( + request, + ( + err?: Error | null, + result?: protos.google.cloud.kms.v1.IMacSignResponse | 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 keymanagementserviceModule.v1.KeyManagementServiceClient({ - 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 keymanagementserviceModule.v1.KeyManagementServiceClient({ - 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 keymanagementserviceModule.v1.KeyManagementServiceClient({ - 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 keymanagementserviceModule.v1.KeyManagementServiceClient({ - 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 keymanagementserviceModule.v1.KeyManagementServiceClient({ - 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 keymanagementserviceModule.v1.KeyManagementServiceClient({ - 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 keymanagementserviceModule.v1.KeyManagementServiceClient({ - 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 keymanagementserviceModule.v1.KeyManagementServiceClient({ - 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 keymanagementserviceModule.v1.KeyManagementServiceClient({ - 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 keymanagementserviceModule.v1.KeyManagementServiceClient({ - 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 keymanagementserviceModule.v1.KeyManagementServiceClient({ - 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.macSign as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.macSign as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes macSign with error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.MacSignRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.MacSignRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.macSign = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.macSign(request), expectedError); + const actualRequest = (client.innerApiCalls.macSign as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.macSign as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes macSign with closed client', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.MacSignRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.MacSignRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.macSign(request), expectedError); + }); + }); + + describe('macVerify', () => { + it('invokes macVerify without error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.MacVerifyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.MacVerifyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.MacVerifyResponse(), + ); + client.innerApiCalls.macVerify = stubSimpleCall(expectedResponse); + const [response] = await client.macVerify(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.macVerify as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.macVerify as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes macVerify without error using callback', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.MacVerifyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.MacVerifyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.MacVerifyResponse(), + ); + client.innerApiCalls.macVerify = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.macVerify( + request, + ( + err?: Error | null, + result?: protos.google.cloud.kms.v1.IMacVerifyResponse | 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 keymanagementserviceModule.v1.KeyManagementServiceClient({ - 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.macVerify as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.macVerify as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('Path templates', () => { + it('invokes macVerify with error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.MacVerifyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.MacVerifyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.macVerify = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.macVerify(request), expectedError); + const actualRequest = ( + client.innerApiCalls.macVerify as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.macVerify as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('cryptoKey', async () => { - const fakePath = "/rendered/path/cryptoKey"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - key_ring: "keyRingValue", - crypto_key: "cryptoKeyValue", - }; - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - 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('invokes macVerify with closed client', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.MacVerifyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.MacVerifyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.macVerify(request), expectedError); + }); + }); + + describe('decapsulate', () => { + it('invokes decapsulate without error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.DecapsulateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.DecapsulateRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.DecapsulateResponse(), + ); + client.innerApiCalls.decapsulate = stubSimpleCall(expectedResponse); + const [response] = await client.decapsulate(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.decapsulate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.decapsulate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchProjectFromCryptoKeyName', () => { - const result = client.matchProjectFromCryptoKeyName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.cryptoKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes decapsulate without error using callback', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.DecapsulateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.DecapsulateRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.DecapsulateResponse(), + ); + client.innerApiCalls.decapsulate = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.decapsulate( + request, + ( + err?: Error | null, + result?: protos.google.cloud.kms.v1.IDecapsulateResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.decapsulate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.decapsulate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchLocationFromCryptoKeyName', () => { - const result = client.matchLocationFromCryptoKeyName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.cryptoKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes decapsulate with error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.DecapsulateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.DecapsulateRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.decapsulate = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.decapsulate(request), expectedError); + const actualRequest = ( + client.innerApiCalls.decapsulate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.decapsulate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchKeyRingFromCryptoKeyName', () => { - const result = client.matchKeyRingFromCryptoKeyName(fakePath); - assert.strictEqual(result, "keyRingValue"); - assert((client.pathTemplates.cryptoKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes decapsulate with closed client', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.DecapsulateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.DecapsulateRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.decapsulate(request), expectedError); + }); + }); + + describe('generateRandomBytes', () => { + it('invokes generateRandomBytes without error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.GenerateRandomBytesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.GenerateRandomBytesRequest', + ['location'], + ); + request.location = defaultValue1; + const expectedHeaderRequestParams = `location=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.GenerateRandomBytesResponse(), + ); + client.innerApiCalls.generateRandomBytes = + stubSimpleCall(expectedResponse); + const [response] = await client.generateRandomBytes(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.generateRandomBytes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.generateRandomBytes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchCryptoKeyFromCryptoKeyName', () => { - const result = client.matchCryptoKeyFromCryptoKeyName(fakePath); - assert.strictEqual(result, "cryptoKeyValue"); - assert((client.pathTemplates.cryptoKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('invokes generateRandomBytes without error using callback', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.GenerateRandomBytesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.GenerateRandomBytesRequest', + ['location'], + ); + request.location = defaultValue1; + const expectedHeaderRequestParams = `location=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.kms.v1.GenerateRandomBytesResponse(), + ); + client.innerApiCalls.generateRandomBytes = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.generateRandomBytes( + request, + ( + err?: Error | null, + result?: protos.google.cloud.kms.v1.IGenerateRandomBytesResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.generateRandomBytes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.generateRandomBytes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - 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 keymanagementserviceModule.v1.KeyManagementServiceClient({ - 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('invokes generateRandomBytes with error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.GenerateRandomBytesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.GenerateRandomBytesRequest', + ['location'], + ); + request.location = defaultValue1; + const expectedHeaderRequestParams = `location=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.generateRandomBytes = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.generateRandomBytes(request), expectedError); + const actualRequest = ( + client.innerApiCalls.generateRandomBytes as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.generateRandomBytes as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchProjectFromCryptoKeyVersionName', () => { - const result = client.matchProjectFromCryptoKeyVersionName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.cryptoKeyVersionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes generateRandomBytes with closed client', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.GenerateRandomBytesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.GenerateRandomBytesRequest', + ['location'], + ); + request.location = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.generateRandomBytes(request), expectedError); + }); + }); + + describe('deleteCryptoKey', () => { + it('invokes deleteCryptoKey without error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.DeleteCryptoKeyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.DeleteCryptoKeyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteCryptoKey = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteCryptoKey(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteCryptoKey as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCryptoKey as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchLocationFromCryptoKeyVersionName', () => { - const result = client.matchLocationFromCryptoKeyVersionName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.cryptoKeyVersionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes deleteCryptoKey without error using callback', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.DeleteCryptoKeyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.DeleteCryptoKeyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteCryptoKey = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteCryptoKey( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.kms.v1.IDeleteCryptoKeyMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.kms.v1.IDeleteCryptoKeyMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteCryptoKey as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCryptoKey as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchKeyRingFromCryptoKeyVersionName', () => { - const result = client.matchKeyRingFromCryptoKeyVersionName(fakePath); - assert.strictEqual(result, "keyRingValue"); - assert((client.pathTemplates.cryptoKeyVersionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes deleteCryptoKey with call error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.DeleteCryptoKeyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.DeleteCryptoKeyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteCryptoKey = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteCryptoKey(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteCryptoKey as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCryptoKey as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchCryptoKeyFromCryptoKeyVersionName', () => { - const result = client.matchCryptoKeyFromCryptoKeyVersionName(fakePath); - assert.strictEqual(result, "cryptoKeyValue"); - assert((client.pathTemplates.cryptoKeyVersionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes deleteCryptoKey with LRO error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.DeleteCryptoKeyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.DeleteCryptoKeyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteCryptoKey = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteCryptoKey(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteCryptoKey as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCryptoKey as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchCryptoKeyVersionFromCryptoKeyVersionName', () => { - const result = client.matchCryptoKeyVersionFromCryptoKeyVersionName(fakePath); - assert.strictEqual(result, "cryptoKeyVersionValue"); - assert((client.pathTemplates.cryptoKeyVersionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('invokes checkDeleteCryptoKeyProgress without error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteCryptoKeyProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - describe('ekmConfig', async () => { - const fakePath = "/rendered/path/ekmConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.ekmConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.ekmConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('ekmConfigPath', () => { - const result = client.ekmConfigPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.ekmConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes checkDeleteCryptoKeyProgress with error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteCryptoKeyProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteCryptoKeyVersion', () => { + it('invokes deleteCryptoKeyVersion without error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.DeleteCryptoKeyVersionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.DeleteCryptoKeyVersionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteCryptoKeyVersion = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteCryptoKeyVersion(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteCryptoKeyVersion as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCryptoKeyVersion as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchProjectFromEkmConfigName', () => { - const result = client.matchProjectFromEkmConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.ekmConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes deleteCryptoKeyVersion without error using callback', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.DeleteCryptoKeyVersionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.DeleteCryptoKeyVersionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteCryptoKeyVersion = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteCryptoKeyVersion( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.kms.v1.IDeleteCryptoKeyVersionMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.kms.v1.IDeleteCryptoKeyVersionMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteCryptoKeyVersion as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCryptoKeyVersion as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchLocationFromEkmConfigName', () => { - const result = client.matchLocationFromEkmConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.ekmConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('invokes deleteCryptoKeyVersion with call error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.DeleteCryptoKeyVersionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.DeleteCryptoKeyVersionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteCryptoKeyVersion = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.deleteCryptoKeyVersion(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.deleteCryptoKeyVersion as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCryptoKeyVersion as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('ekmConnection', async () => { - const fakePath = "/rendered/path/ekmConnection"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - ekm_connection: "ekmConnectionValue", - }; - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.ekmConnectionPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.ekmConnectionPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('ekmConnectionPath', () => { - const result = client.ekmConnectionPath("projectValue", "locationValue", "ekmConnectionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.ekmConnectionPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes deleteCryptoKeyVersion with LRO error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.DeleteCryptoKeyVersionRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.DeleteCryptoKeyVersionRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteCryptoKeyVersion = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteCryptoKeyVersion(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteCryptoKeyVersion as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCryptoKeyVersion as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchProjectFromEkmConnectionName', () => { - const result = client.matchProjectFromEkmConnectionName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.ekmConnectionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes checkDeleteCryptoKeyVersionProgress without error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteCryptoKeyVersionProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('matchLocationFromEkmConnectionName', () => { - const result = client.matchLocationFromEkmConnectionName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.ekmConnectionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes checkDeleteCryptoKeyVersionProgress with error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteCryptoKeyVersionProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listKeyRings', () => { + it('invokes listKeyRings without error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListKeyRingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListKeyRingsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.kms.v1.KeyRing()), + generateSampleMessage(new protos.google.cloud.kms.v1.KeyRing()), + generateSampleMessage(new protos.google.cloud.kms.v1.KeyRing()), + ]; + client.innerApiCalls.listKeyRings = stubSimpleCall(expectedResponse); + const [response] = await client.listKeyRings(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listKeyRings as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listKeyRings as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchEkmConnectionFromEkmConnectionName', () => { - const result = client.matchEkmConnectionFromEkmConnectionName(fakePath); - assert.strictEqual(result, "ekmConnectionValue"); - assert((client.pathTemplates.ekmConnectionPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('invokes listKeyRings without error using callback', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListKeyRingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListKeyRingsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.kms.v1.KeyRing()), + generateSampleMessage(new protos.google.cloud.kms.v1.KeyRing()), + generateSampleMessage(new protos.google.cloud.kms.v1.KeyRing()), + ]; + client.innerApiCalls.listKeyRings = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listKeyRings( + request, + ( + err?: Error | null, + result?: protos.google.cloud.kms.v1.IKeyRing[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listKeyRings as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listKeyRings as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('folderAutokeyConfig', async () => { - const fakePath = "/rendered/path/folderAutokeyConfig"; - const expectedParameters = { - folder: "folderValue", - }; - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.folderAutokeyConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.folderAutokeyConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('folderAutokeyConfigPath', () => { - const result = client.folderAutokeyConfigPath("folderValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.folderAutokeyConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes listKeyRings with error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListKeyRingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListKeyRingsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listKeyRings = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listKeyRings(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listKeyRings as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listKeyRings as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchFolderFromFolderAutokeyConfigName', () => { - const result = client.matchFolderFromFolderAutokeyConfigName(fakePath); - assert.strictEqual(result, "folderValue"); - assert((client.pathTemplates.folderAutokeyConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('invokes listKeyRingsStream without error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListKeyRingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListKeyRingsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.kms.v1.KeyRing()), + generateSampleMessage(new protos.google.cloud.kms.v1.KeyRing()), + generateSampleMessage(new protos.google.cloud.kms.v1.KeyRing()), + ]; + client.descriptors.page.listKeyRings.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listKeyRingsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.kms.v1.KeyRing[] = []; + stream.on('data', (response: protos.google.cloud.kms.v1.KeyRing) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listKeyRings.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listKeyRings, request), + ); + assert( + (client.descriptors.page.listKeyRings.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - describe('importJob', async () => { - const fakePath = "/rendered/path/importJob"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - key_ring: "keyRingValue", - import_job: "importJobValue", - }; - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.importJobPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.importJobPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('importJobPath', () => { - const result = client.importJobPath("projectValue", "locationValue", "keyRingValue", "importJobValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.importJobPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes listKeyRingsStream with error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListKeyRingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListKeyRingsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listKeyRings.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listKeyRingsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.kms.v1.KeyRing[] = []; + stream.on('data', (response: protos.google.cloud.kms.v1.KeyRing) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listKeyRings.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listKeyRings, request), + ); + assert( + (client.descriptors.page.listKeyRings.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('matchProjectFromImportJobName', () => { - const result = client.matchProjectFromImportJobName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.importJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('uses async iteration with listKeyRings without error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListKeyRingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListKeyRingsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.kms.v1.KeyRing()), + generateSampleMessage(new protos.google.cloud.kms.v1.KeyRing()), + generateSampleMessage(new protos.google.cloud.kms.v1.KeyRing()), + ]; + client.descriptors.page.listKeyRings.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.kms.v1.IKeyRing[] = []; + const iterable = client.listKeyRingsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listKeyRings.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listKeyRings.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('matchLocationFromImportJobName', () => { - const result = client.matchLocationFromImportJobName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.importJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('uses async iteration with listKeyRings with error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListKeyRingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListKeyRingsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listKeyRings.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listKeyRingsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.kms.v1.IKeyRing[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listKeyRings.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listKeyRings.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listCryptoKeys', () => { + it('invokes listCryptoKeys without error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListCryptoKeysRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListCryptoKeysRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKey()), + generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKey()), + generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKey()), + ]; + client.innerApiCalls.listCryptoKeys = stubSimpleCall(expectedResponse); + const [response] = await client.listCryptoKeys(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listCryptoKeys as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCryptoKeys as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchKeyRingFromImportJobName', () => { - const result = client.matchKeyRingFromImportJobName(fakePath); - assert.strictEqual(result, "keyRingValue"); - assert((client.pathTemplates.importJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes listCryptoKeys without error using callback', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListCryptoKeysRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListCryptoKeysRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKey()), + generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKey()), + generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKey()), + ]; + client.innerApiCalls.listCryptoKeys = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listCryptoKeys( + request, + ( + err?: Error | null, + result?: protos.google.cloud.kms.v1.ICryptoKey[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listCryptoKeys as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCryptoKeys as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchImportJobFromImportJobName', () => { - const result = client.matchImportJobFromImportJobName(fakePath); - assert.strictEqual(result, "importJobValue"); - assert((client.pathTemplates.importJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('invokes listCryptoKeys with error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListCryptoKeysRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListCryptoKeysRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listCryptoKeys = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listCryptoKeys(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listCryptoKeys as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCryptoKeys as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('keyHandle', async () => { - const fakePath = "/rendered/path/keyHandle"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - key_handle: "keyHandleValue", - }; - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.keyHandlePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.keyHandlePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('keyHandlePath', () => { - const result = client.keyHandlePath("projectValue", "locationValue", "keyHandleValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.keyHandlePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes listCryptoKeysStream without error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListCryptoKeysRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListCryptoKeysRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKey()), + generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKey()), + generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKey()), + ]; + client.descriptors.page.listCryptoKeys.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listCryptoKeysStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.kms.v1.CryptoKey[] = []; + stream.on('data', (response: protos.google.cloud.kms.v1.CryptoKey) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listCryptoKeys.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listCryptoKeys, request), + ); + assert( + (client.descriptors.page.listCryptoKeys.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('matchProjectFromKeyHandleName', () => { - const result = client.matchProjectFromKeyHandleName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.keyHandlePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes listCryptoKeysStream with error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListCryptoKeysRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListCryptoKeysRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listCryptoKeys.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listCryptoKeysStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.kms.v1.CryptoKey[] = []; + stream.on('data', (response: protos.google.cloud.kms.v1.CryptoKey) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listCryptoKeys.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listCryptoKeys, request), + ); + assert( + (client.descriptors.page.listCryptoKeys.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('matchLocationFromKeyHandleName', () => { - const result = client.matchLocationFromKeyHandleName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.keyHandlePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('uses async iteration with listCryptoKeys without error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListCryptoKeysRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListCryptoKeysRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKey()), + generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKey()), + generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKey()), + ]; + client.descriptors.page.listCryptoKeys.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.kms.v1.ICryptoKey[] = []; + const iterable = client.listCryptoKeysAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listCryptoKeys.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listCryptoKeys.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('matchKeyHandleFromKeyHandleName', () => { - const result = client.matchKeyHandleFromKeyHandleName(fakePath); - assert.strictEqual(result, "keyHandleValue"); - assert((client.pathTemplates.keyHandlePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('uses async iteration with listCryptoKeys with error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListCryptoKeysRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListCryptoKeysRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listCryptoKeys.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listCryptoKeysAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.kms.v1.ICryptoKey[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listCryptoKeys.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listCryptoKeys.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listCryptoKeyVersions', () => { + it('invokes listCryptoKeyVersions without error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListCryptoKeyVersionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListCryptoKeyVersionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.kms.v1.CryptoKeyVersion(), + ), + generateSampleMessage( + new protos.google.cloud.kms.v1.CryptoKeyVersion(), + ), + generateSampleMessage( + new protos.google.cloud.kms.v1.CryptoKeyVersion(), + ), + ]; + client.innerApiCalls.listCryptoKeyVersions = + stubSimpleCall(expectedResponse); + const [response] = await client.listCryptoKeyVersions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listCryptoKeyVersions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCryptoKeyVersions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('keyRing', async () => { - const fakePath = "/rendered/path/keyRing"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - key_ring: "keyRingValue", - }; - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.keyRingPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.keyRingPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('keyRingPath', () => { - const result = client.keyRingPath("projectValue", "locationValue", "keyRingValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.keyRingPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes listCryptoKeyVersions without error using callback', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListCryptoKeyVersionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListCryptoKeyVersionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.kms.v1.CryptoKeyVersion(), + ), + generateSampleMessage( + new protos.google.cloud.kms.v1.CryptoKeyVersion(), + ), + generateSampleMessage( + new protos.google.cloud.kms.v1.CryptoKeyVersion(), + ), + ]; + client.innerApiCalls.listCryptoKeyVersions = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listCryptoKeyVersions( + request, + ( + err?: Error | null, + result?: protos.google.cloud.kms.v1.ICryptoKeyVersion[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listCryptoKeyVersions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCryptoKeyVersions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchProjectFromKeyRingName', () => { - const result = client.matchProjectFromKeyRingName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.keyRingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes listCryptoKeyVersions with error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListCryptoKeyVersionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListCryptoKeyVersionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listCryptoKeyVersions = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.listCryptoKeyVersions(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.listCryptoKeyVersions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCryptoKeyVersions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchLocationFromKeyRingName', () => { - const result = client.matchLocationFromKeyRingName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.keyRingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes listCryptoKeyVersionsStream without error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListCryptoKeyVersionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListCryptoKeyVersionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.kms.v1.CryptoKeyVersion(), + ), + generateSampleMessage( + new protos.google.cloud.kms.v1.CryptoKeyVersion(), + ), + generateSampleMessage( + new protos.google.cloud.kms.v1.CryptoKeyVersion(), + ), + ]; + client.descriptors.page.listCryptoKeyVersions.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listCryptoKeyVersionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.kms.v1.CryptoKeyVersion[] = []; + stream.on( + 'data', + (response: protos.google.cloud.kms.v1.CryptoKeyVersion) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + ( + client.descriptors.page.listCryptoKeyVersions + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.listCryptoKeyVersions, request), + ); + assert( + ( + client.descriptors.page.listCryptoKeyVersions + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('matchKeyRingFromKeyRingName', () => { - const result = client.matchKeyRingFromKeyRingName(fakePath); - assert.strictEqual(result, "keyRingValue"); - assert((client.pathTemplates.keyRingPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('invokes listCryptoKeyVersionsStream with error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListCryptoKeyVersionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListCryptoKeyVersionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listCryptoKeyVersions.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listCryptoKeyVersionsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.kms.v1.CryptoKeyVersion[] = []; + stream.on( + 'data', + (response: protos.google.cloud.kms.v1.CryptoKeyVersion) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + ( + client.descriptors.page.listCryptoKeyVersions + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.listCryptoKeyVersions, request), + ); + assert( + ( + client.descriptors.page.listCryptoKeyVersions + .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 keymanagementserviceModule.v1.KeyManagementServiceClient({ - 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('uses async iteration with listCryptoKeyVersions without error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListCryptoKeyVersionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListCryptoKeyVersionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.kms.v1.CryptoKeyVersion(), + ), + generateSampleMessage( + new protos.google.cloud.kms.v1.CryptoKeyVersion(), + ), + generateSampleMessage( + new protos.google.cloud.kms.v1.CryptoKeyVersion(), + ), + ]; + client.descriptors.page.listCryptoKeyVersions.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.kms.v1.ICryptoKeyVersion[] = []; + const iterable = client.listCryptoKeyVersionsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listCryptoKeyVersions + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listCryptoKeyVersions + .asyncIterate 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 listCryptoKeyVersions with error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListCryptoKeyVersionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListCryptoKeyVersionsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listCryptoKeyVersions.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listCryptoKeyVersionsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.kms.v1.ICryptoKeyVersion[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listCryptoKeyVersions + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listCryptoKeyVersions + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + + describe('listImportJobs', () => { + it('invokes listImportJobs without error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListImportJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListImportJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.kms.v1.ImportJob()), + generateSampleMessage(new protos.google.cloud.kms.v1.ImportJob()), + generateSampleMessage(new protos.google.cloud.kms.v1.ImportJob()), + ]; + client.innerApiCalls.listImportJobs = stubSimpleCall(expectedResponse); + const [response] = await client.listImportJobs(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listImportJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listImportJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('invokes listImportJobs without error using callback', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListImportJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListImportJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.kms.v1.ImportJob()), + generateSampleMessage(new protos.google.cloud.kms.v1.ImportJob()), + generateSampleMessage(new protos.google.cloud.kms.v1.ImportJob()), + ]; + client.innerApiCalls.listImportJobs = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listImportJobs( + request, + ( + err?: Error | null, + result?: protos.google.cloud.kms.v1.IImportJob[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listImportJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listImportJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('project', async () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - 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 listImportJobs with error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListImportJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListImportJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listImportJobs = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listImportJobs(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listImportJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listImportJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('invokes listImportJobsStream without error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListImportJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListImportJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.kms.v1.ImportJob()), + generateSampleMessage(new protos.google.cloud.kms.v1.ImportJob()), + generateSampleMessage(new protos.google.cloud.kms.v1.ImportJob()), + ]; + client.descriptors.page.listImportJobs.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listImportJobsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.kms.v1.ImportJob[] = []; + stream.on('data', (response: protos.google.cloud.kms.v1.ImportJob) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listImportJobs.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listImportJobs, request), + ); + assert( + (client.descriptors.page.listImportJobs.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - describe('projectAutokeyConfig', async () => { - const fakePath = "/rendered/path/projectAutokeyConfig"; - const expectedParameters = { - project: "projectValue", - }; - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectAutokeyConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectAutokeyConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectAutokeyConfigPath', () => { - const result = client.projectAutokeyConfigPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectAutokeyConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes listImportJobsStream with error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListImportJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListImportJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listImportJobs.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listImportJobsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.kms.v1.ImportJob[] = []; + stream.on('data', (response: protos.google.cloud.kms.v1.ImportJob) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listImportJobs.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listImportJobs, request), + ); + assert( + (client.descriptors.page.listImportJobs.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('matchProjectFromProjectAutokeyConfigName', () => { - const result = client.matchProjectFromProjectAutokeyConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectAutokeyConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('uses async iteration with listImportJobs without error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListImportJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListImportJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.kms.v1.ImportJob()), + generateSampleMessage(new protos.google.cloud.kms.v1.ImportJob()), + generateSampleMessage(new protos.google.cloud.kms.v1.ImportJob()), + ]; + client.descriptors.page.listImportJobs.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.kms.v1.IImportJob[] = []; + const iterable = client.listImportJobsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listImportJobs.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listImportJobs.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - describe('publicKey', async () => { - const fakePath = "/rendered/path/publicKey"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - key_ring: "keyRingValue", - crypto_key: "cryptoKeyValue", - crypto_key_version: "cryptoKeyVersionValue", - }; - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.publicKeyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.publicKeyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('publicKeyPath', () => { - const result = client.publicKeyPath("projectValue", "locationValue", "keyRingValue", "cryptoKeyValue", "cryptoKeyVersionValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.publicKeyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('uses async iteration with listImportJobs with error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListImportJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListImportJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listImportJobs.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listImportJobsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.kms.v1.IImportJob[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listImportJobs.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listImportJobs.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listRetiredResources', () => { + it('invokes listRetiredResources without error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListRetiredResourcesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListRetiredResourcesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.kms.v1.RetiredResource()), + generateSampleMessage(new protos.google.cloud.kms.v1.RetiredResource()), + generateSampleMessage(new protos.google.cloud.kms.v1.RetiredResource()), + ]; + client.innerApiCalls.listRetiredResources = + stubSimpleCall(expectedResponse); + const [response] = await client.listRetiredResources(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listRetiredResources as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listRetiredResources as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchProjectFromPublicKeyName', () => { - const result = client.matchProjectFromPublicKeyName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.publicKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes listRetiredResources without error using callback', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListRetiredResourcesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListRetiredResourcesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.kms.v1.RetiredResource()), + generateSampleMessage(new protos.google.cloud.kms.v1.RetiredResource()), + generateSampleMessage(new protos.google.cloud.kms.v1.RetiredResource()), + ]; + client.innerApiCalls.listRetiredResources = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listRetiredResources( + request, + ( + err?: Error | null, + result?: protos.google.cloud.kms.v1.IRetiredResource[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listRetiredResources as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listRetiredResources as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchLocationFromPublicKeyName', () => { - const result = client.matchLocationFromPublicKeyName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.publicKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes listRetiredResources with error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListRetiredResourcesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListRetiredResourcesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listRetiredResources = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listRetiredResources(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listRetiredResources as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listRetiredResources as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchKeyRingFromPublicKeyName', () => { - const result = client.matchKeyRingFromPublicKeyName(fakePath); - assert.strictEqual(result, "keyRingValue"); - assert((client.pathTemplates.publicKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes listRetiredResourcesStream without error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListRetiredResourcesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListRetiredResourcesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.kms.v1.RetiredResource()), + generateSampleMessage(new protos.google.cloud.kms.v1.RetiredResource()), + generateSampleMessage(new protos.google.cloud.kms.v1.RetiredResource()), + ]; + client.descriptors.page.listRetiredResources.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listRetiredResourcesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.kms.v1.RetiredResource[] = []; + stream.on( + 'data', + (response: protos.google.cloud.kms.v1.RetiredResource) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listRetiredResources.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listRetiredResources, request), + ); + assert( + (client.descriptors.page.listRetiredResources.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('matchCryptoKeyFromPublicKeyName', () => { - const result = client.matchCryptoKeyFromPublicKeyName(fakePath); - assert.strictEqual(result, "cryptoKeyValue"); - assert((client.pathTemplates.publicKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes listRetiredResourcesStream with error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListRetiredResourcesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListRetiredResourcesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listRetiredResources.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listRetiredResourcesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.kms.v1.RetiredResource[] = []; + stream.on( + 'data', + (response: protos.google.cloud.kms.v1.RetiredResource) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listRetiredResources.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listRetiredResources, request), + ); + assert( + (client.descriptors.page.listRetiredResources.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('matchCryptoKeyVersionFromPublicKeyName', () => { - const result = client.matchCryptoKeyVersionFromPublicKeyName(fakePath); - assert.strictEqual(result, "cryptoKeyVersionValue"); - assert((client.pathTemplates.publicKeyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('uses async iteration with listRetiredResources without error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListRetiredResourcesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListRetiredResourcesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.kms.v1.RetiredResource()), + generateSampleMessage(new protos.google.cloud.kms.v1.RetiredResource()), + generateSampleMessage(new protos.google.cloud.kms.v1.RetiredResource()), + ]; + client.descriptors.page.listRetiredResources.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.kms.v1.IRetiredResource[] = []; + const iterable = client.listRetiredResourcesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listRetiredResources.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listRetiredResources.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - describe('retiredResource', async () => { - const fakePath = "/rendered/path/retiredResource"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - retired_resource: "retiredResourceValue", - }; - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.retiredResourcePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.retiredResourcePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('retiredResourcePath', () => { - const result = client.retiredResourcePath("projectValue", "locationValue", "retiredResourceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.retiredResourcePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('uses async iteration with listRetiredResources with error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.kms.v1.ListRetiredResourcesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.kms.v1.ListRetiredResourcesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listRetiredResources.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listRetiredResourcesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.kms.v1.IRetiredResource[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listRetiredResources.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listRetiredResources.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.getIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + it('invokes getIamPolicy without error using callback', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.getIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .getIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.getIamPolicy as SinonStub).getCall(0)); + }); + it('invokes getIamPolicy with error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.GetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.getIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = stubSimpleCall(expectedResponse); + const response = await client.setIamPolicy(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + it('invokes setIamPolicy without error using callback', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.Policy(), + ); + client.iamClient.setIamPolicy = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .setIamPolicy( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.Policy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.setIamPolicy as SinonStub).getCall(0)); + }); + it('invokes setIamPolicy with error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.SetIamPolicyRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects( + client.setIamPolicy(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = stubSimpleCall(expectedResponse); + const response = await client.testIamPermissions( + request, + expectedOptions, + ); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + it('invokes testIamPermissions without error using callback', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.iamClient.testIamPermissions = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client + .testIamPermissions( + request, + expectedOptions, + ( + err?: Error | null, + result?: IamProtos.google.iam.v1.TestIamPermissionsResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ) + .catch((err) => { + throw err; + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.iamClient.testIamPermissions as SinonStub).getCall(0)); + }); + it('invokes testIamPermissions with error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new IamProtos.google.iam.v1.TestIamPermissionsRequest(), + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.iamClient.testIamPermissions = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.testIamPermissions(request, expectedOptions), + expectedError, + ); + assert( + (client.iamClient.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined), + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + 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 keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + 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 keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + 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 keymanagementserviceModule.v1.KeyManagementServiceClient({ + 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 keymanagementserviceModule.v1.KeyManagementServiceClient({ + 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 keymanagementserviceModule.v1.KeyManagementServiceClient({ + 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 keymanagementserviceModule.v1.KeyManagementServiceClient({ + 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 keymanagementserviceModule.v1.KeyManagementServiceClient({ + 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 keymanagementserviceModule.v1.KeyManagementServiceClient({ + 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 keymanagementserviceModule.v1.KeyManagementServiceClient({ + 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 keymanagementserviceModule.v1.KeyManagementServiceClient({ + 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 keymanagementserviceModule.v1.KeyManagementServiceClient({ + 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 keymanagementserviceModule.v1.KeyManagementServiceClient({ + 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 keymanagementserviceModule.v1.KeyManagementServiceClient({ + 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 keymanagementserviceModule.v1.KeyManagementServiceClient({ + 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 keymanagementserviceModule.v1.KeyManagementServiceClient({ + 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('cryptoKey', async () => { + const fakePath = '/rendered/path/cryptoKey'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + key_ring: 'keyRingValue', + crypto_key: 'cryptoKeyValue', + }; + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + 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), + ); + }); + }); - it('matchProjectFromRetiredResourceName', () => { - const result = client.matchProjectFromRetiredResourceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.retiredResourcePathTemplate.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 keymanagementserviceModule.v1.KeyManagementServiceClient({ + 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), + ); + }); + }); - it('matchLocationFromRetiredResourceName', () => { - const result = client.matchLocationFromRetiredResourceName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.retiredResourcePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('ekmConfig', async () => { + const fakePath = '/rendered/path/ekmConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.ekmConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.ekmConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('ekmConfigPath', () => { + const result = client.ekmConfigPath('projectValue', 'locationValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.ekmConfigPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromEkmConfigName', () => { + const result = client.matchProjectFromEkmConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.ekmConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromEkmConfigName', () => { + const result = client.matchLocationFromEkmConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.ekmConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchRetiredResourceFromRetiredResourceName', () => { - const result = client.matchRetiredResourceFromRetiredResourceName(fakePath); - assert.strictEqual(result, "retiredResourceValue"); - assert((client.pathTemplates.retiredResourcePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('ekmConnection', async () => { + const fakePath = '/rendered/path/ekmConnection'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + ekm_connection: 'ekmConnectionValue', + }; + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.ekmConnectionPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.ekmConnectionPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('ekmConnectionPath', () => { + const result = client.ekmConnectionPath( + 'projectValue', + 'locationValue', + 'ekmConnectionValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.ekmConnectionPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromEkmConnectionName', () => { + const result = client.matchProjectFromEkmConnectionName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.ekmConnectionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromEkmConnectionName', () => { + const result = client.matchLocationFromEkmConnectionName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.ekmConnectionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchEkmConnectionFromEkmConnectionName', () => { + const result = client.matchEkmConnectionFromEkmConnectionName(fakePath); + assert.strictEqual(result, 'ekmConnectionValue'); + assert( + (client.pathTemplates.ekmConnectionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('singleTenantHsmInstance', async () => { - const fakePath = "/rendered/path/singleTenantHsmInstance"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - single_tenant_hsm_instance: "singleTenantHsmInstanceValue", - }; - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.singleTenantHsmInstancePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.singleTenantHsmInstancePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('singleTenantHsmInstancePath', () => { - const result = client.singleTenantHsmInstancePath("projectValue", "locationValue", "singleTenantHsmInstanceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.singleTenantHsmInstancePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + describe('folderAutokeyConfig', async () => { + const fakePath = '/rendered/path/folderAutokeyConfig'; + const expectedParameters = { + folder: 'folderValue', + }; + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.folderAutokeyConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.folderAutokeyConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('folderAutokeyConfigPath', () => { + const result = client.folderAutokeyConfigPath('folderValue'); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.folderAutokeyConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchFolderFromFolderAutokeyConfigName', () => { + const result = client.matchFolderFromFolderAutokeyConfigName(fakePath); + assert.strictEqual(result, 'folderValue'); + assert( + ( + client.pathTemplates.folderAutokeyConfigPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchProjectFromSingleTenantHsmInstanceName', () => { - const result = client.matchProjectFromSingleTenantHsmInstanceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.singleTenantHsmInstancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('importJob', async () => { + const fakePath = '/rendered/path/importJob'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + key_ring: 'keyRingValue', + import_job: 'importJobValue', + }; + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.importJobPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.importJobPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('importJobPath', () => { + const result = client.importJobPath( + 'projectValue', + 'locationValue', + 'keyRingValue', + 'importJobValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.importJobPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromImportJobName', () => { + const result = client.matchProjectFromImportJobName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.importJobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromImportJobName', () => { + const result = client.matchLocationFromImportJobName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.importJobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchKeyRingFromImportJobName', () => { + const result = client.matchKeyRingFromImportJobName(fakePath); + assert.strictEqual(result, 'keyRingValue'); + assert( + (client.pathTemplates.importJobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchImportJobFromImportJobName', () => { + const result = client.matchImportJobFromImportJobName(fakePath); + assert.strictEqual(result, 'importJobValue'); + assert( + (client.pathTemplates.importJobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchLocationFromSingleTenantHsmInstanceName', () => { - const result = client.matchLocationFromSingleTenantHsmInstanceName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.singleTenantHsmInstancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('keyHandle', async () => { + const fakePath = '/rendered/path/keyHandle'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + key_handle: 'keyHandleValue', + }; + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.keyHandlePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.keyHandlePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('keyHandlePath', () => { + const result = client.keyHandlePath( + 'projectValue', + 'locationValue', + 'keyHandleValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.keyHandlePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromKeyHandleName', () => { + const result = client.matchProjectFromKeyHandleName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.keyHandlePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromKeyHandleName', () => { + const result = client.matchLocationFromKeyHandleName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.keyHandlePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchKeyHandleFromKeyHandleName', () => { + const result = client.matchKeyHandleFromKeyHandleName(fakePath); + assert.strictEqual(result, 'keyHandleValue'); + assert( + (client.pathTemplates.keyHandlePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceName', () => { - const result = client.matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceName(fakePath); - assert.strictEqual(result, "singleTenantHsmInstanceValue"); - assert((client.pathTemplates.singleTenantHsmInstancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('keyRing', async () => { + const fakePath = '/rendered/path/keyRing'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + key_ring: 'keyRingValue', + }; + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.keyRingPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.keyRingPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('keyRingPath', () => { + const result = client.keyRingPath( + 'projectValue', + 'locationValue', + 'keyRingValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.keyRingPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromKeyRingName', () => { + const result = client.matchProjectFromKeyRingName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.keyRingPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromKeyRingName', () => { + const result = client.matchLocationFromKeyRingName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.keyRingPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchKeyRingFromKeyRingName', () => { + const result = client.matchKeyRingFromKeyRingName(fakePath); + assert.strictEqual(result, 'keyRingValue'); + assert( + (client.pathTemplates.keyRingPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('singleTenantHsmInstanceProposal', async () => { - const fakePath = "/rendered/path/singleTenantHsmInstanceProposal"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - single_tenant_hsm_instance: "singleTenantHsmInstanceValue", - proposal: "proposalValue", - }; - const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('singleTenantHsmInstanceProposalPath', () => { - const result = client.singleTenantHsmInstanceProposalPath("projectValue", "locationValue", "singleTenantHsmInstanceValue", "proposalValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + describe('location', async () => { + const fakePath = '/rendered/path/location'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + 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('matchProjectFromSingleTenantHsmInstanceProposalName', () => { - const result = client.matchProjectFromSingleTenantHsmInstanceProposalName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('project', async () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + 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('matchLocationFromSingleTenantHsmInstanceProposalName', () => { - const result = client.matchLocationFromSingleTenantHsmInstanceProposalName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('projectAutokeyConfig', async () => { + const fakePath = '/rendered/path/projectAutokeyConfig'; + const expectedParameters = { + project: 'projectValue', + }; + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectAutokeyConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectAutokeyConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectAutokeyConfigPath', () => { + const result = client.projectAutokeyConfigPath('projectValue'); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectAutokeyConfigPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectAutokeyConfigName', () => { + const result = + client.matchProjectFromProjectAutokeyConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.projectAutokeyConfigPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceProposalName', () => { - const result = client.matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceProposalName(fakePath); - assert.strictEqual(result, "singleTenantHsmInstanceValue"); - assert((client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('publicKey', async () => { + const fakePath = '/rendered/path/publicKey'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + key_ring: 'keyRingValue', + crypto_key: 'cryptoKeyValue', + crypto_key_version: 'cryptoKeyVersionValue', + }; + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.publicKeyPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.publicKeyPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('publicKeyPath', () => { + const result = client.publicKeyPath( + 'projectValue', + 'locationValue', + 'keyRingValue', + 'cryptoKeyValue', + 'cryptoKeyVersionValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.publicKeyPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromPublicKeyName', () => { + const result = client.matchProjectFromPublicKeyName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.publicKeyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromPublicKeyName', () => { + const result = client.matchLocationFromPublicKeyName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.publicKeyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchKeyRingFromPublicKeyName', () => { + const result = client.matchKeyRingFromPublicKeyName(fakePath); + assert.strictEqual(result, 'keyRingValue'); + assert( + (client.pathTemplates.publicKeyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCryptoKeyFromPublicKeyName', () => { + const result = client.matchCryptoKeyFromPublicKeyName(fakePath); + assert.strictEqual(result, 'cryptoKeyValue'); + assert( + (client.pathTemplates.publicKeyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCryptoKeyVersionFromPublicKeyName', () => { + const result = client.matchCryptoKeyVersionFromPublicKeyName(fakePath); + assert.strictEqual(result, 'cryptoKeyVersionValue'); + assert( + (client.pathTemplates.publicKeyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchProposalFromSingleTenantHsmInstanceProposalName', () => { - const result = client.matchProposalFromSingleTenantHsmInstanceProposalName(fakePath); - assert.strictEqual(result, "proposalValue"); - assert((client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('retiredResource', async () => { + const fakePath = '/rendered/path/retiredResource'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + retired_resource: 'retiredResourceValue', + }; + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.retiredResourcePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.retiredResourcePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('retiredResourcePath', () => { + const result = client.retiredResourcePath( + 'projectValue', + 'locationValue', + 'retiredResourceValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.retiredResourcePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromRetiredResourceName', () => { + const result = client.matchProjectFromRetiredResourceName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.retiredResourcePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromRetiredResourceName', () => { + const result = client.matchLocationFromRetiredResourceName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.retiredResourcePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRetiredResourceFromRetiredResourceName', () => { + const result = + client.matchRetiredResourceFromRetiredResourceName(fakePath); + assert.strictEqual(result, 'retiredResourceValue'); + assert( + (client.pathTemplates.retiredResourcePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('singleTenantHsmInstance', async () => { + const fakePath = '/rendered/path/singleTenantHsmInstance'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + single_tenant_hsm_instance: 'singleTenantHsmInstanceValue', + }; + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.singleTenantHsmInstancePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.singleTenantHsmInstancePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('singleTenantHsmInstancePath', () => { + const result = client.singleTenantHsmInstancePath( + 'projectValue', + 'locationValue', + 'singleTenantHsmInstanceValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.singleTenantHsmInstancePathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromSingleTenantHsmInstanceName', () => { + const result = + client.matchProjectFromSingleTenantHsmInstanceName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.singleTenantHsmInstancePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromSingleTenantHsmInstanceName', () => { + const result = + client.matchLocationFromSingleTenantHsmInstanceName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.singleTenantHsmInstancePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceName', () => { + const result = + client.matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceName( + fakePath, + ); + assert.strictEqual(result, 'singleTenantHsmInstanceValue'); + assert( + ( + client.pathTemplates.singleTenantHsmInstancePathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('singleTenantHsmInstanceProposal', async () => { + const fakePath = '/rendered/path/singleTenantHsmInstanceProposal'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + single_tenant_hsm_instance: 'singleTenantHsmInstanceValue', + proposal: 'proposalValue', + }; + const client = + new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('singleTenantHsmInstanceProposalPath', () => { + const result = client.singleTenantHsmInstanceProposalPath( + 'projectValue', + 'locationValue', + 'singleTenantHsmInstanceValue', + 'proposalValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromSingleTenantHsmInstanceProposalName', () => { + const result = + client.matchProjectFromSingleTenantHsmInstanceProposalName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromSingleTenantHsmInstanceProposalName', () => { + const result = + client.matchLocationFromSingleTenantHsmInstanceProposalName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceProposalName', () => { + const result = + client.matchSingleTenantHsmInstanceFromSingleTenantHsmInstanceProposalName( + fakePath, + ); + assert.strictEqual(result, 'singleTenantHsmInstanceValue'); + assert( + ( + client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchProposalFromSingleTenantHsmInstanceProposalName', () => { + const result = + client.matchProposalFromSingleTenantHsmInstanceProposalName(fakePath); + assert.strictEqual(result, 'proposalValue'); + assert( + ( + client.pathTemplates.singleTenantHsmInstanceProposalPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-kms/webpack.config.js b/packages/google-cloud-kms/webpack.config.js index 144ccfe3c183..cb391e3cc5da 100644 --- a/packages/google-cloud-kms/webpack.config.js +++ b/packages/google-cloud-kms/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-language/.eslintignore b/packages/google-cloud-language/.eslintignore new file mode 100644 index 000000000000..cfc348ec4d11 --- /dev/null +++ b/packages/google-cloud-language/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/packages/google-cloud-language/.eslintrc.json b/packages/google-cloud-language/.eslintrc.json new file mode 100644 index 000000000000..3e8d97ccb390 --- /dev/null +++ b/packages/google-cloud-language/.eslintrc.json @@ -0,0 +1,4 @@ +{ + "extends": "./node_modules/gts", + "root": true +} diff --git a/packages/google-cloud-language/README.md b/packages/google-cloud-language/README.md index d5fc7da2c717..4ab7a8933171 100644 --- a/packages/google-cloud-language/README.md +++ b/packages/google-cloud-language/README.md @@ -113,7 +113,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-language/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`) @@ -123,7 +123,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-language/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-language/protos/protos.d.ts b/packages/google-cloud-language/protos/protos.d.ts index 39e327230514..25b0c72a5a29 100644 --- a/packages/google-cloud-language/protos/protos.d.ts +++ b/packages/google-cloud-language/protos/protos.d.ts @@ -9602,6 +9602,9 @@ export namespace google { /** CommonLanguageSettings destinations */ destinations?: (google.api.ClientLibraryDestination[]|null); + + /** CommonLanguageSettings selectiveGapicGeneration */ + selectiveGapicGeneration?: (google.api.ISelectiveGapicGeneration|null); } /** Represents a CommonLanguageSettings. */ @@ -9619,6 +9622,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 @@ -10319,6 +10325,9 @@ export namespace google { /** PythonSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** PythonSettings experimentalFeatures */ + experimentalFeatures?: (google.api.PythonSettings.IExperimentalFeatures|null); } /** Represents a PythonSettings. */ @@ -10333,6 +10342,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 @@ -10411,6 +10423,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 { @@ -10737,6 +10861,9 @@ export namespace google { /** GoSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** GoSettings renamedServices */ + renamedServices?: ({ [k: string]: string }|null); } /** Represents a GoSettings. */ @@ -10751,6 +10878,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 @@ -11075,6 +11205,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, @@ -11204,6 +11437,7 @@ export namespace google { /** Edition enum. */ enum Edition { EDITION_UNKNOWN = 0, + EDITION_LEGACY = 900, EDITION_PROTO2 = 998, EDITION_PROTO3 = 999, EDITION_2023 = 1000, @@ -11234,6 +11468,9 @@ export namespace google { /** FileDescriptorProto weakDependency */ weakDependency?: (number[]|null); + /** FileDescriptorProto optionDependency */ + optionDependency?: (string[]|null); + /** FileDescriptorProto messageType */ messageType?: (google.protobuf.IDescriptorProto[]|null); @@ -11283,6 +11520,9 @@ export namespace google { /** FileDescriptorProto weakDependency. */ public weakDependency: number[]; + /** FileDescriptorProto optionDependency. */ + public optionDependency: string[]; + /** FileDescriptorProto messageType. */ public messageType: google.protobuf.IDescriptorProto[]; @@ -11417,6 +11657,9 @@ export namespace google { /** DescriptorProto reservedName */ reservedName?: (string[]|null); + + /** DescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents a DescriptorProto. */ @@ -11458,6 +11701,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 @@ -12305,6 +12551,9 @@ export namespace google { /** EnumDescriptorProto reservedName */ reservedName?: (string[]|null); + + /** EnumDescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents an EnumDescriptorProto. */ @@ -12331,6 +12580,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 @@ -13259,6 +13511,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); @@ -13311,6 +13566,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[]; @@ -13531,6 +13789,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. */ @@ -13769,6 +14142,9 @@ export namespace google { /** EnumValueOptions debugRedact */ debugRedact?: (boolean|null); + /** EnumValueOptions featureSupport */ + featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** EnumValueOptions uninterpretedOption */ uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); } @@ -13791,6 +14167,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[]; @@ -14380,6 +14759,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. */ @@ -14409,6 +14794,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 @@ -14531,6 +14922,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. */ @@ -14650,8 +15151,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. */ @@ -14666,8 +15170,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. @@ -15200,6 +15707,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-language/protos/protos.js b/packages/google-cloud-language/protos/protos.js index 1e4b194b3438..33a910e11560 100644 --- a/packages/google-cloud-language/protos/protos.js +++ b/packages/google-cloud-language/protos/protos.js @@ -25679,6 +25679,7 @@ * @interface ICommonLanguageSettings * @property {string|null} [referenceDocsUri] CommonLanguageSettings referenceDocsUri * @property {Array.|null} [destinations] CommonLanguageSettings destinations + * @property {google.api.ISelectiveGapicGeneration|null} [selectiveGapicGeneration] CommonLanguageSettings selectiveGapicGeneration */ /** @@ -25713,6 +25714,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 @@ -25745,6 +25754,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; }; @@ -25796,6 +25807,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; @@ -25847,6 +25862,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; }; @@ -25889,6 +25909,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; }; @@ -25907,8 +25932,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) { @@ -25916,6 +25943,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; }; @@ -27738,6 +27767,7 @@ * @memberof google.api * @interface IPythonSettings * @property {google.api.ICommonLanguageSettings|null} [common] PythonSettings common + * @property {google.api.PythonSettings.IExperimentalFeatures|null} [experimentalFeatures] PythonSettings experimentalFeatures */ /** @@ -27763,6 +27793,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 @@ -27789,6 +27827,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; }; @@ -27829,6 +27869,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; @@ -27869,6 +27913,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; }; @@ -27889,6 +27938,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; }; @@ -27905,10 +27959,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; }; @@ -27938,6 +27996,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; })(); @@ -28814,6 +29124,7 @@ * @memberof google.api * @interface IGoSettings * @property {google.api.ICommonLanguageSettings|null} [common] GoSettings common + * @property {Object.|null} [renamedServices] GoSettings renamedServices */ /** @@ -28825,6 +29136,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) @@ -28839,6 +29151,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 @@ -28865,6 +29185,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; }; @@ -28895,7 +29218,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) @@ -28905,6 +29228,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; @@ -28945,6 +29291,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; }; @@ -28965,6 +29319,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; }; @@ -28981,10 +29342,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; }; @@ -29623,30 +29992,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; })(); /** @@ -29920,6 +30534,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 @@ -29934,6 +30549,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; @@ -29958,6 +30574,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 @@ -29980,6 +30597,7 @@ this.dependency = []; this.publicDependency = []; this.weakDependency = []; + this.optionDependency = []; this.messageType = []; this.enumType = []; this.service = []; @@ -30030,6 +30648,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 @@ -30151,6 +30777,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; }; @@ -30223,6 +30852,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 = []; @@ -30325,6 +30960,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"; @@ -30379,6 +31021,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -30431,6 +31074,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"); @@ -30494,6 +31144,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -30559,6 +31213,7 @@ object.extension = []; object.publicDependency = []; object.weakDependency = []; + object.optionDependency = []; } if (options.defaults) { object.name = ""; @@ -30615,6 +31270,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; }; @@ -30663,6 +31323,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 */ /** @@ -30768,6 +31429,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 @@ -30820,6 +31489,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; }; @@ -30912,6 +31583,10 @@ message.reservedName.push(reader.string()); break; } + case 11: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -31025,6 +31700,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; }; @@ -31124,6 +31808,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; }; @@ -31153,6 +31857,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; @@ -31198,6 +31903,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; }; @@ -33242,6 +33949,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 */ /** @@ -33302,6 +34010,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 @@ -33339,6 +34055,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; }; @@ -33401,6 +34119,10 @@ message.reservedName.push(reader.string()); break; } + case 6: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -33469,6 +34191,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; }; @@ -33518,6 +34249,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; }; @@ -33542,6 +34293,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; @@ -33562,6 +34314,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; }; @@ -35807,6 +36561,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 */ @@ -35926,6 +36681,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 @@ -35992,6 +36755,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(); @@ -36091,6 +36856,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 = []; @@ -36222,6 +36991,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"; @@ -36405,6 +37179,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"); @@ -36497,6 +37276,7 @@ object.debugRedact = false; object.retention = options.enums === String ? "RETENTION_UNKNOWN" : 0; object.features = null; + object.featureSupport = null; } if (message.ctype != null && message.hasOwnProperty("ctype")) object.ctype = options.enums === String ? $root.google.protobuf.FieldOptions.CType[message.ctype] === undefined ? message.ctype : $root.google.protobuf.FieldOptions.CType[message.ctype] : message.ctype; @@ -36528,6 +37308,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) @@ -36798,6 +37580,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -36839,103 +37622,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; @@ -37530,6 +38799,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 */ @@ -37573,6 +38843,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 @@ -37611,6 +38889,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(); @@ -37662,6 +38942,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 = []; @@ -37714,6 +38998,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"; @@ -37747,6 +39036,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"); @@ -37779,6 +39073,7 @@ object.deprecated = false; object.features = null; object.debugRedact = false; + object.featureSupport = null; } if (message.deprecated != null && message.hasOwnProperty("deprecated")) object.deprecated = message.deprecated; @@ -37786,6 +39081,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) @@ -39225,6 +40522,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 */ /** @@ -39290,6 +40589,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 @@ -39326,6 +40641,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; }; @@ -39386,6 +40705,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; @@ -39476,6 +40803,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; }; @@ -39615,6 +40962,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; }; @@ -39638,6 +41033,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; @@ -39651,6 +41048,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; }; @@ -39778,6 +41179,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; })(); @@ -39962,6 +41576,7 @@ default: return "minimumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -39979,6 +41594,7 @@ default: return "maximumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -40027,6 +41643,10 @@ case 0: message.minimumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.minimumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.minimumEdition = 998; @@ -40079,6 +41699,10 @@ case 0: message.maximumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.maximumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.maximumEdition = 998; @@ -40187,7 +41811,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 */ /** @@ -40214,12 +41839,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. @@ -40245,10 +41878,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; }; @@ -40289,8 +41924,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: @@ -40333,6 +41972,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -40345,10 +41985,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; }; @@ -40376,6 +42021,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -40417,10 +42066,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; }; @@ -40439,13 +42093,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; }; @@ -41660,6 +43317,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-language/protos/protos.json b/packages/google-cloud-language/protos/protos.json index 4fc2afecbc64..10de857e2cd7 100644 --- a/packages/google-cloud-language/protos/protos.json +++ b/packages/google-cloud-language/protos/protos.json @@ -2457,8 +2457,7 @@ "java_multiple_files": true, "java_outer_classname": "FieldBehaviorProto", "java_package": "com.google.api", - "objc_class_prefix": "GAPI", - "cc_enable_arenas": true + "objc_class_prefix": "GAPI" }, "nested": { "http": { @@ -2582,6 +2581,10 @@ "rule": "repeated", "type": "ClientLibraryDestination", "id": 2 + }, + "selectiveGapicGeneration": { + "type": "SelectiveGapicGeneration", + "id": 3 } } }, @@ -2722,6 +2725,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 + } + } } } }, @@ -2779,6 +2804,11 @@ "common": { "type": "CommonLanguageSettings", "id": 1 + }, + "renamedServices": { + "keyType": "string", + "type": "string", + "id": 2 } } }, @@ -2840,6 +2870,19 @@ "PACKAGE_MANAGER": 20 } }, + "SelectiveGapicGeneration": { + "fields": { + "methods": { + "rule": "repeated", + "type": "string", + "id": 1 + }, + "generateOmittedAsInternal": { + "type": "bool", + "id": 2 + } + } + }, "LaunchStage": { "values": { "LAUNCH_STAGE_UNSPECIFIED": 0, @@ -2895,12 +2938,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, @@ -2939,6 +2989,11 @@ "type": "int32", "id": 11 }, + "optionDependency": { + "rule": "repeated", + "type": "string", + "id": 15 + }, "messageType": { "rule": "repeated", "type": "DescriptorProto", @@ -3027,6 +3082,10 @@ "rule": "repeated", "type": "string", "id": 10 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 11 } }, "nested": { @@ -3252,6 +3311,10 @@ "rule": "repeated", "type": "string", "id": 5 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 6 } }, "nested": { @@ -3302,7 +3365,14 @@ "type": "ServiceOptions", "id": 3 } - } + }, + "reserved": [ + [ + 4, + 4 + ], + "stream" + ] }, "MethodDescriptorProto": { "edition": "proto2", @@ -3466,6 +3536,7 @@ 42, 42 ], + "php_generic_services", [ 38, 38 @@ -3601,7 +3672,8 @@ "type": "bool", "id": 10, "options": { - "default": false + "default": false, + "deprecated": true } }, "debugRedact": { @@ -3629,6 +3701,10 @@ "type": "FeatureSet", "id": 21 }, + "featureSupport": { + "type": "FeatureSupport", + "id": 22 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -3698,6 +3774,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 + } + } } } }, @@ -3786,6 +3882,10 @@ "default": false } }, + "featureSupport": { + "type": "FieldOptions.FeatureSupport", + "id": 4 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -3928,6 +4028,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_2023", "edition_defaults.value": "EXPLICIT" } @@ -3938,6 +4039,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "OPEN" } @@ -3948,6 +4050,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "PACKED" } @@ -3958,6 +4061,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "VERIFY" } @@ -3968,7 +4072,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" } }, @@ -3978,27 +4083,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, @@ -4043,7 +4159,13 @@ "UTF8_VALIDATION_UNKNOWN": 0, "VERIFY": 2, "NONE": 3 - } + }, + "reserved": [ + [ + 1, + 1 + ] + ] }, "MessageEncoding": { "values": { @@ -4058,6 +4180,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 + } + } + } } } }, @@ -4085,11 +4234,26 @@ "type": "Edition", "id": 3 }, - "features": { + "overridableFeatures": { "type": "FeatureSet", - "id": 2 + "id": 4 + }, + "fixedFeatures": { + "type": "FeatureSet", + "id": 5 } - } + }, + "reserved": [ + [ + 1, + 1 + ], + [ + 2, + 2 + ], + "features" + ] } } }, @@ -4102,6 +4266,12 @@ "id": 1 } }, + "extensions": [ + [ + 536000000, + 536000000 + ] + ], "nested": { "Location": { "fields": { @@ -4187,6 +4357,14 @@ } } }, + "SymbolVisibility": { + "edition": "proto2", + "values": { + "VISIBILITY_UNSET": 0, + "VISIBILITY_LOCAL": 1, + "VISIBILITY_EXPORT": 2 + } + }, "Duration": { "fields": { "seconds": { diff --git a/packages/google-cloud-language/samples/generated/v1/snippet_metadata_google.cloud.language.v1.json b/packages/google-cloud-language/samples/generated/v1/snippet_metadata_google.cloud.language.v1.json index cddd3b30e09a..0ac8ed666eab 100644 --- a/packages/google-cloud-language/samples/generated/v1/snippet_metadata_google.cloud.language.v1.json +++ b/packages/google-cloud-language/samples/generated/v1/snippet_metadata_google.cloud.language.v1.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-language", - "version": "7.2.1", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-language/samples/generated/v1beta2/snippet_metadata_google.cloud.language.v1beta2.json b/packages/google-cloud-language/samples/generated/v1beta2/snippet_metadata_google.cloud.language.v1beta2.json index 827a14bc99ec..7f46630d8de9 100644 --- a/packages/google-cloud-language/samples/generated/v1beta2/snippet_metadata_google.cloud.language.v1beta2.json +++ b/packages/google-cloud-language/samples/generated/v1beta2/snippet_metadata_google.cloud.language.v1beta2.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-language", - "version": "7.2.1", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-language/samples/generated/v2/snippet_metadata_google.cloud.language.v2.json b/packages/google-cloud-language/samples/generated/v2/snippet_metadata_google.cloud.language.v2.json index b4293d73fe60..659ea31f0256 100644 --- a/packages/google-cloud-language/samples/generated/v2/snippet_metadata_google.cloud.language.v2.json +++ b/packages/google-cloud-language/samples/generated/v2/snippet_metadata_google.cloud.language.v2.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-language", - "version": "7.2.1", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-language/src/v1/index.ts b/packages/google-cloud-language/src/v1/index.ts index 0350a5e24651..8fa13e0c2233 100644 --- a/packages/google-cloud-language/src/v1/index.ts +++ b/packages/google-cloud-language/src/v1/index.ts @@ -16,4 +16,4 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {LanguageServiceClient} from './language_service_client'; +export { LanguageServiceClient } from './language_service_client'; diff --git a/packages/google-cloud-language/src/v1/language_service_client.ts b/packages/google-cloud-language/src/v1/language_service_client.ts index c34f1e6ddbff..e11020615927 100644 --- a/packages/google-cloud-language/src/v1/language_service_client.ts +++ b/packages/google-cloud-language/src/v1/language_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 @@ -45,7 +50,7 @@ export class LanguageServiceClient { 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('language'); @@ -58,8 +63,8 @@ export class LanguageServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - languageServiceStub?: Promise<{[name: string]: Function}>; + innerApiCalls: { [name: string]: Function }; + languageServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of LanguageServiceClient. @@ -100,21 +105,42 @@ export class LanguageServiceClient { * const client = new LanguageServiceClient({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 LanguageServiceClient; - 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 = 'language.' + 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 LanguageServiceClient { 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 LanguageServiceClient { } // 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 { @@ -175,8 +198,11 @@ export class LanguageServiceClient { // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.language.v1.LanguageService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.language.v1.LanguageService', + 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 @@ -207,36 +233,48 @@ export class LanguageServiceClient { // Put together the "service stub" for // google.cloud.language.v1.LanguageService. this.languageServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.language.v1.LanguageService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.language.v1.LanguageService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.language.v1.LanguageService, - 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 languageServiceStubMethods = - ['analyzeSentiment', 'analyzeEntities', 'analyzeEntitySentiment', 'analyzeSyntax', 'classifyText', 'moderateText', 'annotateText']; + const languageServiceStubMethods = [ + 'analyzeSentiment', + 'analyzeEntities', + 'analyzeEntitySentiment', + 'analyzeSyntax', + 'classifyText', + 'moderateText', + 'annotateText', + ]; for (const methodName of languageServiceStubMethods) { const callPromise = this.languageServiceStub.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; @@ -251,8 +289,14 @@ export class LanguageServiceClient { * @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 'language.googleapis.com'; } @@ -263,8 +307,14 @@ export class LanguageServiceClient { * @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 'language.googleapis.com'; } @@ -297,7 +347,7 @@ export class LanguageServiceClient { static get scopes() { return [ 'https://www.googleapis.com/auth/cloud-language', - 'https://www.googleapis.com/auth/cloud-platform' + 'https://www.googleapis.com/auth/cloud-platform', ]; } @@ -307,8 +357,9 @@ export class LanguageServiceClient { * 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; @@ -319,654 +370,925 @@ export class LanguageServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Analyzes the sentiment of the provided text. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.language.v1.Document} request.document - * Required. Input document. - * @param {google.cloud.language.v1.EncodingType} request.encodingType - * The encoding type used by the API to calculate sentence offsets. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.language.v1.AnalyzeSentimentResponse|AnalyzeSentimentResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/language_service.analyze_sentiment.js - * region_tag:language_v1_generated_LanguageService_AnalyzeSentiment_async - */ + /** + * Analyzes the sentiment of the provided text. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.language.v1.Document} request.document + * Required. Input document. + * @param {google.cloud.language.v1.EncodingType} request.encodingType + * The encoding type used by the API to calculate sentence offsets. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.language.v1.AnalyzeSentimentResponse|AnalyzeSentimentResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/language_service.analyze_sentiment.js + * region_tag:language_v1_generated_LanguageService_AnalyzeSentiment_async + */ analyzeSentiment( - request?: protos.google.cloud.language.v1.IAnalyzeSentimentRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.language.v1.IAnalyzeSentimentResponse, - protos.google.cloud.language.v1.IAnalyzeSentimentRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.language.v1.IAnalyzeSentimentRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.language.v1.IAnalyzeSentimentResponse, + protos.google.cloud.language.v1.IAnalyzeSentimentRequest | undefined, + {} | undefined, + ] + >; analyzeSentiment( - request: protos.google.cloud.language.v1.IAnalyzeSentimentRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.language.v1.IAnalyzeSentimentResponse, - protos.google.cloud.language.v1.IAnalyzeSentimentRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.language.v1.IAnalyzeSentimentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.language.v1.IAnalyzeSentimentResponse, + | protos.google.cloud.language.v1.IAnalyzeSentimentRequest + | null + | undefined, + {} | null | undefined + >, + ): void; analyzeSentiment( - request: protos.google.cloud.language.v1.IAnalyzeSentimentRequest, - callback: Callback< - protos.google.cloud.language.v1.IAnalyzeSentimentResponse, - protos.google.cloud.language.v1.IAnalyzeSentimentRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.language.v1.IAnalyzeSentimentRequest, + callback: Callback< + protos.google.cloud.language.v1.IAnalyzeSentimentResponse, + | protos.google.cloud.language.v1.IAnalyzeSentimentRequest + | null + | undefined, + {} | null | undefined + >, + ): void; analyzeSentiment( - request?: protos.google.cloud.language.v1.IAnalyzeSentimentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.language.v1.IAnalyzeSentimentResponse, - protos.google.cloud.language.v1.IAnalyzeSentimentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.language.v1.IAnalyzeSentimentRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.language.v1.IAnalyzeSentimentResponse, - protos.google.cloud.language.v1.IAnalyzeSentimentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.language.v1.IAnalyzeSentimentResponse, - protos.google.cloud.language.v1.IAnalyzeSentimentRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.language.v1.IAnalyzeSentimentRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.language.v1.IAnalyzeSentimentResponse, + | protos.google.cloud.language.v1.IAnalyzeSentimentRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.language.v1.IAnalyzeSentimentResponse, + protos.google.cloud.language.v1.IAnalyzeSentimentRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === '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('analyzeSentiment request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.language.v1.IAnalyzeSentimentResponse, - protos.google.cloud.language.v1.IAnalyzeSentimentRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.language.v1.IAnalyzeSentimentResponse, + | protos.google.cloud.language.v1.IAnalyzeSentimentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('analyzeSentiment response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.analyzeSentiment(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.language.v1.IAnalyzeSentimentResponse, - protos.google.cloud.language.v1.IAnalyzeSentimentRequest|undefined, - {}|undefined - ]) => { - this._log.info('analyzeSentiment response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .analyzeSentiment(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.language.v1.IAnalyzeSentimentResponse, + protos.google.cloud.language.v1.IAnalyzeSentimentRequest | undefined, + {} | undefined, + ]) => { + this._log.info('analyzeSentiment response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Finds named entities (currently proper names and common nouns) in the text - * along with entity types, salience, mentions for each entity, and - * other properties. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.language.v1.Document} request.document - * Required. Input document. - * @param {google.cloud.language.v1.EncodingType} request.encodingType - * The encoding type used by the API to calculate offsets. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.language.v1.AnalyzeEntitiesResponse|AnalyzeEntitiesResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/language_service.analyze_entities.js - * region_tag:language_v1_generated_LanguageService_AnalyzeEntities_async - */ + /** + * Finds named entities (currently proper names and common nouns) in the text + * along with entity types, salience, mentions for each entity, and + * other properties. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.language.v1.Document} request.document + * Required. Input document. + * @param {google.cloud.language.v1.EncodingType} request.encodingType + * The encoding type used by the API to calculate offsets. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.language.v1.AnalyzeEntitiesResponse|AnalyzeEntitiesResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/language_service.analyze_entities.js + * region_tag:language_v1_generated_LanguageService_AnalyzeEntities_async + */ analyzeEntities( - request?: protos.google.cloud.language.v1.IAnalyzeEntitiesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.language.v1.IAnalyzeEntitiesResponse, - protos.google.cloud.language.v1.IAnalyzeEntitiesRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.language.v1.IAnalyzeEntitiesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.language.v1.IAnalyzeEntitiesResponse, + protos.google.cloud.language.v1.IAnalyzeEntitiesRequest | undefined, + {} | undefined, + ] + >; analyzeEntities( - request: protos.google.cloud.language.v1.IAnalyzeEntitiesRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.language.v1.IAnalyzeEntitiesResponse, - protos.google.cloud.language.v1.IAnalyzeEntitiesRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.language.v1.IAnalyzeEntitiesRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.language.v1.IAnalyzeEntitiesResponse, + | protos.google.cloud.language.v1.IAnalyzeEntitiesRequest + | null + | undefined, + {} | null | undefined + >, + ): void; analyzeEntities( - request: protos.google.cloud.language.v1.IAnalyzeEntitiesRequest, - callback: Callback< - protos.google.cloud.language.v1.IAnalyzeEntitiesResponse, - protos.google.cloud.language.v1.IAnalyzeEntitiesRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.language.v1.IAnalyzeEntitiesRequest, + callback: Callback< + protos.google.cloud.language.v1.IAnalyzeEntitiesResponse, + | protos.google.cloud.language.v1.IAnalyzeEntitiesRequest + | null + | undefined, + {} | null | undefined + >, + ): void; analyzeEntities( - request?: protos.google.cloud.language.v1.IAnalyzeEntitiesRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.language.v1.IAnalyzeEntitiesRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.language.v1.IAnalyzeEntitiesResponse, - protos.google.cloud.language.v1.IAnalyzeEntitiesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.language.v1.IAnalyzeEntitiesResponse, - protos.google.cloud.language.v1.IAnalyzeEntitiesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.language.v1.IAnalyzeEntitiesResponse, - protos.google.cloud.language.v1.IAnalyzeEntitiesRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.language.v1.IAnalyzeEntitiesRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.language.v1.IAnalyzeEntitiesResponse, + | protos.google.cloud.language.v1.IAnalyzeEntitiesRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.language.v1.IAnalyzeEntitiesResponse, + protos.google.cloud.language.v1.IAnalyzeEntitiesRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === '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('analyzeEntities request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.language.v1.IAnalyzeEntitiesResponse, - protos.google.cloud.language.v1.IAnalyzeEntitiesRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.language.v1.IAnalyzeEntitiesResponse, + | protos.google.cloud.language.v1.IAnalyzeEntitiesRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('analyzeEntities response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.analyzeEntities(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.language.v1.IAnalyzeEntitiesResponse, - protos.google.cloud.language.v1.IAnalyzeEntitiesRequest|undefined, - {}|undefined - ]) => { - this._log.info('analyzeEntities response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .analyzeEntities(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.language.v1.IAnalyzeEntitiesResponse, + protos.google.cloud.language.v1.IAnalyzeEntitiesRequest | undefined, + {} | undefined, + ]) => { + this._log.info('analyzeEntities response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Finds entities, similar to - * {@link protos.google.cloud.language.v1.LanguageService.AnalyzeEntities|AnalyzeEntities} - * in the text and analyzes sentiment associated with each entity and its - * mentions. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.language.v1.Document} request.document - * Required. Input document. - * @param {google.cloud.language.v1.EncodingType} request.encodingType - * The encoding type used by the API to calculate offsets. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.language.v1.AnalyzeEntitySentimentResponse|AnalyzeEntitySentimentResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/language_service.analyze_entity_sentiment.js - * region_tag:language_v1_generated_LanguageService_AnalyzeEntitySentiment_async - */ + /** + * Finds entities, similar to + * {@link protos.google.cloud.language.v1.LanguageService.AnalyzeEntities|AnalyzeEntities} + * in the text and analyzes sentiment associated with each entity and its + * mentions. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.language.v1.Document} request.document + * Required. Input document. + * @param {google.cloud.language.v1.EncodingType} request.encodingType + * The encoding type used by the API to calculate offsets. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.language.v1.AnalyzeEntitySentimentResponse|AnalyzeEntitySentimentResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/language_service.analyze_entity_sentiment.js + * region_tag:language_v1_generated_LanguageService_AnalyzeEntitySentiment_async + */ analyzeEntitySentiment( - request?: protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.language.v1.IAnalyzeEntitySentimentResponse, - protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.language.v1.IAnalyzeEntitySentimentResponse, + ( + | protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest + | undefined + ), + {} | undefined, + ] + >; analyzeEntitySentiment( - request: protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.language.v1.IAnalyzeEntitySentimentResponse, - protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.language.v1.IAnalyzeEntitySentimentResponse, + | protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest + | null + | undefined, + {} | null | undefined + >, + ): void; analyzeEntitySentiment( - request: protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest, - callback: Callback< - protos.google.cloud.language.v1.IAnalyzeEntitySentimentResponse, - protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest, + callback: Callback< + protos.google.cloud.language.v1.IAnalyzeEntitySentimentResponse, + | protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest + | null + | undefined, + {} | null | undefined + >, + ): void; analyzeEntitySentiment( - request?: protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.language.v1.IAnalyzeEntitySentimentResponse, - protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.language.v1.IAnalyzeEntitySentimentResponse, - protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.language.v1.IAnalyzeEntitySentimentResponse, - protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.language.v1.IAnalyzeEntitySentimentResponse, + | protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.language.v1.IAnalyzeEntitySentimentResponse, + ( + | protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === '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('analyzeEntitySentiment request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.language.v1.IAnalyzeEntitySentimentResponse, - protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.language.v1.IAnalyzeEntitySentimentResponse, + | protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('analyzeEntitySentiment response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.analyzeEntitySentiment(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.language.v1.IAnalyzeEntitySentimentResponse, - protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest|undefined, - {}|undefined - ]) => { - this._log.info('analyzeEntitySentiment response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .analyzeEntitySentiment(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.language.v1.IAnalyzeEntitySentimentResponse, + ( + | protos.google.cloud.language.v1.IAnalyzeEntitySentimentRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('analyzeEntitySentiment response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Analyzes the syntax of the text and provides sentence boundaries and - * tokenization along with part of speech tags, dependency trees, and other - * properties. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.language.v1.Document} request.document - * Required. Input document. - * @param {google.cloud.language.v1.EncodingType} request.encodingType - * The encoding type used by the API to calculate offsets. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.language.v1.AnalyzeSyntaxResponse|AnalyzeSyntaxResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/language_service.analyze_syntax.js - * region_tag:language_v1_generated_LanguageService_AnalyzeSyntax_async - */ + /** + * Analyzes the syntax of the text and provides sentence boundaries and + * tokenization along with part of speech tags, dependency trees, and other + * properties. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.language.v1.Document} request.document + * Required. Input document. + * @param {google.cloud.language.v1.EncodingType} request.encodingType + * The encoding type used by the API to calculate offsets. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.language.v1.AnalyzeSyntaxResponse|AnalyzeSyntaxResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/language_service.analyze_syntax.js + * region_tag:language_v1_generated_LanguageService_AnalyzeSyntax_async + */ analyzeSyntax( - request?: protos.google.cloud.language.v1.IAnalyzeSyntaxRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.language.v1.IAnalyzeSyntaxResponse, - protos.google.cloud.language.v1.IAnalyzeSyntaxRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.language.v1.IAnalyzeSyntaxRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.language.v1.IAnalyzeSyntaxResponse, + protos.google.cloud.language.v1.IAnalyzeSyntaxRequest | undefined, + {} | undefined, + ] + >; analyzeSyntax( - request: protos.google.cloud.language.v1.IAnalyzeSyntaxRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.language.v1.IAnalyzeSyntaxResponse, - protos.google.cloud.language.v1.IAnalyzeSyntaxRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.language.v1.IAnalyzeSyntaxRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.language.v1.IAnalyzeSyntaxResponse, + protos.google.cloud.language.v1.IAnalyzeSyntaxRequest | null | undefined, + {} | null | undefined + >, + ): void; analyzeSyntax( - request: protos.google.cloud.language.v1.IAnalyzeSyntaxRequest, - callback: Callback< - protos.google.cloud.language.v1.IAnalyzeSyntaxResponse, - protos.google.cloud.language.v1.IAnalyzeSyntaxRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.language.v1.IAnalyzeSyntaxRequest, + callback: Callback< + protos.google.cloud.language.v1.IAnalyzeSyntaxResponse, + protos.google.cloud.language.v1.IAnalyzeSyntaxRequest | null | undefined, + {} | null | undefined + >, + ): void; analyzeSyntax( - request?: protos.google.cloud.language.v1.IAnalyzeSyntaxRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.language.v1.IAnalyzeSyntaxResponse, - protos.google.cloud.language.v1.IAnalyzeSyntaxRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.language.v1.IAnalyzeSyntaxRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.language.v1.IAnalyzeSyntaxResponse, - protos.google.cloud.language.v1.IAnalyzeSyntaxRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.language.v1.IAnalyzeSyntaxResponse, - protos.google.cloud.language.v1.IAnalyzeSyntaxRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.language.v1.IAnalyzeSyntaxRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.language.v1.IAnalyzeSyntaxResponse, + protos.google.cloud.language.v1.IAnalyzeSyntaxRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.language.v1.IAnalyzeSyntaxResponse, + protos.google.cloud.language.v1.IAnalyzeSyntaxRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === '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('analyzeSyntax request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.language.v1.IAnalyzeSyntaxResponse, - protos.google.cloud.language.v1.IAnalyzeSyntaxRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.language.v1.IAnalyzeSyntaxResponse, + | protos.google.cloud.language.v1.IAnalyzeSyntaxRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('analyzeSyntax response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.analyzeSyntax(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.language.v1.IAnalyzeSyntaxResponse, - protos.google.cloud.language.v1.IAnalyzeSyntaxRequest|undefined, - {}|undefined - ]) => { - this._log.info('analyzeSyntax response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .analyzeSyntax(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.language.v1.IAnalyzeSyntaxResponse, + protos.google.cloud.language.v1.IAnalyzeSyntaxRequest | undefined, + {} | undefined, + ]) => { + this._log.info('analyzeSyntax response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Classifies a document into categories. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.language.v1.Document} request.document - * Required. Input document. - * @param {google.cloud.language.v1.ClassificationModelOptions} request.classificationModelOptions - * Model options to use for classification. Defaults to v1 options if not - * 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 an object representing {@link protos.google.cloud.language.v1.ClassifyTextResponse|ClassifyTextResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/language_service.classify_text.js - * region_tag:language_v1_generated_LanguageService_ClassifyText_async - */ + /** + * Classifies a document into categories. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.language.v1.Document} request.document + * Required. Input document. + * @param {google.cloud.language.v1.ClassificationModelOptions} request.classificationModelOptions + * Model options to use for classification. Defaults to v1 options if not + * 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 an object representing {@link protos.google.cloud.language.v1.ClassifyTextResponse|ClassifyTextResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/language_service.classify_text.js + * region_tag:language_v1_generated_LanguageService_ClassifyText_async + */ classifyText( - request?: protos.google.cloud.language.v1.IClassifyTextRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.language.v1.IClassifyTextResponse, - protos.google.cloud.language.v1.IClassifyTextRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.language.v1.IClassifyTextRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.language.v1.IClassifyTextResponse, + protos.google.cloud.language.v1.IClassifyTextRequest | undefined, + {} | undefined, + ] + >; classifyText( - request: protos.google.cloud.language.v1.IClassifyTextRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.language.v1.IClassifyTextResponse, - protos.google.cloud.language.v1.IClassifyTextRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.language.v1.IClassifyTextRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.language.v1.IClassifyTextResponse, + protos.google.cloud.language.v1.IClassifyTextRequest | null | undefined, + {} | null | undefined + >, + ): void; classifyText( - request: protos.google.cloud.language.v1.IClassifyTextRequest, - callback: Callback< - protos.google.cloud.language.v1.IClassifyTextResponse, - protos.google.cloud.language.v1.IClassifyTextRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.language.v1.IClassifyTextRequest, + callback: Callback< + protos.google.cloud.language.v1.IClassifyTextResponse, + protos.google.cloud.language.v1.IClassifyTextRequest | null | undefined, + {} | null | undefined + >, + ): void; classifyText( - request?: protos.google.cloud.language.v1.IClassifyTextRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.language.v1.IClassifyTextResponse, - protos.google.cloud.language.v1.IClassifyTextRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.language.v1.IClassifyTextRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.language.v1.IClassifyTextResponse, - protos.google.cloud.language.v1.IClassifyTextRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.language.v1.IClassifyTextResponse, - protos.google.cloud.language.v1.IClassifyTextRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.language.v1.IClassifyTextRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.language.v1.IClassifyTextResponse, + protos.google.cloud.language.v1.IClassifyTextRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.language.v1.IClassifyTextResponse, + protos.google.cloud.language.v1.IClassifyTextRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === '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('classifyText request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.language.v1.IClassifyTextResponse, - protos.google.cloud.language.v1.IClassifyTextRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.language.v1.IClassifyTextResponse, + | protos.google.cloud.language.v1.IClassifyTextRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('classifyText response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.classifyText(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.language.v1.IClassifyTextResponse, - protos.google.cloud.language.v1.IClassifyTextRequest|undefined, - {}|undefined - ]) => { - this._log.info('classifyText response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .classifyText(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.language.v1.IClassifyTextResponse, + protos.google.cloud.language.v1.IClassifyTextRequest | undefined, + {} | undefined, + ]) => { + this._log.info('classifyText response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Moderates a document for harmful and sensitive categories. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.language.v1.Document} request.document - * Required. Input document. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.language.v1.ModerateTextResponse|ModerateTextResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/language_service.moderate_text.js - * region_tag:language_v1_generated_LanguageService_ModerateText_async - */ + /** + * Moderates a document for harmful and sensitive categories. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.language.v1.Document} request.document + * Required. Input document. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.language.v1.ModerateTextResponse|ModerateTextResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/language_service.moderate_text.js + * region_tag:language_v1_generated_LanguageService_ModerateText_async + */ moderateText( - request?: protos.google.cloud.language.v1.IModerateTextRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.language.v1.IModerateTextResponse, - protos.google.cloud.language.v1.IModerateTextRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.language.v1.IModerateTextRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.language.v1.IModerateTextResponse, + protos.google.cloud.language.v1.IModerateTextRequest | undefined, + {} | undefined, + ] + >; moderateText( - request: protos.google.cloud.language.v1.IModerateTextRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.language.v1.IModerateTextResponse, - protos.google.cloud.language.v1.IModerateTextRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.language.v1.IModerateTextRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.language.v1.IModerateTextResponse, + protos.google.cloud.language.v1.IModerateTextRequest | null | undefined, + {} | null | undefined + >, + ): void; moderateText( - request: protos.google.cloud.language.v1.IModerateTextRequest, - callback: Callback< - protos.google.cloud.language.v1.IModerateTextResponse, - protos.google.cloud.language.v1.IModerateTextRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.language.v1.IModerateTextRequest, + callback: Callback< + protos.google.cloud.language.v1.IModerateTextResponse, + protos.google.cloud.language.v1.IModerateTextRequest | null | undefined, + {} | null | undefined + >, + ): void; moderateText( - request?: protos.google.cloud.language.v1.IModerateTextRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.language.v1.IModerateTextRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.language.v1.IModerateTextResponse, - protos.google.cloud.language.v1.IModerateTextRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.language.v1.IModerateTextResponse, - protos.google.cloud.language.v1.IModerateTextRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.language.v1.IModerateTextResponse, - protos.google.cloud.language.v1.IModerateTextRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.language.v1.IModerateTextRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.language.v1.IModerateTextResponse, + protos.google.cloud.language.v1.IModerateTextRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.language.v1.IModerateTextResponse, + protos.google.cloud.language.v1.IModerateTextRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === '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('moderateText request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.language.v1.IModerateTextResponse, - protos.google.cloud.language.v1.IModerateTextRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.language.v1.IModerateTextResponse, + | protos.google.cloud.language.v1.IModerateTextRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('moderateText response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.moderateText(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.language.v1.IModerateTextResponse, - protos.google.cloud.language.v1.IModerateTextRequest|undefined, - {}|undefined - ]) => { - this._log.info('moderateText response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .moderateText(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.language.v1.IModerateTextResponse, + protos.google.cloud.language.v1.IModerateTextRequest | undefined, + {} | undefined, + ]) => { + this._log.info('moderateText response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * A convenience method that provides all the features that analyzeSentiment, - * analyzeEntities, and analyzeSyntax provide in one call. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.language.v1.Document} request.document - * Required. Input document. - * @param {google.cloud.language.v1.AnnotateTextRequest.Features} request.features - * Required. The enabled features. - * @param {google.cloud.language.v1.EncodingType} request.encodingType - * The encoding type used by the API to calculate offsets. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.language.v1.AnnotateTextResponse|AnnotateTextResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/language_service.annotate_text.js - * region_tag:language_v1_generated_LanguageService_AnnotateText_async - */ + /** + * A convenience method that provides all the features that analyzeSentiment, + * analyzeEntities, and analyzeSyntax provide in one call. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.language.v1.Document} request.document + * Required. Input document. + * @param {google.cloud.language.v1.AnnotateTextRequest.Features} request.features + * Required. The enabled features. + * @param {google.cloud.language.v1.EncodingType} request.encodingType + * The encoding type used by the API to calculate offsets. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.language.v1.AnnotateTextResponse|AnnotateTextResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/language_service.annotate_text.js + * region_tag:language_v1_generated_LanguageService_AnnotateText_async + */ annotateText( - request?: protos.google.cloud.language.v1.IAnnotateTextRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.language.v1.IAnnotateTextResponse, - protos.google.cloud.language.v1.IAnnotateTextRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.language.v1.IAnnotateTextRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.language.v1.IAnnotateTextResponse, + protos.google.cloud.language.v1.IAnnotateTextRequest | undefined, + {} | undefined, + ] + >; annotateText( - request: protos.google.cloud.language.v1.IAnnotateTextRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.language.v1.IAnnotateTextResponse, - protos.google.cloud.language.v1.IAnnotateTextRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.language.v1.IAnnotateTextRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.language.v1.IAnnotateTextResponse, + protos.google.cloud.language.v1.IAnnotateTextRequest | null | undefined, + {} | null | undefined + >, + ): void; annotateText( - request: protos.google.cloud.language.v1.IAnnotateTextRequest, - callback: Callback< - protos.google.cloud.language.v1.IAnnotateTextResponse, - protos.google.cloud.language.v1.IAnnotateTextRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.language.v1.IAnnotateTextRequest, + callback: Callback< + protos.google.cloud.language.v1.IAnnotateTextResponse, + protos.google.cloud.language.v1.IAnnotateTextRequest | null | undefined, + {} | null | undefined + >, + ): void; annotateText( - request?: protos.google.cloud.language.v1.IAnnotateTextRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.language.v1.IAnnotateTextResponse, - protos.google.cloud.language.v1.IAnnotateTextRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.language.v1.IAnnotateTextRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.language.v1.IAnnotateTextResponse, - protos.google.cloud.language.v1.IAnnotateTextRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.language.v1.IAnnotateTextResponse, - protos.google.cloud.language.v1.IAnnotateTextRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.language.v1.IAnnotateTextRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.language.v1.IAnnotateTextResponse, + protos.google.cloud.language.v1.IAnnotateTextRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.language.v1.IAnnotateTextResponse, + protos.google.cloud.language.v1.IAnnotateTextRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === '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('annotateText request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.language.v1.IAnnotateTextResponse, - protos.google.cloud.language.v1.IAnnotateTextRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.language.v1.IAnnotateTextResponse, + | protos.google.cloud.language.v1.IAnnotateTextRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('annotateText response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.annotateText(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.language.v1.IAnnotateTextResponse, - protos.google.cloud.language.v1.IAnnotateTextRequest|undefined, - {}|undefined - ]) => { - this._log.info('annotateText response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .annotateText(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.language.v1.IAnnotateTextResponse, + protos.google.cloud.language.v1.IAnnotateTextRequest | undefined, + {} | undefined, + ]) => { + this._log.info('annotateText response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } - /** * Terminate the gRPC channel and close the client. * @@ -975,7 +1297,7 @@ export class LanguageServiceClient { */ close(): Promise { if (this.languageServiceStub && !this._terminated) { - return this.languageServiceStub.then(stub => { + return this.languageServiceStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); @@ -983,4 +1305,4 @@ export class LanguageServiceClient { } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-language/src/v1beta2/index.ts b/packages/google-cloud-language/src/v1beta2/index.ts index 0350a5e24651..8fa13e0c2233 100644 --- a/packages/google-cloud-language/src/v1beta2/index.ts +++ b/packages/google-cloud-language/src/v1beta2/index.ts @@ -16,4 +16,4 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {LanguageServiceClient} from './language_service_client'; +export { LanguageServiceClient } from './language_service_client'; diff --git a/packages/google-cloud-language/src/v1beta2/language_service_client.ts b/packages/google-cloud-language/src/v1beta2/language_service_client.ts index ff83ac59795e..7c1ee7ac9123 100644 --- a/packages/google-cloud-language/src/v1beta2/language_service_client.ts +++ b/packages/google-cloud-language/src/v1beta2/language_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 @@ -45,7 +50,7 @@ export class LanguageServiceClient { 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('language'); @@ -58,8 +63,8 @@ export class LanguageServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - languageServiceStub?: Promise<{[name: string]: Function}>; + innerApiCalls: { [name: string]: Function }; + languageServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of LanguageServiceClient. @@ -100,21 +105,42 @@ export class LanguageServiceClient { * const client = new LanguageServiceClient({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 LanguageServiceClient; - 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 = 'language.' + 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 LanguageServiceClient { 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 LanguageServiceClient { } // 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 { @@ -175,8 +198,11 @@ export class LanguageServiceClient { // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.language.v1beta2.LanguageService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.language.v1beta2.LanguageService', + 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 @@ -207,36 +233,48 @@ export class LanguageServiceClient { // Put together the "service stub" for // google.cloud.language.v1beta2.LanguageService. this.languageServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.language.v1beta2.LanguageService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.language.v1beta2.LanguageService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.language.v1beta2.LanguageService, - 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 languageServiceStubMethods = - ['analyzeSentiment', 'analyzeEntities', 'analyzeEntitySentiment', 'analyzeSyntax', 'classifyText', 'moderateText', 'annotateText']; + const languageServiceStubMethods = [ + 'analyzeSentiment', + 'analyzeEntities', + 'analyzeEntitySentiment', + 'analyzeSyntax', + 'classifyText', + 'moderateText', + 'annotateText', + ]; for (const methodName of languageServiceStubMethods) { const callPromise = this.languageServiceStub.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; @@ -251,8 +289,14 @@ export class LanguageServiceClient { * @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 'language.googleapis.com'; } @@ -263,8 +307,14 @@ export class LanguageServiceClient { * @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 'language.googleapis.com'; } @@ -297,7 +347,7 @@ export class LanguageServiceClient { static get scopes() { return [ 'https://www.googleapis.com/auth/cloud-language', - 'https://www.googleapis.com/auth/cloud-platform' + 'https://www.googleapis.com/auth/cloud-platform', ]; } @@ -307,8 +357,9 @@ export class LanguageServiceClient { * 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; @@ -319,655 +370,959 @@ export class LanguageServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Analyzes the sentiment of the provided text. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.language.v1beta2.Document} request.document - * Required. Input document. - * @param {google.cloud.language.v1beta2.EncodingType} request.encodingType - * The encoding type used by the API to calculate sentence offsets for the - * sentence sentiment. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.language.v1beta2.AnalyzeSentimentResponse|AnalyzeSentimentResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta2/language_service.analyze_sentiment.js - * region_tag:language_v1beta2_generated_LanguageService_AnalyzeSentiment_async - */ + /** + * Analyzes the sentiment of the provided text. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.language.v1beta2.Document} request.document + * Required. Input document. + * @param {google.cloud.language.v1beta2.EncodingType} request.encodingType + * The encoding type used by the API to calculate sentence offsets for the + * sentence sentiment. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.language.v1beta2.AnalyzeSentimentResponse|AnalyzeSentimentResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta2/language_service.analyze_sentiment.js + * region_tag:language_v1beta2_generated_LanguageService_AnalyzeSentiment_async + */ analyzeSentiment( - request?: protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.language.v1beta2.IAnalyzeSentimentResponse, - protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.language.v1beta2.IAnalyzeSentimentResponse, + protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest | undefined, + {} | undefined, + ] + >; analyzeSentiment( - request: protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.language.v1beta2.IAnalyzeSentimentResponse, - protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.language.v1beta2.IAnalyzeSentimentResponse, + | protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest + | null + | undefined, + {} | null | undefined + >, + ): void; analyzeSentiment( - request: protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest, - callback: Callback< - protos.google.cloud.language.v1beta2.IAnalyzeSentimentResponse, - protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest, + callback: Callback< + protos.google.cloud.language.v1beta2.IAnalyzeSentimentResponse, + | protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest + | null + | undefined, + {} | null | undefined + >, + ): void; analyzeSentiment( - request?: protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.language.v1beta2.IAnalyzeSentimentResponse, - protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.language.v1beta2.IAnalyzeSentimentResponse, - protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.language.v1beta2.IAnalyzeSentimentResponse, - protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.language.v1beta2.IAnalyzeSentimentResponse, + | protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.language.v1beta2.IAnalyzeSentimentResponse, + protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === '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('analyzeSentiment request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.language.v1beta2.IAnalyzeSentimentResponse, - protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.language.v1beta2.IAnalyzeSentimentResponse, + | protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('analyzeSentiment response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.analyzeSentiment(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.language.v1beta2.IAnalyzeSentimentResponse, - protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest|undefined, - {}|undefined - ]) => { - this._log.info('analyzeSentiment response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .analyzeSentiment(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.language.v1beta2.IAnalyzeSentimentResponse, + ( + | protos.google.cloud.language.v1beta2.IAnalyzeSentimentRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('analyzeSentiment response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Finds named entities (currently proper names and common nouns) in the text - * along with entity types, salience, mentions for each entity, and - * other properties. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.language.v1beta2.Document} request.document - * Required. Input document. - * @param {google.cloud.language.v1beta2.EncodingType} request.encodingType - * The encoding type used by the API to calculate offsets. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.language.v1beta2.AnalyzeEntitiesResponse|AnalyzeEntitiesResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta2/language_service.analyze_entities.js - * region_tag:language_v1beta2_generated_LanguageService_AnalyzeEntities_async - */ + /** + * Finds named entities (currently proper names and common nouns) in the text + * along with entity types, salience, mentions for each entity, and + * other properties. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.language.v1beta2.Document} request.document + * Required. Input document. + * @param {google.cloud.language.v1beta2.EncodingType} request.encodingType + * The encoding type used by the API to calculate offsets. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.language.v1beta2.AnalyzeEntitiesResponse|AnalyzeEntitiesResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta2/language_service.analyze_entities.js + * region_tag:language_v1beta2_generated_LanguageService_AnalyzeEntities_async + */ analyzeEntities( - request?: protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.language.v1beta2.IAnalyzeEntitiesResponse, - protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.language.v1beta2.IAnalyzeEntitiesResponse, + protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest | undefined, + {} | undefined, + ] + >; analyzeEntities( - request: protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.language.v1beta2.IAnalyzeEntitiesResponse, - protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.language.v1beta2.IAnalyzeEntitiesResponse, + | protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest + | null + | undefined, + {} | null | undefined + >, + ): void; analyzeEntities( - request: protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest, - callback: Callback< - protos.google.cloud.language.v1beta2.IAnalyzeEntitiesResponse, - protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest, + callback: Callback< + protos.google.cloud.language.v1beta2.IAnalyzeEntitiesResponse, + | protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest + | null + | undefined, + {} | null | undefined + >, + ): void; analyzeEntities( - request?: protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.language.v1beta2.IAnalyzeEntitiesResponse, - protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.language.v1beta2.IAnalyzeEntitiesResponse, - protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.language.v1beta2.IAnalyzeEntitiesResponse, - protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.language.v1beta2.IAnalyzeEntitiesResponse, + | protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.language.v1beta2.IAnalyzeEntitiesResponse, + protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === '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('analyzeEntities request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.language.v1beta2.IAnalyzeEntitiesResponse, - protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.language.v1beta2.IAnalyzeEntitiesResponse, + | protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('analyzeEntities response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.analyzeEntities(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.language.v1beta2.IAnalyzeEntitiesResponse, - protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest|undefined, - {}|undefined - ]) => { - this._log.info('analyzeEntities response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .analyzeEntities(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.language.v1beta2.IAnalyzeEntitiesResponse, + ( + | protos.google.cloud.language.v1beta2.IAnalyzeEntitiesRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('analyzeEntities response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Finds entities, similar to - * {@link protos.google.cloud.language.v1beta2.LanguageService.AnalyzeEntities|AnalyzeEntities} - * in the text and analyzes sentiment associated with each entity and its - * mentions. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.language.v1beta2.Document} request.document - * Required. Input document. - * @param {google.cloud.language.v1beta2.EncodingType} request.encodingType - * The encoding type used by the API to calculate offsets. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.language.v1beta2.AnalyzeEntitySentimentResponse|AnalyzeEntitySentimentResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta2/language_service.analyze_entity_sentiment.js - * region_tag:language_v1beta2_generated_LanguageService_AnalyzeEntitySentiment_async - */ + /** + * Finds entities, similar to + * {@link protos.google.cloud.language.v1beta2.LanguageService.AnalyzeEntities|AnalyzeEntities} + * in the text and analyzes sentiment associated with each entity and its + * mentions. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.language.v1beta2.Document} request.document + * Required. Input document. + * @param {google.cloud.language.v1beta2.EncodingType} request.encodingType + * The encoding type used by the API to calculate offsets. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.language.v1beta2.AnalyzeEntitySentimentResponse|AnalyzeEntitySentimentResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta2/language_service.analyze_entity_sentiment.js + * region_tag:language_v1beta2_generated_LanguageService_AnalyzeEntitySentiment_async + */ analyzeEntitySentiment( - request?: protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentResponse, - protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentResponse, + ( + | protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest + | undefined + ), + {} | undefined, + ] + >; analyzeEntitySentiment( - request: protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentResponse, - protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentResponse, + | protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest + | null + | undefined, + {} | null | undefined + >, + ): void; analyzeEntitySentiment( - request: protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest, - callback: Callback< - protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentResponse, - protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest, + callback: Callback< + protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentResponse, + | protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest + | null + | undefined, + {} | null | undefined + >, + ): void; analyzeEntitySentiment( - request?: protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentResponse, - protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentResponse, - protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentResponse, - protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentResponse, + | protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentResponse, + ( + | protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === '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('analyzeEntitySentiment request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentResponse, - protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentResponse, + | protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('analyzeEntitySentiment response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.analyzeEntitySentiment(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentResponse, - protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest|undefined, - {}|undefined - ]) => { - this._log.info('analyzeEntitySentiment response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .analyzeEntitySentiment(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentResponse, + ( + | protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('analyzeEntitySentiment response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Analyzes the syntax of the text and provides sentence boundaries and - * tokenization along with part of speech tags, dependency trees, and other - * properties. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.language.v1beta2.Document} request.document - * Required. Input document. - * @param {google.cloud.language.v1beta2.EncodingType} request.encodingType - * The encoding type used by the API to calculate offsets. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.language.v1beta2.AnalyzeSyntaxResponse|AnalyzeSyntaxResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta2/language_service.analyze_syntax.js - * region_tag:language_v1beta2_generated_LanguageService_AnalyzeSyntax_async - */ + /** + * Analyzes the syntax of the text and provides sentence boundaries and + * tokenization along with part of speech tags, dependency trees, and other + * properties. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.language.v1beta2.Document} request.document + * Required. Input document. + * @param {google.cloud.language.v1beta2.EncodingType} request.encodingType + * The encoding type used by the API to calculate offsets. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.language.v1beta2.AnalyzeSyntaxResponse|AnalyzeSyntaxResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta2/language_service.analyze_syntax.js + * region_tag:language_v1beta2_generated_LanguageService_AnalyzeSyntax_async + */ analyzeSyntax( - request?: protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.language.v1beta2.IAnalyzeSyntaxResponse, - protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.language.v1beta2.IAnalyzeSyntaxResponse, + protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest | undefined, + {} | undefined, + ] + >; analyzeSyntax( - request: protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.language.v1beta2.IAnalyzeSyntaxResponse, - protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.language.v1beta2.IAnalyzeSyntaxResponse, + | protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest + | null + | undefined, + {} | null | undefined + >, + ): void; analyzeSyntax( - request: protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest, - callback: Callback< - protos.google.cloud.language.v1beta2.IAnalyzeSyntaxResponse, - protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest, + callback: Callback< + protos.google.cloud.language.v1beta2.IAnalyzeSyntaxResponse, + | protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest + | null + | undefined, + {} | null | undefined + >, + ): void; analyzeSyntax( - request?: protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.language.v1beta2.IAnalyzeSyntaxResponse, - protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.language.v1beta2.IAnalyzeSyntaxResponse, - protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.language.v1beta2.IAnalyzeSyntaxResponse, - protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.language.v1beta2.IAnalyzeSyntaxResponse, + | protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.language.v1beta2.IAnalyzeSyntaxResponse, + protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === '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('analyzeSyntax request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.language.v1beta2.IAnalyzeSyntaxResponse, - protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.language.v1beta2.IAnalyzeSyntaxResponse, + | protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('analyzeSyntax response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.analyzeSyntax(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.language.v1beta2.IAnalyzeSyntaxResponse, - protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest|undefined, - {}|undefined - ]) => { - this._log.info('analyzeSyntax response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .analyzeSyntax(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.language.v1beta2.IAnalyzeSyntaxResponse, + ( + | protos.google.cloud.language.v1beta2.IAnalyzeSyntaxRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('analyzeSyntax response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Classifies a document into categories. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.language.v1beta2.Document} request.document - * Required. Input document. - * @param {google.cloud.language.v1beta2.ClassificationModelOptions} request.classificationModelOptions - * Model options to use for classification. Defaults to v1 options if not - * 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 an object representing {@link protos.google.cloud.language.v1beta2.ClassifyTextResponse|ClassifyTextResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta2/language_service.classify_text.js - * region_tag:language_v1beta2_generated_LanguageService_ClassifyText_async - */ + /** + * Classifies a document into categories. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.language.v1beta2.Document} request.document + * Required. Input document. + * @param {google.cloud.language.v1beta2.ClassificationModelOptions} request.classificationModelOptions + * Model options to use for classification. Defaults to v1 options if not + * 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 an object representing {@link protos.google.cloud.language.v1beta2.ClassifyTextResponse|ClassifyTextResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta2/language_service.classify_text.js + * region_tag:language_v1beta2_generated_LanguageService_ClassifyText_async + */ classifyText( - request?: protos.google.cloud.language.v1beta2.IClassifyTextRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.language.v1beta2.IClassifyTextResponse, - protos.google.cloud.language.v1beta2.IClassifyTextRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.language.v1beta2.IClassifyTextRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.language.v1beta2.IClassifyTextResponse, + protos.google.cloud.language.v1beta2.IClassifyTextRequest | undefined, + {} | undefined, + ] + >; classifyText( - request: protos.google.cloud.language.v1beta2.IClassifyTextRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.language.v1beta2.IClassifyTextResponse, - protos.google.cloud.language.v1beta2.IClassifyTextRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.language.v1beta2.IClassifyTextRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.language.v1beta2.IClassifyTextResponse, + | protos.google.cloud.language.v1beta2.IClassifyTextRequest + | null + | undefined, + {} | null | undefined + >, + ): void; classifyText( - request: protos.google.cloud.language.v1beta2.IClassifyTextRequest, - callback: Callback< - protos.google.cloud.language.v1beta2.IClassifyTextResponse, - protos.google.cloud.language.v1beta2.IClassifyTextRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.language.v1beta2.IClassifyTextRequest, + callback: Callback< + protos.google.cloud.language.v1beta2.IClassifyTextResponse, + | protos.google.cloud.language.v1beta2.IClassifyTextRequest + | null + | undefined, + {} | null | undefined + >, + ): void; classifyText( - request?: protos.google.cloud.language.v1beta2.IClassifyTextRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.language.v1beta2.IClassifyTextResponse, - protos.google.cloud.language.v1beta2.IClassifyTextRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.language.v1beta2.IClassifyTextRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.language.v1beta2.IClassifyTextResponse, - protos.google.cloud.language.v1beta2.IClassifyTextRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.language.v1beta2.IClassifyTextResponse, - protos.google.cloud.language.v1beta2.IClassifyTextRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.language.v1beta2.IClassifyTextRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.language.v1beta2.IClassifyTextResponse, + | protos.google.cloud.language.v1beta2.IClassifyTextRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.language.v1beta2.IClassifyTextResponse, + protos.google.cloud.language.v1beta2.IClassifyTextRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === '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('classifyText request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.language.v1beta2.IClassifyTextResponse, - protos.google.cloud.language.v1beta2.IClassifyTextRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.language.v1beta2.IClassifyTextResponse, + | protos.google.cloud.language.v1beta2.IClassifyTextRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('classifyText response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.classifyText(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.language.v1beta2.IClassifyTextResponse, - protos.google.cloud.language.v1beta2.IClassifyTextRequest|undefined, - {}|undefined - ]) => { - this._log.info('classifyText response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .classifyText(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.language.v1beta2.IClassifyTextResponse, + protos.google.cloud.language.v1beta2.IClassifyTextRequest | undefined, + {} | undefined, + ]) => { + this._log.info('classifyText response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Moderates a document for harmful and sensitive categories. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.language.v1beta2.Document} request.document - * Required. Input document. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.language.v1beta2.ModerateTextResponse|ModerateTextResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta2/language_service.moderate_text.js - * region_tag:language_v1beta2_generated_LanguageService_ModerateText_async - */ + /** + * Moderates a document for harmful and sensitive categories. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.language.v1beta2.Document} request.document + * Required. Input document. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.language.v1beta2.ModerateTextResponse|ModerateTextResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta2/language_service.moderate_text.js + * region_tag:language_v1beta2_generated_LanguageService_ModerateText_async + */ moderateText( - request?: protos.google.cloud.language.v1beta2.IModerateTextRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.language.v1beta2.IModerateTextResponse, - protos.google.cloud.language.v1beta2.IModerateTextRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.language.v1beta2.IModerateTextRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.language.v1beta2.IModerateTextResponse, + protos.google.cloud.language.v1beta2.IModerateTextRequest | undefined, + {} | undefined, + ] + >; moderateText( - request: protos.google.cloud.language.v1beta2.IModerateTextRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.language.v1beta2.IModerateTextResponse, - protos.google.cloud.language.v1beta2.IModerateTextRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.language.v1beta2.IModerateTextRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.language.v1beta2.IModerateTextResponse, + | protos.google.cloud.language.v1beta2.IModerateTextRequest + | null + | undefined, + {} | null | undefined + >, + ): void; moderateText( - request: protos.google.cloud.language.v1beta2.IModerateTextRequest, - callback: Callback< - protos.google.cloud.language.v1beta2.IModerateTextResponse, - protos.google.cloud.language.v1beta2.IModerateTextRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.language.v1beta2.IModerateTextRequest, + callback: Callback< + protos.google.cloud.language.v1beta2.IModerateTextResponse, + | protos.google.cloud.language.v1beta2.IModerateTextRequest + | null + | undefined, + {} | null | undefined + >, + ): void; moderateText( - request?: protos.google.cloud.language.v1beta2.IModerateTextRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.language.v1beta2.IModerateTextRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.language.v1beta2.IModerateTextResponse, - protos.google.cloud.language.v1beta2.IModerateTextRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.language.v1beta2.IModerateTextResponse, - protos.google.cloud.language.v1beta2.IModerateTextRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.language.v1beta2.IModerateTextResponse, - protos.google.cloud.language.v1beta2.IModerateTextRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.language.v1beta2.IModerateTextRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.language.v1beta2.IModerateTextResponse, + | protos.google.cloud.language.v1beta2.IModerateTextRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.language.v1beta2.IModerateTextResponse, + protos.google.cloud.language.v1beta2.IModerateTextRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === '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('moderateText request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.language.v1beta2.IModerateTextResponse, - protos.google.cloud.language.v1beta2.IModerateTextRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.language.v1beta2.IModerateTextResponse, + | protos.google.cloud.language.v1beta2.IModerateTextRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('moderateText response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.moderateText(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.language.v1beta2.IModerateTextResponse, - protos.google.cloud.language.v1beta2.IModerateTextRequest|undefined, - {}|undefined - ]) => { - this._log.info('moderateText response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .moderateText(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.language.v1beta2.IModerateTextResponse, + protos.google.cloud.language.v1beta2.IModerateTextRequest | undefined, + {} | undefined, + ]) => { + this._log.info('moderateText response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * A convenience method that provides all syntax, sentiment, entity, and - * classification features in one call. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.language.v1beta2.Document} request.document - * Required. Input document. - * @param {google.cloud.language.v1beta2.AnnotateTextRequest.Features} request.features - * Required. The enabled features. - * @param {google.cloud.language.v1beta2.EncodingType} request.encodingType - * The encoding type used by the API to calculate offsets. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.language.v1beta2.AnnotateTextResponse|AnnotateTextResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta2/language_service.annotate_text.js - * region_tag:language_v1beta2_generated_LanguageService_AnnotateText_async - */ + /** + * A convenience method that provides all syntax, sentiment, entity, and + * classification features in one call. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.language.v1beta2.Document} request.document + * Required. Input document. + * @param {google.cloud.language.v1beta2.AnnotateTextRequest.Features} request.features + * Required. The enabled features. + * @param {google.cloud.language.v1beta2.EncodingType} request.encodingType + * The encoding type used by the API to calculate offsets. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.language.v1beta2.AnnotateTextResponse|AnnotateTextResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta2/language_service.annotate_text.js + * region_tag:language_v1beta2_generated_LanguageService_AnnotateText_async + */ annotateText( - request?: protos.google.cloud.language.v1beta2.IAnnotateTextRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.language.v1beta2.IAnnotateTextResponse, - protos.google.cloud.language.v1beta2.IAnnotateTextRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.language.v1beta2.IAnnotateTextRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.language.v1beta2.IAnnotateTextResponse, + protos.google.cloud.language.v1beta2.IAnnotateTextRequest | undefined, + {} | undefined, + ] + >; annotateText( - request: protos.google.cloud.language.v1beta2.IAnnotateTextRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.language.v1beta2.IAnnotateTextResponse, - protos.google.cloud.language.v1beta2.IAnnotateTextRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.language.v1beta2.IAnnotateTextRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.language.v1beta2.IAnnotateTextResponse, + | protos.google.cloud.language.v1beta2.IAnnotateTextRequest + | null + | undefined, + {} | null | undefined + >, + ): void; annotateText( - request: protos.google.cloud.language.v1beta2.IAnnotateTextRequest, - callback: Callback< - protos.google.cloud.language.v1beta2.IAnnotateTextResponse, - protos.google.cloud.language.v1beta2.IAnnotateTextRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.language.v1beta2.IAnnotateTextRequest, + callback: Callback< + protos.google.cloud.language.v1beta2.IAnnotateTextResponse, + | protos.google.cloud.language.v1beta2.IAnnotateTextRequest + | null + | undefined, + {} | null | undefined + >, + ): void; annotateText( - request?: protos.google.cloud.language.v1beta2.IAnnotateTextRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.language.v1beta2.IAnnotateTextResponse, - protos.google.cloud.language.v1beta2.IAnnotateTextRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.language.v1beta2.IAnnotateTextRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.language.v1beta2.IAnnotateTextResponse, - protos.google.cloud.language.v1beta2.IAnnotateTextRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.language.v1beta2.IAnnotateTextResponse, - protos.google.cloud.language.v1beta2.IAnnotateTextRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.language.v1beta2.IAnnotateTextRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.language.v1beta2.IAnnotateTextResponse, + | protos.google.cloud.language.v1beta2.IAnnotateTextRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.language.v1beta2.IAnnotateTextResponse, + protos.google.cloud.language.v1beta2.IAnnotateTextRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === '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('annotateText request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.language.v1beta2.IAnnotateTextResponse, - protos.google.cloud.language.v1beta2.IAnnotateTextRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.language.v1beta2.IAnnotateTextResponse, + | protos.google.cloud.language.v1beta2.IAnnotateTextRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('annotateText response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.annotateText(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.language.v1beta2.IAnnotateTextResponse, - protos.google.cloud.language.v1beta2.IAnnotateTextRequest|undefined, - {}|undefined - ]) => { - this._log.info('annotateText response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .annotateText(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.language.v1beta2.IAnnotateTextResponse, + protos.google.cloud.language.v1beta2.IAnnotateTextRequest | undefined, + {} | undefined, + ]) => { + this._log.info('annotateText response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } - /** * Terminate the gRPC channel and close the client. * @@ -976,7 +1331,7 @@ export class LanguageServiceClient { */ close(): Promise { if (this.languageServiceStub && !this._terminated) { - return this.languageServiceStub.then(stub => { + return this.languageServiceStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); @@ -984,4 +1339,4 @@ export class LanguageServiceClient { } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-language/src/v2/index.ts b/packages/google-cloud-language/src/v2/index.ts index 0350a5e24651..8fa13e0c2233 100644 --- a/packages/google-cloud-language/src/v2/index.ts +++ b/packages/google-cloud-language/src/v2/index.ts @@ -16,4 +16,4 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {LanguageServiceClient} from './language_service_client'; +export { LanguageServiceClient } from './language_service_client'; diff --git a/packages/google-cloud-language/src/v2/language_service_client.ts b/packages/google-cloud-language/src/v2/language_service_client.ts index d89cfbe009c8..4c093b09f4ba 100644 --- a/packages/google-cloud-language/src/v2/language_service_client.ts +++ b/packages/google-cloud-language/src/v2/language_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 @@ -45,7 +50,7 @@ export class LanguageServiceClient { 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('language'); @@ -58,8 +63,8 @@ export class LanguageServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - languageServiceStub?: Promise<{[name: string]: Function}>; + innerApiCalls: { [name: string]: Function }; + languageServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of LanguageServiceClient. @@ -100,21 +105,42 @@ export class LanguageServiceClient { * const client = new LanguageServiceClient({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 LanguageServiceClient; - 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 = 'language.' + 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 LanguageServiceClient { 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 LanguageServiceClient { } // 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 { @@ -175,8 +198,11 @@ export class LanguageServiceClient { // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.language.v2.LanguageService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.language.v2.LanguageService', + 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 @@ -207,36 +233,46 @@ export class LanguageServiceClient { // Put together the "service stub" for // google.cloud.language.v2.LanguageService. this.languageServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.language.v2.LanguageService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.language.v2.LanguageService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.language.v2.LanguageService, - 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 languageServiceStubMethods = - ['analyzeSentiment', 'analyzeEntities', 'classifyText', 'moderateText', 'annotateText']; + const languageServiceStubMethods = [ + 'analyzeSentiment', + 'analyzeEntities', + 'classifyText', + 'moderateText', + 'annotateText', + ]; for (const methodName of languageServiceStubMethods) { const callPromise = this.languageServiceStub.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; @@ -251,8 +287,14 @@ export class LanguageServiceClient { * @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 'language.googleapis.com'; } @@ -263,8 +305,14 @@ export class LanguageServiceClient { * @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 'language.googleapis.com'; } @@ -297,7 +345,7 @@ export class LanguageServiceClient { static get scopes() { return [ 'https://www.googleapis.com/auth/cloud-language', - 'https://www.googleapis.com/auth/cloud-platform' + 'https://www.googleapis.com/auth/cloud-platform', ]; } @@ -307,8 +355,9 @@ export class LanguageServiceClient { * 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; @@ -319,465 +368,651 @@ export class LanguageServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Analyzes the sentiment of the provided text. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.language.v2.Document} request.document - * Required. Input document. - * @param {google.cloud.language.v2.EncodingType} request.encodingType - * The encoding type used by the API to calculate sentence offsets. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.language.v2.AnalyzeSentimentResponse|AnalyzeSentimentResponse}. - * Please see the {@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/language_service.analyze_sentiment.js - * region_tag:language_v2_generated_LanguageService_AnalyzeSentiment_async - */ + /** + * Analyzes the sentiment of the provided text. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.language.v2.Document} request.document + * Required. Input document. + * @param {google.cloud.language.v2.EncodingType} request.encodingType + * The encoding type used by the API to calculate sentence offsets. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.language.v2.AnalyzeSentimentResponse|AnalyzeSentimentResponse}. + * Please see the {@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/language_service.analyze_sentiment.js + * region_tag:language_v2_generated_LanguageService_AnalyzeSentiment_async + */ analyzeSentiment( - request?: protos.google.cloud.language.v2.IAnalyzeSentimentRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.language.v2.IAnalyzeSentimentResponse, - protos.google.cloud.language.v2.IAnalyzeSentimentRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.language.v2.IAnalyzeSentimentRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.language.v2.IAnalyzeSentimentResponse, + protos.google.cloud.language.v2.IAnalyzeSentimentRequest | undefined, + {} | undefined, + ] + >; analyzeSentiment( - request: protos.google.cloud.language.v2.IAnalyzeSentimentRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.language.v2.IAnalyzeSentimentResponse, - protos.google.cloud.language.v2.IAnalyzeSentimentRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.language.v2.IAnalyzeSentimentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.language.v2.IAnalyzeSentimentResponse, + | protos.google.cloud.language.v2.IAnalyzeSentimentRequest + | null + | undefined, + {} | null | undefined + >, + ): void; analyzeSentiment( - request: protos.google.cloud.language.v2.IAnalyzeSentimentRequest, - callback: Callback< - protos.google.cloud.language.v2.IAnalyzeSentimentResponse, - protos.google.cloud.language.v2.IAnalyzeSentimentRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.language.v2.IAnalyzeSentimentRequest, + callback: Callback< + protos.google.cloud.language.v2.IAnalyzeSentimentResponse, + | protos.google.cloud.language.v2.IAnalyzeSentimentRequest + | null + | undefined, + {} | null | undefined + >, + ): void; analyzeSentiment( - request?: protos.google.cloud.language.v2.IAnalyzeSentimentRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.language.v2.IAnalyzeSentimentRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.language.v2.IAnalyzeSentimentResponse, - protos.google.cloud.language.v2.IAnalyzeSentimentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.language.v2.IAnalyzeSentimentResponse, - protos.google.cloud.language.v2.IAnalyzeSentimentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.language.v2.IAnalyzeSentimentResponse, - protos.google.cloud.language.v2.IAnalyzeSentimentRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.language.v2.IAnalyzeSentimentRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.language.v2.IAnalyzeSentimentResponse, + | protos.google.cloud.language.v2.IAnalyzeSentimentRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.language.v2.IAnalyzeSentimentResponse, + protos.google.cloud.language.v2.IAnalyzeSentimentRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === '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('analyzeSentiment request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.language.v2.IAnalyzeSentimentResponse, - protos.google.cloud.language.v2.IAnalyzeSentimentRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.language.v2.IAnalyzeSentimentResponse, + | protos.google.cloud.language.v2.IAnalyzeSentimentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('analyzeSentiment response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.analyzeSentiment(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.language.v2.IAnalyzeSentimentResponse, - protos.google.cloud.language.v2.IAnalyzeSentimentRequest|undefined, - {}|undefined - ]) => { - this._log.info('analyzeSentiment response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .analyzeSentiment(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.language.v2.IAnalyzeSentimentResponse, + protos.google.cloud.language.v2.IAnalyzeSentimentRequest | undefined, + {} | undefined, + ]) => { + this._log.info('analyzeSentiment response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Finds named entities (currently proper names and common nouns) in the text - * along with entity types, probability, mentions for each entity, and - * other properties. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.language.v2.Document} request.document - * Required. Input document. - * @param {google.cloud.language.v2.EncodingType} request.encodingType - * The encoding type used by the API to calculate offsets. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.language.v2.AnalyzeEntitiesResponse|AnalyzeEntitiesResponse}. - * Please see the {@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/language_service.analyze_entities.js - * region_tag:language_v2_generated_LanguageService_AnalyzeEntities_async - */ + /** + * Finds named entities (currently proper names and common nouns) in the text + * along with entity types, probability, mentions for each entity, and + * other properties. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.language.v2.Document} request.document + * Required. Input document. + * @param {google.cloud.language.v2.EncodingType} request.encodingType + * The encoding type used by the API to calculate offsets. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.language.v2.AnalyzeEntitiesResponse|AnalyzeEntitiesResponse}. + * Please see the {@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/language_service.analyze_entities.js + * region_tag:language_v2_generated_LanguageService_AnalyzeEntities_async + */ analyzeEntities( - request?: protos.google.cloud.language.v2.IAnalyzeEntitiesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.language.v2.IAnalyzeEntitiesResponse, - protos.google.cloud.language.v2.IAnalyzeEntitiesRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.language.v2.IAnalyzeEntitiesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.language.v2.IAnalyzeEntitiesResponse, + protos.google.cloud.language.v2.IAnalyzeEntitiesRequest | undefined, + {} | undefined, + ] + >; analyzeEntities( - request: protos.google.cloud.language.v2.IAnalyzeEntitiesRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.language.v2.IAnalyzeEntitiesResponse, - protos.google.cloud.language.v2.IAnalyzeEntitiesRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.language.v2.IAnalyzeEntitiesRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.language.v2.IAnalyzeEntitiesResponse, + | protos.google.cloud.language.v2.IAnalyzeEntitiesRequest + | null + | undefined, + {} | null | undefined + >, + ): void; analyzeEntities( - request: protos.google.cloud.language.v2.IAnalyzeEntitiesRequest, - callback: Callback< - protos.google.cloud.language.v2.IAnalyzeEntitiesResponse, - protos.google.cloud.language.v2.IAnalyzeEntitiesRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.language.v2.IAnalyzeEntitiesRequest, + callback: Callback< + protos.google.cloud.language.v2.IAnalyzeEntitiesResponse, + | protos.google.cloud.language.v2.IAnalyzeEntitiesRequest + | null + | undefined, + {} | null | undefined + >, + ): void; analyzeEntities( - request?: protos.google.cloud.language.v2.IAnalyzeEntitiesRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.language.v2.IAnalyzeEntitiesResponse, - protos.google.cloud.language.v2.IAnalyzeEntitiesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.language.v2.IAnalyzeEntitiesRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.language.v2.IAnalyzeEntitiesResponse, - protos.google.cloud.language.v2.IAnalyzeEntitiesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.language.v2.IAnalyzeEntitiesResponse, - protos.google.cloud.language.v2.IAnalyzeEntitiesRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.language.v2.IAnalyzeEntitiesRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.language.v2.IAnalyzeEntitiesResponse, + | protos.google.cloud.language.v2.IAnalyzeEntitiesRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.language.v2.IAnalyzeEntitiesResponse, + protos.google.cloud.language.v2.IAnalyzeEntitiesRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === '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('analyzeEntities request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.language.v2.IAnalyzeEntitiesResponse, - protos.google.cloud.language.v2.IAnalyzeEntitiesRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.language.v2.IAnalyzeEntitiesResponse, + | protos.google.cloud.language.v2.IAnalyzeEntitiesRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('analyzeEntities response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.analyzeEntities(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.language.v2.IAnalyzeEntitiesResponse, - protos.google.cloud.language.v2.IAnalyzeEntitiesRequest|undefined, - {}|undefined - ]) => { - this._log.info('analyzeEntities response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .analyzeEntities(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.language.v2.IAnalyzeEntitiesResponse, + protos.google.cloud.language.v2.IAnalyzeEntitiesRequest | undefined, + {} | undefined, + ]) => { + this._log.info('analyzeEntities response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Classifies a document into categories. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.language.v2.Document} request.document - * Required. Input document. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.language.v2.ClassifyTextResponse|ClassifyTextResponse}. - * Please see the {@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/language_service.classify_text.js - * region_tag:language_v2_generated_LanguageService_ClassifyText_async - */ + /** + * Classifies a document into categories. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.language.v2.Document} request.document + * Required. Input document. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.language.v2.ClassifyTextResponse|ClassifyTextResponse}. + * Please see the {@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/language_service.classify_text.js + * region_tag:language_v2_generated_LanguageService_ClassifyText_async + */ classifyText( - request?: protos.google.cloud.language.v2.IClassifyTextRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.language.v2.IClassifyTextResponse, - protos.google.cloud.language.v2.IClassifyTextRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.language.v2.IClassifyTextRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.language.v2.IClassifyTextResponse, + protos.google.cloud.language.v2.IClassifyTextRequest | undefined, + {} | undefined, + ] + >; classifyText( - request: protos.google.cloud.language.v2.IClassifyTextRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.language.v2.IClassifyTextResponse, - protos.google.cloud.language.v2.IClassifyTextRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.language.v2.IClassifyTextRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.language.v2.IClassifyTextResponse, + protos.google.cloud.language.v2.IClassifyTextRequest | null | undefined, + {} | null | undefined + >, + ): void; classifyText( - request: protos.google.cloud.language.v2.IClassifyTextRequest, - callback: Callback< - protos.google.cloud.language.v2.IClassifyTextResponse, - protos.google.cloud.language.v2.IClassifyTextRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.language.v2.IClassifyTextRequest, + callback: Callback< + protos.google.cloud.language.v2.IClassifyTextResponse, + protos.google.cloud.language.v2.IClassifyTextRequest | null | undefined, + {} | null | undefined + >, + ): void; classifyText( - request?: protos.google.cloud.language.v2.IClassifyTextRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.language.v2.IClassifyTextRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.language.v2.IClassifyTextResponse, - protos.google.cloud.language.v2.IClassifyTextRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.language.v2.IClassifyTextResponse, - protos.google.cloud.language.v2.IClassifyTextRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.language.v2.IClassifyTextResponse, - protos.google.cloud.language.v2.IClassifyTextRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.language.v2.IClassifyTextRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.language.v2.IClassifyTextResponse, + protos.google.cloud.language.v2.IClassifyTextRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.language.v2.IClassifyTextResponse, + protos.google.cloud.language.v2.IClassifyTextRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === '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('classifyText request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.language.v2.IClassifyTextResponse, - protos.google.cloud.language.v2.IClassifyTextRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.language.v2.IClassifyTextResponse, + | protos.google.cloud.language.v2.IClassifyTextRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('classifyText response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.classifyText(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.language.v2.IClassifyTextResponse, - protos.google.cloud.language.v2.IClassifyTextRequest|undefined, - {}|undefined - ]) => { - this._log.info('classifyText response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .classifyText(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.language.v2.IClassifyTextResponse, + protos.google.cloud.language.v2.IClassifyTextRequest | undefined, + {} | undefined, + ]) => { + this._log.info('classifyText response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * Moderates a document for harmful and sensitive categories. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.language.v2.Document} request.document - * Required. Input document. - * @param {google.cloud.language.v2.ModerateTextRequest.ModelVersion} [request.modelVersion] - * Optional. The model version to use for ModerateText. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.language.v2.ModerateTextResponse|ModerateTextResponse}. - * Please see the {@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/language_service.moderate_text.js - * region_tag:language_v2_generated_LanguageService_ModerateText_async - */ + /** + * Moderates a document for harmful and sensitive categories. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.language.v2.Document} request.document + * Required. Input document. + * @param {google.cloud.language.v2.ModerateTextRequest.ModelVersion} [request.modelVersion] + * Optional. The model version to use for ModerateText. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.language.v2.ModerateTextResponse|ModerateTextResponse}. + * Please see the {@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/language_service.moderate_text.js + * region_tag:language_v2_generated_LanguageService_ModerateText_async + */ moderateText( - request?: protos.google.cloud.language.v2.IModerateTextRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.language.v2.IModerateTextResponse, - protos.google.cloud.language.v2.IModerateTextRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.language.v2.IModerateTextRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.language.v2.IModerateTextResponse, + protos.google.cloud.language.v2.IModerateTextRequest | undefined, + {} | undefined, + ] + >; moderateText( - request: protos.google.cloud.language.v2.IModerateTextRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.language.v2.IModerateTextResponse, - protos.google.cloud.language.v2.IModerateTextRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.language.v2.IModerateTextRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.language.v2.IModerateTextResponse, + protos.google.cloud.language.v2.IModerateTextRequest | null | undefined, + {} | null | undefined + >, + ): void; moderateText( - request: protos.google.cloud.language.v2.IModerateTextRequest, - callback: Callback< - protos.google.cloud.language.v2.IModerateTextResponse, - protos.google.cloud.language.v2.IModerateTextRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.language.v2.IModerateTextRequest, + callback: Callback< + protos.google.cloud.language.v2.IModerateTextResponse, + protos.google.cloud.language.v2.IModerateTextRequest | null | undefined, + {} | null | undefined + >, + ): void; moderateText( - request?: protos.google.cloud.language.v2.IModerateTextRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.language.v2.IModerateTextResponse, - protos.google.cloud.language.v2.IModerateTextRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.language.v2.IModerateTextRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.language.v2.IModerateTextResponse, - protos.google.cloud.language.v2.IModerateTextRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.language.v2.IModerateTextResponse, - protos.google.cloud.language.v2.IModerateTextRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.language.v2.IModerateTextRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.language.v2.IModerateTextResponse, + protos.google.cloud.language.v2.IModerateTextRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.language.v2.IModerateTextResponse, + protos.google.cloud.language.v2.IModerateTextRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === '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('moderateText request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.language.v2.IModerateTextResponse, - protos.google.cloud.language.v2.IModerateTextRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.language.v2.IModerateTextResponse, + | protos.google.cloud.language.v2.IModerateTextRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('moderateText response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.moderateText(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.language.v2.IModerateTextResponse, - protos.google.cloud.language.v2.IModerateTextRequest|undefined, - {}|undefined - ]) => { - this._log.info('moderateText response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .moderateText(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.language.v2.IModerateTextResponse, + protos.google.cloud.language.v2.IModerateTextRequest | undefined, + {} | undefined, + ]) => { + this._log.info('moderateText response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * A convenience method that provides all features in one call. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.language.v2.Document} request.document - * Required. Input document. - * @param {google.cloud.language.v2.AnnotateTextRequest.Features} request.features - * Required. The enabled features. - * @param {google.cloud.language.v2.EncodingType} request.encodingType - * The encoding type used by the API to calculate offsets. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.language.v2.AnnotateTextResponse|AnnotateTextResponse}. - * Please see the {@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/language_service.annotate_text.js - * region_tag:language_v2_generated_LanguageService_AnnotateText_async - */ + /** + * A convenience method that provides all features in one call. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.language.v2.Document} request.document + * Required. Input document. + * @param {google.cloud.language.v2.AnnotateTextRequest.Features} request.features + * Required. The enabled features. + * @param {google.cloud.language.v2.EncodingType} request.encodingType + * The encoding type used by the API to calculate offsets. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.language.v2.AnnotateTextResponse|AnnotateTextResponse}. + * Please see the {@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/language_service.annotate_text.js + * region_tag:language_v2_generated_LanguageService_AnnotateText_async + */ annotateText( - request?: protos.google.cloud.language.v2.IAnnotateTextRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.language.v2.IAnnotateTextResponse, - protos.google.cloud.language.v2.IAnnotateTextRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.language.v2.IAnnotateTextRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.language.v2.IAnnotateTextResponse, + protos.google.cloud.language.v2.IAnnotateTextRequest | undefined, + {} | undefined, + ] + >; annotateText( - request: protos.google.cloud.language.v2.IAnnotateTextRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.language.v2.IAnnotateTextResponse, - protos.google.cloud.language.v2.IAnnotateTextRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.language.v2.IAnnotateTextRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.language.v2.IAnnotateTextResponse, + protos.google.cloud.language.v2.IAnnotateTextRequest | null | undefined, + {} | null | undefined + >, + ): void; annotateText( - request: protos.google.cloud.language.v2.IAnnotateTextRequest, - callback: Callback< - protos.google.cloud.language.v2.IAnnotateTextResponse, - protos.google.cloud.language.v2.IAnnotateTextRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.language.v2.IAnnotateTextRequest, + callback: Callback< + protos.google.cloud.language.v2.IAnnotateTextResponse, + protos.google.cloud.language.v2.IAnnotateTextRequest | null | undefined, + {} | null | undefined + >, + ): void; annotateText( - request?: protos.google.cloud.language.v2.IAnnotateTextRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.language.v2.IAnnotateTextResponse, - protos.google.cloud.language.v2.IAnnotateTextRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.language.v2.IAnnotateTextRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.language.v2.IAnnotateTextResponse, - protos.google.cloud.language.v2.IAnnotateTextRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.language.v2.IAnnotateTextResponse, - protos.google.cloud.language.v2.IAnnotateTextRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.language.v2.IAnnotateTextRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.language.v2.IAnnotateTextResponse, + protos.google.cloud.language.v2.IAnnotateTextRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.language.v2.IAnnotateTextResponse, + protos.google.cloud.language.v2.IAnnotateTextRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === '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('annotateText request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.language.v2.IAnnotateTextResponse, - protos.google.cloud.language.v2.IAnnotateTextRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.language.v2.IAnnotateTextResponse, + | protos.google.cloud.language.v2.IAnnotateTextRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('annotateText response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.annotateText(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.language.v2.IAnnotateTextResponse, - protos.google.cloud.language.v2.IAnnotateTextRequest|undefined, - {}|undefined - ]) => { - this._log.info('annotateText response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .annotateText(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.language.v2.IAnnotateTextResponse, + protos.google.cloud.language.v2.IAnnotateTextRequest | undefined, + {} | undefined, + ]) => { + this._log.info('annotateText response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } - /** * Terminate the gRPC channel and close the client. * @@ -786,7 +1021,7 @@ export class LanguageServiceClient { */ close(): Promise { if (this.languageServiceStub && !this._terminated) { - return this.languageServiceStub.then(stub => { + return this.languageServiceStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); @@ -794,4 +1029,4 @@ export class LanguageServiceClient { } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-language/system-test/fixtures/sample/src/index.ts b/packages/google-cloud-language/system-test/fixtures/sample/src/index.ts index 341947311514..708df99b93df 100644 --- a/packages/google-cloud-language/system-test/fixtures/sample/src/index.ts +++ b/packages/google-cloud-language/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 {LanguageServiceClient} from '@google-cloud/language'; +import { LanguageServiceClient } from '@google-cloud/language'; // check that the client class type name can be used function doStuffWithLanguageServiceClient(client: LanguageServiceClient) { diff --git a/packages/google-cloud-language/system-test/install.ts b/packages/google-cloud-language/system-test/install.ts index f66069aa3940..ccf167042d2e 100644 --- a/packages/google-cloud-language/system-test/install.ts +++ b/packages/google-cloud-language/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-language/test/gapic_language_service_v1.ts b/packages/google-cloud-language/test/gapic_language_service_v1.ts index 7ac5e87983ca..04a777e506b3 100644 --- a/packages/google-cloud-language/test/gapic_language_service_v1.ts +++ b/packages/google-cloud-language/test/gapic_language_service_v1.ts @@ -19,721 +19,840 @@ 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 languageserviceModule 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('v1.LanguageServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new languageserviceModule.v1.LanguageServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'language.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new languageserviceModule.v1.LanguageServiceClient(); - 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 = languageserviceModule.v1.LanguageServiceClient.servicePath; - assert.strictEqual(servicePath, 'language.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = languageserviceModule.v1.LanguageServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'language.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new languageserviceModule.v1.LanguageServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'language.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new languageserviceModule.v1.LanguageServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'language.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 languageserviceModule.v1.LanguageServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'language.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 languageserviceModule.v1.LanguageServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'language.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 languageserviceModule.v1.LanguageServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); - - it('has port', () => { - const port = languageserviceModule.v1.LanguageServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new languageserviceModule.v1.LanguageServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - fallback: true, - }); - assert(client); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new languageserviceModule.v1.LanguageServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'language.googleapis.com'); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.languageServiceStub, undefined); - await client.initialize(); - assert(client.languageServiceStub); - }); + it('has universeDomain', () => { + const client = new languageserviceModule.v1.LanguageServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('has close method for the initialized client', done => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.languageServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + languageserviceModule.v1.LanguageServiceClient.servicePath; + assert.strictEqual(servicePath, 'language.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + languageserviceModule.v1.LanguageServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'language.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'language.example.com'); + }); - it('has close method for the non-initialized client', done => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.languageServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'language.example.com'); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new languageserviceModule.v1.LanguageServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'language.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 languageserviceModule.v1.LanguageServiceClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'language.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 languageserviceModule.v1.LanguageServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); + it('has port', () => { + const port = languageserviceModule.v1.LanguageServiceClient.port; + assert(port); + assert(typeof port === 'number'); }); - describe('analyzeSentiment', () => { - it('invokes analyzeSentiment without error', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v1.AnalyzeSentimentRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.language.v1.AnalyzeSentimentResponse() - ); - client.innerApiCalls.analyzeSentiment = stubSimpleCall(expectedResponse); - const [response] = await client.analyzeSentiment(request); - assert.deepStrictEqual(response, expectedResponse); - }); + it('should create a client with no option', () => { + const client = new languageserviceModule.v1.LanguageServiceClient(); + assert(client); + }); - it('invokes analyzeSentiment without error using callback', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v1.AnalyzeSentimentRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.language.v1.AnalyzeSentimentResponse() - ); - client.innerApiCalls.analyzeSentiment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.analyzeSentiment( - request, - (err?: Error|null, result?: protos.google.cloud.language.v1.IAnalyzeSentimentResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - }); + it('should create a client with gRPC fallback', () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + fallback: true, + }); + assert(client); + }); - it('invokes analyzeSentiment with error', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v1.AnalyzeSentimentRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.analyzeSentiment = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.analyzeSentiment(request), expectedError); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.languageServiceStub, undefined); + await client.initialize(); + assert(client.languageServiceStub); + }); - it('invokes analyzeSentiment with closed client', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v1.AnalyzeSentimentRequest() - ); - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.analyzeSentiment(request), expectedError); + it('has close method for the initialized client', (done) => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.languageServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('analyzeEntities', () => { - it('invokes analyzeEntities without error', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v1.AnalyzeEntitiesRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.language.v1.AnalyzeEntitiesResponse() - ); - client.innerApiCalls.analyzeEntities = stubSimpleCall(expectedResponse); - const [response] = await client.analyzeEntities(request); - assert.deepStrictEqual(response, expectedResponse); + it('has close method for the non-initialized client', (done) => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.languageServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes analyzeEntities without error using callback', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v1.AnalyzeEntitiesRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.language.v1.AnalyzeEntitiesResponse() - ); - client.innerApiCalls.analyzeEntities = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.analyzeEntities( - request, - (err?: Error|null, result?: protos.google.cloud.language.v1.IAnalyzeEntitiesResponse|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 languageserviceModule.v1.LanguageServiceClient({ + 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 analyzeEntities with error', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v1.AnalyzeEntitiesRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.analyzeEntities = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.analyzeEntities(request), expectedError); - }); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new languageserviceModule.v1.LanguageServiceClient({ + 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('analyzeSentiment', () => { + it('invokes analyzeSentiment without error', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1.AnalyzeSentimentRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v1.AnalyzeSentimentResponse(), + ); + client.innerApiCalls.analyzeSentiment = stubSimpleCall(expectedResponse); + const [response] = await client.analyzeSentiment(request); + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes analyzeEntities with closed client', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v1.AnalyzeEntitiesRequest() - ); - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.analyzeEntities(request), expectedError); - }); + it('invokes analyzeSentiment without error using callback', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1.AnalyzeSentimentRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v1.AnalyzeSentimentResponse(), + ); + client.innerApiCalls.analyzeSentiment = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.analyzeSentiment( + request, + ( + err?: Error | null, + result?: protos.google.cloud.language.v1.IAnalyzeSentimentResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); }); - describe('analyzeEntitySentiment', () => { - it('invokes analyzeEntitySentiment without error', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v1.AnalyzeEntitySentimentRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.language.v1.AnalyzeEntitySentimentResponse() - ); - client.innerApiCalls.analyzeEntitySentiment = stubSimpleCall(expectedResponse); - const [response] = await client.analyzeEntitySentiment(request); - assert.deepStrictEqual(response, expectedResponse); - }); + it('invokes analyzeSentiment with error', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1.AnalyzeSentimentRequest(), + ); + const expectedError = new Error('expected'); + client.innerApiCalls.analyzeSentiment = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.analyzeSentiment(request), expectedError); + }); - it('invokes analyzeEntitySentiment without error using callback', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v1.AnalyzeEntitySentimentRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.language.v1.AnalyzeEntitySentimentResponse() - ); - client.innerApiCalls.analyzeEntitySentiment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.analyzeEntitySentiment( - request, - (err?: Error|null, result?: protos.google.cloud.language.v1.IAnalyzeEntitySentimentResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - }); + it('invokes analyzeSentiment with closed client', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1.AnalyzeSentimentRequest(), + ); + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.analyzeSentiment(request), expectedError); + }); + }); + + describe('analyzeEntities', () => { + it('invokes analyzeEntities without error', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1.AnalyzeEntitiesRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v1.AnalyzeEntitiesResponse(), + ); + client.innerApiCalls.analyzeEntities = stubSimpleCall(expectedResponse); + const [response] = await client.analyzeEntities(request); + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes analyzeEntitySentiment with error', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v1.AnalyzeEntitySentimentRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.analyzeEntitySentiment = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.analyzeEntitySentiment(request), expectedError); - }); + it('invokes analyzeEntities without error using callback', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1.AnalyzeEntitiesRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v1.AnalyzeEntitiesResponse(), + ); + client.innerApiCalls.analyzeEntities = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.analyzeEntities( + request, + ( + err?: Error | null, + result?: protos.google.cloud.language.v1.IAnalyzeEntitiesResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes analyzeEntitySentiment with closed client', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v1.AnalyzeEntitySentimentRequest() - ); - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.analyzeEntitySentiment(request), expectedError); - }); + it('invokes analyzeEntities with error', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1.AnalyzeEntitiesRequest(), + ); + const expectedError = new Error('expected'); + client.innerApiCalls.analyzeEntities = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.analyzeEntities(request), expectedError); }); - describe('analyzeSyntax', () => { - it('invokes analyzeSyntax without error', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v1.AnalyzeSyntaxRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.language.v1.AnalyzeSyntaxResponse() - ); - client.innerApiCalls.analyzeSyntax = stubSimpleCall(expectedResponse); - const [response] = await client.analyzeSyntax(request); - assert.deepStrictEqual(response, expectedResponse); - }); + it('invokes analyzeEntities with closed client', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1.AnalyzeEntitiesRequest(), + ); + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.analyzeEntities(request), expectedError); + }); + }); + + describe('analyzeEntitySentiment', () => { + it('invokes analyzeEntitySentiment without error', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1.AnalyzeEntitySentimentRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v1.AnalyzeEntitySentimentResponse(), + ); + client.innerApiCalls.analyzeEntitySentiment = + stubSimpleCall(expectedResponse); + const [response] = await client.analyzeEntitySentiment(request); + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes analyzeSyntax without error using callback', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v1.AnalyzeSyntaxRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.language.v1.AnalyzeSyntaxResponse() - ); - client.innerApiCalls.analyzeSyntax = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.analyzeSyntax( - request, - (err?: Error|null, result?: protos.google.cloud.language.v1.IAnalyzeSyntaxResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - }); + it('invokes analyzeEntitySentiment without error using callback', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1.AnalyzeEntitySentimentRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v1.AnalyzeEntitySentimentResponse(), + ); + client.innerApiCalls.analyzeEntitySentiment = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.analyzeEntitySentiment( + request, + ( + err?: Error | null, + result?: protos.google.cloud.language.v1.IAnalyzeEntitySentimentResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes analyzeSyntax with error', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v1.AnalyzeSyntaxRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.analyzeSyntax = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.analyzeSyntax(request), expectedError); - }); + it('invokes analyzeEntitySentiment with error', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1.AnalyzeEntitySentimentRequest(), + ); + const expectedError = new Error('expected'); + client.innerApiCalls.analyzeEntitySentiment = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.analyzeEntitySentiment(request), + expectedError, + ); + }); - it('invokes analyzeSyntax with closed client', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v1.AnalyzeSyntaxRequest() - ); - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.analyzeSyntax(request), expectedError); - }); + it('invokes analyzeEntitySentiment with closed client', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1.AnalyzeEntitySentimentRequest(), + ); + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.analyzeEntitySentiment(request), + expectedError, + ); + }); + }); + + describe('analyzeSyntax', () => { + it('invokes analyzeSyntax without error', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1.AnalyzeSyntaxRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v1.AnalyzeSyntaxResponse(), + ); + client.innerApiCalls.analyzeSyntax = stubSimpleCall(expectedResponse); + const [response] = await client.analyzeSyntax(request); + assert.deepStrictEqual(response, expectedResponse); }); - describe('classifyText', () => { - it('invokes classifyText without error', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v1.ClassifyTextRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.language.v1.ClassifyTextResponse() - ); - client.innerApiCalls.classifyText = stubSimpleCall(expectedResponse); - const [response] = await client.classifyText(request); - assert.deepStrictEqual(response, expectedResponse); - }); + it('invokes analyzeSyntax without error using callback', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1.AnalyzeSyntaxRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v1.AnalyzeSyntaxResponse(), + ); + client.innerApiCalls.analyzeSyntax = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.analyzeSyntax( + request, + ( + err?: Error | null, + result?: protos.google.cloud.language.v1.IAnalyzeSyntaxResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes classifyText without error using callback', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v1.ClassifyTextRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.language.v1.ClassifyTextResponse() - ); - client.innerApiCalls.classifyText = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.classifyText( - request, - (err?: Error|null, result?: protos.google.cloud.language.v1.IClassifyTextResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - }); + it('invokes analyzeSyntax with error', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1.AnalyzeSyntaxRequest(), + ); + const expectedError = new Error('expected'); + client.innerApiCalls.analyzeSyntax = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.analyzeSyntax(request), expectedError); + }); - it('invokes classifyText with error', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v1.ClassifyTextRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.classifyText = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.classifyText(request), expectedError); - }); + it('invokes analyzeSyntax with closed client', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1.AnalyzeSyntaxRequest(), + ); + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.analyzeSyntax(request), expectedError); + }); + }); + + describe('classifyText', () => { + it('invokes classifyText without error', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1.ClassifyTextRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v1.ClassifyTextResponse(), + ); + client.innerApiCalls.classifyText = stubSimpleCall(expectedResponse); + const [response] = await client.classifyText(request); + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes classifyText with closed client', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v1.ClassifyTextRequest() - ); - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.classifyText(request), expectedError); - }); + it('invokes classifyText without error using callback', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1.ClassifyTextRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v1.ClassifyTextResponse(), + ); + client.innerApiCalls.classifyText = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.classifyText( + request, + ( + err?: Error | null, + result?: protos.google.cloud.language.v1.IClassifyTextResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); }); - describe('moderateText', () => { - it('invokes moderateText without error', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v1.ModerateTextRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.language.v1.ModerateTextResponse() - ); - client.innerApiCalls.moderateText = stubSimpleCall(expectedResponse); - const [response] = await client.moderateText(request); - assert.deepStrictEqual(response, expectedResponse); - }); + it('invokes classifyText with error', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1.ClassifyTextRequest(), + ); + const expectedError = new Error('expected'); + client.innerApiCalls.classifyText = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.classifyText(request), expectedError); + }); - it('invokes moderateText without error using callback', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v1.ModerateTextRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.language.v1.ModerateTextResponse() - ); - client.innerApiCalls.moderateText = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.moderateText( - request, - (err?: Error|null, result?: protos.google.cloud.language.v1.IModerateTextResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - }); + it('invokes classifyText with closed client', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1.ClassifyTextRequest(), + ); + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.classifyText(request), expectedError); + }); + }); + + describe('moderateText', () => { + it('invokes moderateText without error', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1.ModerateTextRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v1.ModerateTextResponse(), + ); + client.innerApiCalls.moderateText = stubSimpleCall(expectedResponse); + const [response] = await client.moderateText(request); + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes moderateText with error', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v1.ModerateTextRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.moderateText = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.moderateText(request), expectedError); - }); + it('invokes moderateText without error using callback', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1.ModerateTextRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v1.ModerateTextResponse(), + ); + client.innerApiCalls.moderateText = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.moderateText( + request, + ( + err?: Error | null, + result?: protos.google.cloud.language.v1.IModerateTextResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes moderateText with closed client', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v1.ModerateTextRequest() - ); - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.moderateText(request), expectedError); - }); + it('invokes moderateText with error', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1.ModerateTextRequest(), + ); + const expectedError = new Error('expected'); + client.innerApiCalls.moderateText = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.moderateText(request), expectedError); }); - describe('annotateText', () => { - it('invokes annotateText without error', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v1.AnnotateTextRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.language.v1.AnnotateTextResponse() - ); - client.innerApiCalls.annotateText = stubSimpleCall(expectedResponse); - const [response] = await client.annotateText(request); - assert.deepStrictEqual(response, expectedResponse); - }); + it('invokes moderateText with closed client', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1.ModerateTextRequest(), + ); + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.moderateText(request), expectedError); + }); + }); + + describe('annotateText', () => { + it('invokes annotateText without error', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1.AnnotateTextRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v1.AnnotateTextResponse(), + ); + client.innerApiCalls.annotateText = stubSimpleCall(expectedResponse); + const [response] = await client.annotateText(request); + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes annotateText without error using callback', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v1.AnnotateTextRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.language.v1.AnnotateTextResponse() - ); - client.innerApiCalls.annotateText = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.annotateText( - request, - (err?: Error|null, result?: protos.google.cloud.language.v1.IAnnotateTextResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - }); + it('invokes annotateText without error using callback', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1.AnnotateTextRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v1.AnnotateTextResponse(), + ); + client.innerApiCalls.annotateText = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.annotateText( + request, + ( + err?: Error | null, + result?: protos.google.cloud.language.v1.IAnnotateTextResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes annotateText with error', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v1.AnnotateTextRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.annotateText = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.annotateText(request), expectedError); - }); + it('invokes annotateText with error', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1.AnnotateTextRequest(), + ); + const expectedError = new Error('expected'); + client.innerApiCalls.annotateText = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.annotateText(request), expectedError); + }); - it('invokes annotateText with closed client', async () => { - const client = new languageserviceModule.v1.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v1.AnnotateTextRequest() - ); - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.annotateText(request), expectedError); - }); + it('invokes annotateText with closed client', async () => { + const client = new languageserviceModule.v1.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1.AnnotateTextRequest(), + ); + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.annotateText(request), expectedError); }); + }); }); diff --git a/packages/google-cloud-language/test/gapic_language_service_v1beta2.ts b/packages/google-cloud-language/test/gapic_language_service_v1beta2.ts index f5384fdc51ce..6f796ce893ba 100644 --- a/packages/google-cloud-language/test/gapic_language_service_v1beta2.ts +++ b/packages/google-cloud-language/test/gapic_language_service_v1beta2.ts @@ -19,721 +19,842 @@ 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 languageserviceModule 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('v1beta2.LanguageServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'language.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient(); - 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 = languageserviceModule.v1beta2.LanguageServiceClient.servicePath; - assert.strictEqual(servicePath, 'language.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = languageserviceModule.v1beta2.LanguageServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'language.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'language.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'language.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 languageserviceModule.v1beta2.LanguageServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'language.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 languageserviceModule.v1beta2.LanguageServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'language.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 languageserviceModule.v1beta2.LanguageServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); - - it('has port', () => { - const port = languageserviceModule.v1beta2.LanguageServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - fallback: true, - }); - assert(client); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'language.googleapis.com'); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.languageServiceStub, undefined); - await client.initialize(); - assert(client.languageServiceStub); - }); + it('has universeDomain', () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('has close method for the initialized client', done => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.languageServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + languageserviceModule.v1beta2.LanguageServiceClient.servicePath; + assert.strictEqual(servicePath, 'language.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + languageserviceModule.v1beta2.LanguageServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'language.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'language.example.com'); + }); - it('has close method for the non-initialized client', done => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.languageServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'language.example.com'); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = + new languageserviceModule.v1beta2.LanguageServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'language.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 languageserviceModule.v1beta2.LanguageServiceClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'language.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 languageserviceModule.v1beta2.LanguageServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); + it('has port', () => { + const port = languageserviceModule.v1beta2.LanguageServiceClient.port; + assert(port); + assert(typeof port === 'number'); }); - describe('analyzeSentiment', () => { - it('invokes analyzeSentiment without error', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v1beta2.AnalyzeSentimentRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.language.v1beta2.AnalyzeSentimentResponse() - ); - client.innerApiCalls.analyzeSentiment = stubSimpleCall(expectedResponse); - const [response] = await client.analyzeSentiment(request); - assert.deepStrictEqual(response, expectedResponse); - }); + it('should create a client with no option', () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient(); + assert(client); + }); - it('invokes analyzeSentiment without error using callback', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v1beta2.AnalyzeSentimentRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.language.v1beta2.AnalyzeSentimentResponse() - ); - client.innerApiCalls.analyzeSentiment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.analyzeSentiment( - request, - (err?: Error|null, result?: protos.google.cloud.language.v1beta2.IAnalyzeSentimentResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - }); + it('should create a client with gRPC fallback', () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + fallback: true, + }); + assert(client); + }); - it('invokes analyzeSentiment with error', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v1beta2.AnalyzeSentimentRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.analyzeSentiment = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.analyzeSentiment(request), expectedError); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.languageServiceStub, undefined); + await client.initialize(); + assert(client.languageServiceStub); + }); - it('invokes analyzeSentiment with closed client', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v1beta2.AnalyzeSentimentRequest() - ); - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.analyzeSentiment(request), expectedError); + it('has close method for the initialized client', (done) => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.languageServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('analyzeEntities', () => { - it('invokes analyzeEntities without error', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v1beta2.AnalyzeEntitiesRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.language.v1beta2.AnalyzeEntitiesResponse() - ); - client.innerApiCalls.analyzeEntities = stubSimpleCall(expectedResponse); - const [response] = await client.analyzeEntities(request); - assert.deepStrictEqual(response, expectedResponse); + it('has close method for the non-initialized client', (done) => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.languageServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes analyzeEntities without error using callback', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v1beta2.AnalyzeEntitiesRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.language.v1beta2.AnalyzeEntitiesResponse() - ); - client.innerApiCalls.analyzeEntities = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.analyzeEntities( - request, - (err?: Error|null, result?: protos.google.cloud.language.v1beta2.IAnalyzeEntitiesResponse|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 languageserviceModule.v1beta2.LanguageServiceClient({ + 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 analyzeEntities with error', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v1beta2.AnalyzeEntitiesRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.analyzeEntities = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.analyzeEntities(request), expectedError); - }); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + 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('analyzeSentiment', () => { + it('invokes analyzeSentiment without error', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1beta2.AnalyzeSentimentRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v1beta2.AnalyzeSentimentResponse(), + ); + client.innerApiCalls.analyzeSentiment = stubSimpleCall(expectedResponse); + const [response] = await client.analyzeSentiment(request); + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes analyzeEntities with closed client', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v1beta2.AnalyzeEntitiesRequest() - ); - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.analyzeEntities(request), expectedError); - }); + it('invokes analyzeSentiment without error using callback', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1beta2.AnalyzeSentimentRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v1beta2.AnalyzeSentimentResponse(), + ); + client.innerApiCalls.analyzeSentiment = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.analyzeSentiment( + request, + ( + err?: Error | null, + result?: protos.google.cloud.language.v1beta2.IAnalyzeSentimentResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); }); - describe('analyzeEntitySentiment', () => { - it('invokes analyzeEntitySentiment without error', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v1beta2.AnalyzeEntitySentimentRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.language.v1beta2.AnalyzeEntitySentimentResponse() - ); - client.innerApiCalls.analyzeEntitySentiment = stubSimpleCall(expectedResponse); - const [response] = await client.analyzeEntitySentiment(request); - assert.deepStrictEqual(response, expectedResponse); - }); + it('invokes analyzeSentiment with error', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1beta2.AnalyzeSentimentRequest(), + ); + const expectedError = new Error('expected'); + client.innerApiCalls.analyzeSentiment = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.analyzeSentiment(request), expectedError); + }); - it('invokes analyzeEntitySentiment without error using callback', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v1beta2.AnalyzeEntitySentimentRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.language.v1beta2.AnalyzeEntitySentimentResponse() - ); - client.innerApiCalls.analyzeEntitySentiment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.analyzeEntitySentiment( - request, - (err?: Error|null, result?: protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - }); + it('invokes analyzeSentiment with closed client', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1beta2.AnalyzeSentimentRequest(), + ); + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.analyzeSentiment(request), expectedError); + }); + }); + + describe('analyzeEntities', () => { + it('invokes analyzeEntities without error', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1beta2.AnalyzeEntitiesRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v1beta2.AnalyzeEntitiesResponse(), + ); + client.innerApiCalls.analyzeEntities = stubSimpleCall(expectedResponse); + const [response] = await client.analyzeEntities(request); + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes analyzeEntitySentiment with error', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v1beta2.AnalyzeEntitySentimentRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.analyzeEntitySentiment = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.analyzeEntitySentiment(request), expectedError); - }); + it('invokes analyzeEntities without error using callback', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1beta2.AnalyzeEntitiesRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v1beta2.AnalyzeEntitiesResponse(), + ); + client.innerApiCalls.analyzeEntities = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.analyzeEntities( + request, + ( + err?: Error | null, + result?: protos.google.cloud.language.v1beta2.IAnalyzeEntitiesResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes analyzeEntitySentiment with closed client', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v1beta2.AnalyzeEntitySentimentRequest() - ); - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.analyzeEntitySentiment(request), expectedError); - }); + it('invokes analyzeEntities with error', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1beta2.AnalyzeEntitiesRequest(), + ); + const expectedError = new Error('expected'); + client.innerApiCalls.analyzeEntities = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.analyzeEntities(request), expectedError); }); - describe('analyzeSyntax', () => { - it('invokes analyzeSyntax without error', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v1beta2.AnalyzeSyntaxRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.language.v1beta2.AnalyzeSyntaxResponse() - ); - client.innerApiCalls.analyzeSyntax = stubSimpleCall(expectedResponse); - const [response] = await client.analyzeSyntax(request); - assert.deepStrictEqual(response, expectedResponse); - }); + it('invokes analyzeEntities with closed client', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1beta2.AnalyzeEntitiesRequest(), + ); + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.analyzeEntities(request), expectedError); + }); + }); + + describe('analyzeEntitySentiment', () => { + it('invokes analyzeEntitySentiment without error', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1beta2.AnalyzeEntitySentimentRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v1beta2.AnalyzeEntitySentimentResponse(), + ); + client.innerApiCalls.analyzeEntitySentiment = + stubSimpleCall(expectedResponse); + const [response] = await client.analyzeEntitySentiment(request); + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes analyzeSyntax without error using callback', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v1beta2.AnalyzeSyntaxRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.language.v1beta2.AnalyzeSyntaxResponse() - ); - client.innerApiCalls.analyzeSyntax = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.analyzeSyntax( - request, - (err?: Error|null, result?: protos.google.cloud.language.v1beta2.IAnalyzeSyntaxResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - }); + it('invokes analyzeEntitySentiment without error using callback', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1beta2.AnalyzeEntitySentimentRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v1beta2.AnalyzeEntitySentimentResponse(), + ); + client.innerApiCalls.analyzeEntitySentiment = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.analyzeEntitySentiment( + request, + ( + err?: Error | null, + result?: protos.google.cloud.language.v1beta2.IAnalyzeEntitySentimentResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes analyzeSyntax with error', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v1beta2.AnalyzeSyntaxRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.analyzeSyntax = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.analyzeSyntax(request), expectedError); - }); + it('invokes analyzeEntitySentiment with error', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1beta2.AnalyzeEntitySentimentRequest(), + ); + const expectedError = new Error('expected'); + client.innerApiCalls.analyzeEntitySentiment = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.analyzeEntitySentiment(request), + expectedError, + ); + }); - it('invokes analyzeSyntax with closed client', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v1beta2.AnalyzeSyntaxRequest() - ); - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.analyzeSyntax(request), expectedError); - }); + it('invokes analyzeEntitySentiment with closed client', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1beta2.AnalyzeEntitySentimentRequest(), + ); + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.analyzeEntitySentiment(request), + expectedError, + ); + }); + }); + + describe('analyzeSyntax', () => { + it('invokes analyzeSyntax without error', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1beta2.AnalyzeSyntaxRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v1beta2.AnalyzeSyntaxResponse(), + ); + client.innerApiCalls.analyzeSyntax = stubSimpleCall(expectedResponse); + const [response] = await client.analyzeSyntax(request); + assert.deepStrictEqual(response, expectedResponse); }); - describe('classifyText', () => { - it('invokes classifyText without error', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v1beta2.ClassifyTextRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.language.v1beta2.ClassifyTextResponse() - ); - client.innerApiCalls.classifyText = stubSimpleCall(expectedResponse); - const [response] = await client.classifyText(request); - assert.deepStrictEqual(response, expectedResponse); - }); + it('invokes analyzeSyntax without error using callback', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1beta2.AnalyzeSyntaxRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v1beta2.AnalyzeSyntaxResponse(), + ); + client.innerApiCalls.analyzeSyntax = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.analyzeSyntax( + request, + ( + err?: Error | null, + result?: protos.google.cloud.language.v1beta2.IAnalyzeSyntaxResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes classifyText without error using callback', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v1beta2.ClassifyTextRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.language.v1beta2.ClassifyTextResponse() - ); - client.innerApiCalls.classifyText = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.classifyText( - request, - (err?: Error|null, result?: protos.google.cloud.language.v1beta2.IClassifyTextResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - }); + it('invokes analyzeSyntax with error', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1beta2.AnalyzeSyntaxRequest(), + ); + const expectedError = new Error('expected'); + client.innerApiCalls.analyzeSyntax = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.analyzeSyntax(request), expectedError); + }); - it('invokes classifyText with error', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v1beta2.ClassifyTextRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.classifyText = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.classifyText(request), expectedError); - }); + it('invokes analyzeSyntax with closed client', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1beta2.AnalyzeSyntaxRequest(), + ); + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.analyzeSyntax(request), expectedError); + }); + }); + + describe('classifyText', () => { + it('invokes classifyText without error', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1beta2.ClassifyTextRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v1beta2.ClassifyTextResponse(), + ); + client.innerApiCalls.classifyText = stubSimpleCall(expectedResponse); + const [response] = await client.classifyText(request); + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes classifyText with closed client', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v1beta2.ClassifyTextRequest() - ); - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.classifyText(request), expectedError); - }); + it('invokes classifyText without error using callback', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1beta2.ClassifyTextRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v1beta2.ClassifyTextResponse(), + ); + client.innerApiCalls.classifyText = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.classifyText( + request, + ( + err?: Error | null, + result?: protos.google.cloud.language.v1beta2.IClassifyTextResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); }); - describe('moderateText', () => { - it('invokes moderateText without error', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v1beta2.ModerateTextRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.language.v1beta2.ModerateTextResponse() - ); - client.innerApiCalls.moderateText = stubSimpleCall(expectedResponse); - const [response] = await client.moderateText(request); - assert.deepStrictEqual(response, expectedResponse); - }); + it('invokes classifyText with error', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1beta2.ClassifyTextRequest(), + ); + const expectedError = new Error('expected'); + client.innerApiCalls.classifyText = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.classifyText(request), expectedError); + }); - it('invokes moderateText without error using callback', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v1beta2.ModerateTextRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.language.v1beta2.ModerateTextResponse() - ); - client.innerApiCalls.moderateText = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.moderateText( - request, - (err?: Error|null, result?: protos.google.cloud.language.v1beta2.IModerateTextResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - }); + it('invokes classifyText with closed client', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1beta2.ClassifyTextRequest(), + ); + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.classifyText(request), expectedError); + }); + }); + + describe('moderateText', () => { + it('invokes moderateText without error', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1beta2.ModerateTextRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v1beta2.ModerateTextResponse(), + ); + client.innerApiCalls.moderateText = stubSimpleCall(expectedResponse); + const [response] = await client.moderateText(request); + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes moderateText with error', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v1beta2.ModerateTextRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.moderateText = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.moderateText(request), expectedError); - }); + it('invokes moderateText without error using callback', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1beta2.ModerateTextRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v1beta2.ModerateTextResponse(), + ); + client.innerApiCalls.moderateText = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.moderateText( + request, + ( + err?: Error | null, + result?: protos.google.cloud.language.v1beta2.IModerateTextResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes moderateText with closed client', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v1beta2.ModerateTextRequest() - ); - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.moderateText(request), expectedError); - }); + it('invokes moderateText with error', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1beta2.ModerateTextRequest(), + ); + const expectedError = new Error('expected'); + client.innerApiCalls.moderateText = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.moderateText(request), expectedError); }); - describe('annotateText', () => { - it('invokes annotateText without error', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v1beta2.AnnotateTextRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.language.v1beta2.AnnotateTextResponse() - ); - client.innerApiCalls.annotateText = stubSimpleCall(expectedResponse); - const [response] = await client.annotateText(request); - assert.deepStrictEqual(response, expectedResponse); - }); + it('invokes moderateText with closed client', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1beta2.ModerateTextRequest(), + ); + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.moderateText(request), expectedError); + }); + }); + + describe('annotateText', () => { + it('invokes annotateText without error', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1beta2.AnnotateTextRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v1beta2.AnnotateTextResponse(), + ); + client.innerApiCalls.annotateText = stubSimpleCall(expectedResponse); + const [response] = await client.annotateText(request); + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes annotateText without error using callback', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v1beta2.AnnotateTextRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.language.v1beta2.AnnotateTextResponse() - ); - client.innerApiCalls.annotateText = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.annotateText( - request, - (err?: Error|null, result?: protos.google.cloud.language.v1beta2.IAnnotateTextResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - }); + it('invokes annotateText without error using callback', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1beta2.AnnotateTextRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v1beta2.AnnotateTextResponse(), + ); + client.innerApiCalls.annotateText = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.annotateText( + request, + ( + err?: Error | null, + result?: protos.google.cloud.language.v1beta2.IAnnotateTextResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes annotateText with error', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v1beta2.AnnotateTextRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.annotateText = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.annotateText(request), expectedError); - }); + it('invokes annotateText with error', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1beta2.AnnotateTextRequest(), + ); + const expectedError = new Error('expected'); + client.innerApiCalls.annotateText = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.annotateText(request), expectedError); + }); - it('invokes annotateText with closed client', async () => { - const client = new languageserviceModule.v1beta2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v1beta2.AnnotateTextRequest() - ); - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.annotateText(request), expectedError); - }); + it('invokes annotateText with closed client', async () => { + const client = new languageserviceModule.v1beta2.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v1beta2.AnnotateTextRequest(), + ); + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.annotateText(request), expectedError); }); + }); }); diff --git a/packages/google-cloud-language/test/gapic_language_service_v2.ts b/packages/google-cloud-language/test/gapic_language_service_v2.ts index 6aff899448c9..206f4a5263d4 100644 --- a/packages/google-cloud-language/test/gapic_language_service_v2.ts +++ b/packages/google-cloud-language/test/gapic_language_service_v2.ts @@ -19,571 +19,663 @@ 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 languageserviceModule 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('v2.LanguageServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new languageserviceModule.v2.LanguageServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'language.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new languageserviceModule.v2.LanguageServiceClient(); - 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 = languageserviceModule.v2.LanguageServiceClient.servicePath; - assert.strictEqual(servicePath, 'language.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = languageserviceModule.v2.LanguageServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'language.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new languageserviceModule.v2.LanguageServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'language.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new languageserviceModule.v2.LanguageServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'language.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 languageserviceModule.v2.LanguageServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'language.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 languageserviceModule.v2.LanguageServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'language.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 languageserviceModule.v2.LanguageServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); - - it('has port', () => { - const port = languageserviceModule.v2.LanguageServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new languageserviceModule.v2.LanguageServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'language.googleapis.com'); + }); - it('should create a client with no option', () => { - const client = new languageserviceModule.v2.LanguageServiceClient(); - assert(client); - }); + it('has universeDomain', () => { + const client = new languageserviceModule.v2.LanguageServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('should create a client with gRPC fallback', () => { - const client = new languageserviceModule.v2.LanguageServiceClient({ - fallback: true, - }); - assert(client); - }); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + languageserviceModule.v2.LanguageServiceClient.servicePath; + assert.strictEqual(servicePath, 'language.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + languageserviceModule.v2.LanguageServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'language.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new languageserviceModule.v2.LanguageServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'language.example.com'); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new languageserviceModule.v2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.languageServiceStub, undefined); - await client.initialize(); - assert(client.languageServiceStub); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new languageserviceModule.v2.LanguageServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'language.example.com'); + }); - it('has close method for the initialized client', done => { - const client = new languageserviceModule.v2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.languageServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new languageserviceModule.v2.LanguageServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'language.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 languageserviceModule.v2.LanguageServiceClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'language.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 languageserviceModule.v2.LanguageServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('has close method for the non-initialized client', done => { - const client = new languageserviceModule.v2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.languageServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has port', () => { + const port = languageserviceModule.v2.LanguageServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new languageserviceModule.v2.LanguageServiceClient({ - 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 languageserviceModule.v2.LanguageServiceClient(); + assert(client); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new languageserviceModule.v2.LanguageServiceClient({ - 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 languageserviceModule.v2.LanguageServiceClient({ + fallback: true, + }); + assert(client); }); - describe('analyzeSentiment', () => { - it('invokes analyzeSentiment without error', async () => { - const client = new languageserviceModule.v2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v2.AnalyzeSentimentRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.language.v2.AnalyzeSentimentResponse() - ); - client.innerApiCalls.analyzeSentiment = stubSimpleCall(expectedResponse); - const [response] = await client.analyzeSentiment(request); - assert.deepStrictEqual(response, expectedResponse); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new languageserviceModule.v2.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.languageServiceStub, undefined); + await client.initialize(); + assert(client.languageServiceStub); + }); - it('invokes analyzeSentiment without error using callback', async () => { - const client = new languageserviceModule.v2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v2.AnalyzeSentimentRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.language.v2.AnalyzeSentimentResponse() - ); - client.innerApiCalls.analyzeSentiment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.analyzeSentiment( - request, - (err?: Error|null, result?: protos.google.cloud.language.v2.IAnalyzeSentimentResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); + it('has close method for the initialized client', (done) => { + const client = new languageserviceModule.v2.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.languageServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes analyzeSentiment with error', async () => { - const client = new languageserviceModule.v2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v2.AnalyzeSentimentRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.analyzeSentiment = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.analyzeSentiment(request), expectedError); + it('has close method for the non-initialized client', (done) => { + const client = new languageserviceModule.v2.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.languageServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes analyzeSentiment with closed client', async () => { - const client = new languageserviceModule.v2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v2.AnalyzeSentimentRequest() - ); - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.analyzeSentiment(request), expectedError); - }); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new languageserviceModule.v2.LanguageServiceClient({ + 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('analyzeEntities', () => { - it('invokes analyzeEntities without error', async () => { - const client = new languageserviceModule.v2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v2.AnalyzeEntitiesRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.language.v2.AnalyzeEntitiesResponse() - ); - client.innerApiCalls.analyzeEntities = stubSimpleCall(expectedResponse); - const [response] = await client.analyzeEntities(request); - assert.deepStrictEqual(response, expectedResponse); - }); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new languageserviceModule.v2.LanguageServiceClient({ + 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('analyzeSentiment', () => { + it('invokes analyzeSentiment without error', async () => { + const client = new languageserviceModule.v2.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v2.AnalyzeSentimentRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v2.AnalyzeSentimentResponse(), + ); + client.innerApiCalls.analyzeSentiment = stubSimpleCall(expectedResponse); + const [response] = await client.analyzeSentiment(request); + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes analyzeEntities without error using callback', async () => { - const client = new languageserviceModule.v2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v2.AnalyzeEntitiesRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.language.v2.AnalyzeEntitiesResponse() - ); - client.innerApiCalls.analyzeEntities = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.analyzeEntities( - request, - (err?: Error|null, result?: protos.google.cloud.language.v2.IAnalyzeEntitiesResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - }); + it('invokes analyzeSentiment without error using callback', async () => { + const client = new languageserviceModule.v2.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v2.AnalyzeSentimentRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v2.AnalyzeSentimentResponse(), + ); + client.innerApiCalls.analyzeSentiment = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.analyzeSentiment( + request, + ( + err?: Error | null, + result?: protos.google.cloud.language.v2.IAnalyzeSentimentResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes analyzeEntities with error', async () => { - const client = new languageserviceModule.v2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v2.AnalyzeEntitiesRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.analyzeEntities = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.analyzeEntities(request), expectedError); - }); + it('invokes analyzeSentiment with error', async () => { + const client = new languageserviceModule.v2.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v2.AnalyzeSentimentRequest(), + ); + const expectedError = new Error('expected'); + client.innerApiCalls.analyzeSentiment = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.analyzeSentiment(request), expectedError); + }); - it('invokes analyzeEntities with closed client', async () => { - const client = new languageserviceModule.v2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v2.AnalyzeEntitiesRequest() - ); - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.analyzeEntities(request), expectedError); - }); + it('invokes analyzeSentiment with closed client', async () => { + const client = new languageserviceModule.v2.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v2.AnalyzeSentimentRequest(), + ); + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.analyzeSentiment(request), expectedError); + }); + }); + + describe('analyzeEntities', () => { + it('invokes analyzeEntities without error', async () => { + const client = new languageserviceModule.v2.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v2.AnalyzeEntitiesRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v2.AnalyzeEntitiesResponse(), + ); + client.innerApiCalls.analyzeEntities = stubSimpleCall(expectedResponse); + const [response] = await client.analyzeEntities(request); + assert.deepStrictEqual(response, expectedResponse); }); - describe('classifyText', () => { - it('invokes classifyText without error', async () => { - const client = new languageserviceModule.v2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v2.ClassifyTextRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.language.v2.ClassifyTextResponse() - ); - client.innerApiCalls.classifyText = stubSimpleCall(expectedResponse); - const [response] = await client.classifyText(request); - assert.deepStrictEqual(response, expectedResponse); - }); + it('invokes analyzeEntities without error using callback', async () => { + const client = new languageserviceModule.v2.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v2.AnalyzeEntitiesRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v2.AnalyzeEntitiesResponse(), + ); + client.innerApiCalls.analyzeEntities = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.analyzeEntities( + request, + ( + err?: Error | null, + result?: protos.google.cloud.language.v2.IAnalyzeEntitiesResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes classifyText without error using callback', async () => { - const client = new languageserviceModule.v2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v2.ClassifyTextRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.language.v2.ClassifyTextResponse() - ); - client.innerApiCalls.classifyText = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.classifyText( - request, - (err?: Error|null, result?: protos.google.cloud.language.v2.IClassifyTextResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - }); + it('invokes analyzeEntities with error', async () => { + const client = new languageserviceModule.v2.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v2.AnalyzeEntitiesRequest(), + ); + const expectedError = new Error('expected'); + client.innerApiCalls.analyzeEntities = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.analyzeEntities(request), expectedError); + }); - it('invokes classifyText with error', async () => { - const client = new languageserviceModule.v2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v2.ClassifyTextRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.classifyText = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.classifyText(request), expectedError); - }); + it('invokes analyzeEntities with closed client', async () => { + const client = new languageserviceModule.v2.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v2.AnalyzeEntitiesRequest(), + ); + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.analyzeEntities(request), expectedError); + }); + }); + + describe('classifyText', () => { + it('invokes classifyText without error', async () => { + const client = new languageserviceModule.v2.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v2.ClassifyTextRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v2.ClassifyTextResponse(), + ); + client.innerApiCalls.classifyText = stubSimpleCall(expectedResponse); + const [response] = await client.classifyText(request); + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes classifyText with closed client', async () => { - const client = new languageserviceModule.v2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v2.ClassifyTextRequest() - ); - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.classifyText(request), expectedError); - }); + it('invokes classifyText without error using callback', async () => { + const client = new languageserviceModule.v2.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v2.ClassifyTextRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v2.ClassifyTextResponse(), + ); + client.innerApiCalls.classifyText = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.classifyText( + request, + ( + err?: Error | null, + result?: protos.google.cloud.language.v2.IClassifyTextResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); }); - describe('moderateText', () => { - it('invokes moderateText without error', async () => { - const client = new languageserviceModule.v2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v2.ModerateTextRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.language.v2.ModerateTextResponse() - ); - client.innerApiCalls.moderateText = stubSimpleCall(expectedResponse); - const [response] = await client.moderateText(request); - assert.deepStrictEqual(response, expectedResponse); - }); + it('invokes classifyText with error', async () => { + const client = new languageserviceModule.v2.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v2.ClassifyTextRequest(), + ); + const expectedError = new Error('expected'); + client.innerApiCalls.classifyText = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.classifyText(request), expectedError); + }); - it('invokes moderateText without error using callback', async () => { - const client = new languageserviceModule.v2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v2.ModerateTextRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.language.v2.ModerateTextResponse() - ); - client.innerApiCalls.moderateText = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.moderateText( - request, - (err?: Error|null, result?: protos.google.cloud.language.v2.IModerateTextResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - }); + it('invokes classifyText with closed client', async () => { + const client = new languageserviceModule.v2.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v2.ClassifyTextRequest(), + ); + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.classifyText(request), expectedError); + }); + }); + + describe('moderateText', () => { + it('invokes moderateText without error', async () => { + const client = new languageserviceModule.v2.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v2.ModerateTextRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v2.ModerateTextResponse(), + ); + client.innerApiCalls.moderateText = stubSimpleCall(expectedResponse); + const [response] = await client.moderateText(request); + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes moderateText with error', async () => { - const client = new languageserviceModule.v2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v2.ModerateTextRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.moderateText = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.moderateText(request), expectedError); - }); + it('invokes moderateText without error using callback', async () => { + const client = new languageserviceModule.v2.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v2.ModerateTextRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v2.ModerateTextResponse(), + ); + client.innerApiCalls.moderateText = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.moderateText( + request, + ( + err?: Error | null, + result?: protos.google.cloud.language.v2.IModerateTextResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes moderateText with closed client', async () => { - const client = new languageserviceModule.v2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v2.ModerateTextRequest() - ); - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.moderateText(request), expectedError); - }); + it('invokes moderateText with error', async () => { + const client = new languageserviceModule.v2.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v2.ModerateTextRequest(), + ); + const expectedError = new Error('expected'); + client.innerApiCalls.moderateText = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.moderateText(request), expectedError); }); - describe('annotateText', () => { - it('invokes annotateText without error', async () => { - const client = new languageserviceModule.v2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v2.AnnotateTextRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.language.v2.AnnotateTextResponse() - ); - client.innerApiCalls.annotateText = stubSimpleCall(expectedResponse); - const [response] = await client.annotateText(request); - assert.deepStrictEqual(response, expectedResponse); - }); + it('invokes moderateText with closed client', async () => { + const client = new languageserviceModule.v2.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v2.ModerateTextRequest(), + ); + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.moderateText(request), expectedError); + }); + }); + + describe('annotateText', () => { + it('invokes annotateText without error', async () => { + const client = new languageserviceModule.v2.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v2.AnnotateTextRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v2.AnnotateTextResponse(), + ); + client.innerApiCalls.annotateText = stubSimpleCall(expectedResponse); + const [response] = await client.annotateText(request); + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes annotateText without error using callback', async () => { - const client = new languageserviceModule.v2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v2.AnnotateTextRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.language.v2.AnnotateTextResponse() - ); - client.innerApiCalls.annotateText = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.annotateText( - request, - (err?: Error|null, result?: protos.google.cloud.language.v2.IAnnotateTextResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - }); + it('invokes annotateText without error using callback', async () => { + const client = new languageserviceModule.v2.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v2.AnnotateTextRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.language.v2.AnnotateTextResponse(), + ); + client.innerApiCalls.annotateText = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.annotateText( + request, + ( + err?: Error | null, + result?: protos.google.cloud.language.v2.IAnnotateTextResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes annotateText with error', async () => { - const client = new languageserviceModule.v2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v2.AnnotateTextRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.annotateText = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.annotateText(request), expectedError); - }); + it('invokes annotateText with error', async () => { + const client = new languageserviceModule.v2.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v2.AnnotateTextRequest(), + ); + const expectedError = new Error('expected'); + client.innerApiCalls.annotateText = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.annotateText(request), expectedError); + }); - it('invokes annotateText with closed client', async () => { - const client = new languageserviceModule.v2.LanguageServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.language.v2.AnnotateTextRequest() - ); - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.annotateText(request), expectedError); - }); + it('invokes annotateText with closed client', async () => { + const client = new languageserviceModule.v2.LanguageServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.language.v2.AnnotateTextRequest(), + ); + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.annotateText(request), expectedError); }); + }); }); diff --git a/packages/google-cloud-language/webpack.config.js b/packages/google-cloud-language/webpack.config.js index 127cf7dff459..c90df1063ed4 100644 --- a/packages/google-cloud-language/webpack.config.js +++ b/packages/google-cloud-language/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-licensemanager/.eslintignore b/packages/google-cloud-licensemanager/.eslintignore new file mode 100644 index 000000000000..cfc348ec4d11 --- /dev/null +++ b/packages/google-cloud-licensemanager/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/packages/google-cloud-licensemanager/.eslintrc.json b/packages/google-cloud-licensemanager/.eslintrc.json new file mode 100644 index 000000000000..3e8d97ccb390 --- /dev/null +++ b/packages/google-cloud-licensemanager/.eslintrc.json @@ -0,0 +1,4 @@ +{ + "extends": "./node_modules/gts", + "root": true +} diff --git a/packages/google-cloud-licensemanager/README.md b/packages/google-cloud-licensemanager/README.md index 149fd431f864..89f63d6bfe95 100644 --- a/packages/google-cloud-licensemanager/README.md +++ b/packages/google-cloud-licensemanager/README.md @@ -104,7 +104,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-licensemanager/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`) @@ -114,7 +114,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-licensemanager/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-licensemanager/protos/protos.d.ts b/packages/google-cloud-licensemanager/protos/protos.d.ts index eb5f8e639d44..338dcb325709 100644 --- a/packages/google-cloud-licensemanager/protos/protos.d.ts +++ b/packages/google-cloud-licensemanager/protos/protos.d.ts @@ -3954,6 +3954,9 @@ export namespace google { /** CommonLanguageSettings destinations */ destinations?: (google.api.ClientLibraryDestination[]|null); + + /** CommonLanguageSettings selectiveGapicGeneration */ + selectiveGapicGeneration?: (google.api.ISelectiveGapicGeneration|null); } /** Represents a CommonLanguageSettings. */ @@ -3971,6 +3974,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 @@ -4671,6 +4677,9 @@ export namespace google { /** PythonSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** PythonSettings experimentalFeatures */ + experimentalFeatures?: (google.api.PythonSettings.IExperimentalFeatures|null); } /** Represents a PythonSettings. */ @@ -4685,6 +4694,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 @@ -4763,6 +4775,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 { @@ -5089,6 +5213,9 @@ export namespace google { /** GoSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** GoSettings renamedServices */ + renamedServices?: ({ [k: string]: string }|null); } /** Represents a GoSettings. */ @@ -5103,6 +5230,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 @@ -5427,6 +5557,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, @@ -5444,6 +5677,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. */ @@ -5458,6 +5694,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 @@ -5547,6 +5786,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. */ @@ -5652,6 +5988,7 @@ export namespace google { /** Edition enum. */ enum Edition { EDITION_UNKNOWN = 0, + EDITION_LEGACY = 900, EDITION_PROTO2 = 998, EDITION_PROTO3 = 999, EDITION_2023 = 1000, @@ -5682,6 +6019,9 @@ export namespace google { /** FileDescriptorProto weakDependency */ weakDependency?: (number[]|null); + /** FileDescriptorProto optionDependency */ + optionDependency?: (string[]|null); + /** FileDescriptorProto messageType */ messageType?: (google.protobuf.IDescriptorProto[]|null); @@ -5731,6 +6071,9 @@ export namespace google { /** FileDescriptorProto weakDependency. */ public weakDependency: number[]; + /** FileDescriptorProto optionDependency. */ + public optionDependency: string[]; + /** FileDescriptorProto messageType. */ public messageType: google.protobuf.IDescriptorProto[]; @@ -5865,6 +6208,9 @@ export namespace google { /** DescriptorProto reservedName */ reservedName?: (string[]|null); + + /** DescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents a DescriptorProto. */ @@ -5906,6 +6252,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 @@ -6753,6 +7102,9 @@ export namespace google { /** EnumDescriptorProto reservedName */ reservedName?: (string[]|null); + + /** EnumDescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents an EnumDescriptorProto. */ @@ -6779,6 +7131,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 @@ -7713,6 +8068,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); @@ -7771,6 +8129,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[]; @@ -7991,6 +8352,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. */ @@ -8229,6 +8705,9 @@ export namespace google { /** EnumValueOptions debugRedact */ debugRedact?: (boolean|null); + /** EnumValueOptions featureSupport */ + featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** EnumValueOptions uninterpretedOption */ uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); } @@ -8251,6 +8730,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[]; @@ -8843,6 +9325,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. */ @@ -8872,6 +9360,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 @@ -8994,6 +9488,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. */ @@ -9113,8 +9717,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. */ @@ -9129,8 +9736,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. @@ -9663,6 +10273,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-licensemanager/protos/protos.js b/packages/google-cloud-licensemanager/protos/protos.js index 844f3249aaa4..ead3187bce29 100644 --- a/packages/google-cloud-licensemanager/protos/protos.js +++ b/packages/google-cloud-licensemanager/protos/protos.js @@ -9833,6 +9833,7 @@ * @interface ICommonLanguageSettings * @property {string|null} [referenceDocsUri] CommonLanguageSettings referenceDocsUri * @property {Array.|null} [destinations] CommonLanguageSettings destinations + * @property {google.api.ISelectiveGapicGeneration|null} [selectiveGapicGeneration] CommonLanguageSettings selectiveGapicGeneration */ /** @@ -9867,6 +9868,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 @@ -9899,6 +9908,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; }; @@ -9950,6 +9961,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; @@ -10001,6 +10016,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; }; @@ -10043,6 +10063,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; }; @@ -10061,8 +10086,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) { @@ -10070,6 +10097,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; }; @@ -11892,6 +11921,7 @@ * @memberof google.api * @interface IPythonSettings * @property {google.api.ICommonLanguageSettings|null} [common] PythonSettings common + * @property {google.api.PythonSettings.IExperimentalFeatures|null} [experimentalFeatures] PythonSettings experimentalFeatures */ /** @@ -11917,6 +11947,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 @@ -11943,6 +11981,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; }; @@ -11983,6 +12023,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; @@ -12023,6 +12067,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; }; @@ -12043,6 +12092,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; }; @@ -12059,10 +12113,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; }; @@ -12092,6 +12150,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; })(); @@ -12968,6 +13278,7 @@ * @memberof google.api * @interface IGoSettings * @property {google.api.ICommonLanguageSettings|null} [common] GoSettings common + * @property {Object.|null} [renamedServices] GoSettings renamedServices */ /** @@ -12979,6 +13290,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) @@ -12993,6 +13305,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 @@ -13019,6 +13339,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; }; @@ -13049,7 +13372,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) @@ -13059,6 +13382,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; @@ -13099,6 +13445,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; }; @@ -13119,6 +13473,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; }; @@ -13135,10 +13496,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; }; @@ -13777,30 +14146,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; })(); api.FieldInfo = (function() { @@ -13810,6 +14424,7 @@ * @memberof google.api * @interface IFieldInfo * @property {google.api.FieldInfo.Format|null} [format] FieldInfo format + * @property {Array.|null} [referencedTypes] FieldInfo referencedTypes */ /** @@ -13821,6 +14436,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) @@ -13835,6 +14451,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 @@ -13861,6 +14485,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; }; @@ -13901,6 +14528,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; @@ -13947,6 +14580,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; }; @@ -13990,6 +14632,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; }; @@ -14006,10 +14658,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; }; @@ -14062,37 +14721,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) @@ -14100,80 +14746,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: @@ -14185,39 +14828,260 @@ }; /** - * 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 (error) - return "file." + error; + 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; } } return null; @@ -14305,6 +15169,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 @@ -14319,6 +15184,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; @@ -14343,6 +15209,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 @@ -14365,6 +15232,7 @@ this.dependency = []; this.publicDependency = []; this.weakDependency = []; + this.optionDependency = []; this.messageType = []; this.enumType = []; this.service = []; @@ -14415,6 +15283,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 @@ -14536,6 +15412,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; }; @@ -14608,6 +15487,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 = []; @@ -14710,6 +15595,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"; @@ -14764,6 +15656,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -14816,6 +15709,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"); @@ -14879,6 +15779,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -14944,6 +15848,7 @@ object.extension = []; object.publicDependency = []; object.weakDependency = []; + object.optionDependency = []; } if (options.defaults) { object.name = ""; @@ -15000,6 +15905,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; }; @@ -15048,6 +15958,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 */ /** @@ -15153,6 +16064,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 @@ -15205,6 +16124,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; }; @@ -15297,6 +16218,10 @@ message.reservedName.push(reader.string()); break; } + case 11: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -15410,6 +16335,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; }; @@ -15509,6 +16443,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; }; @@ -15538,6 +16492,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; @@ -15583,6 +16538,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; }; @@ -17627,6 +18584,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 */ /** @@ -17687,6 +18645,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 @@ -17724,6 +18690,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; }; @@ -17786,6 +18754,10 @@ message.reservedName.push(reader.string()); break; } + case 6: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -17854,7 +18826,16 @@ 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; }; /** @@ -17903,6 +18884,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; }; @@ -17927,6 +18928,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; @@ -17947,6 +18949,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; }; @@ -20265,6 +21269,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 @@ -20386,6 +21391,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 @@ -20468,6 +21481,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(); @@ -20571,6 +21586,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 = []; @@ -20710,6 +21729,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"; @@ -20903,6 +21927,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"); @@ -21005,6 +22034,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; } @@ -21038,6 +22068,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) @@ -21312,6 +22344,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -21353,103 +22386,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; @@ -22044,6 +23563,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 */ @@ -22087,6 +23607,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 @@ -22125,6 +23653,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(); @@ -22176,6 +23706,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 = []; @@ -22228,6 +23762,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"; @@ -22261,6 +23800,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"); @@ -22293,6 +23837,7 @@ object.deprecated = false; object.features = null; object.debugRedact = false; + object.featureSupport = null; } if (message.deprecated != null && message.hasOwnProperty("deprecated")) object.deprecated = message.deprecated; @@ -22300,6 +23845,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) @@ -23767,6 +25314,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 */ /** @@ -23832,6 +25381,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 @@ -23868,6 +25433,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; }; @@ -23928,6 +25497,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; @@ -24018,6 +25595,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; }; @@ -24157,6 +25754,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; }; @@ -24180,6 +25825,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; @@ -24193,6 +25840,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; }; @@ -24320,6 +25971,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; })(); @@ -24504,6 +26368,7 @@ default: return "minimumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -24521,6 +26386,7 @@ default: return "maximumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -24569,6 +26435,10 @@ case 0: message.minimumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.minimumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.minimumEdition = 998; @@ -24621,6 +26491,10 @@ case 0: message.maximumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.maximumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.maximumEdition = 998; @@ -24729,7 +26603,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 */ /** @@ -24756,12 +26631,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. @@ -24787,10 +26670,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; }; @@ -24831,8 +26716,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: @@ -24875,6 +26764,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -24887,10 +26777,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; }; @@ -24918,6 +26813,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -24959,10 +26858,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; }; @@ -24981,13 +26885,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; }; @@ -26202,6 +28109,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-licensemanager/protos/protos.json b/packages/google-cloud-licensemanager/protos/protos.json index 2a60163befe5..ab8fdbafb656 100644 --- a/packages/google-cloud-licensemanager/protos/protos.json +++ b/packages/google-cloud-licensemanager/protos/protos.json @@ -1156,8 +1156,7 @@ "java_multiple_files": true, "java_outer_classname": "FieldInfoProto", "java_package": "com.google.api", - "objc_class_prefix": "GAPI", - "cc_enable_arenas": true + "objc_class_prefix": "GAPI" }, "nested": { "fieldBehavior": { @@ -1380,6 +1379,10 @@ "rule": "repeated", "type": "ClientLibraryDestination", "id": 2 + }, + "selectiveGapicGeneration": { + "type": "SelectiveGapicGeneration", + "id": 3 } } }, @@ -1520,6 +1523,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 + } + } } } }, @@ -1577,6 +1602,11 @@ "common": { "type": "CommonLanguageSettings", "id": 1 + }, + "renamedServices": { + "keyType": "string", + "type": "string", + "id": 2 } } }, @@ -1638,6 +1668,19 @@ "PACKAGE_MANAGER": 20 } }, + "SelectiveGapicGeneration": { + "fields": { + "methods": { + "rule": "repeated", + "type": "string", + "id": 1 + }, + "generateOmittedAsInternal": { + "type": "bool", + "id": 2 + } + } + }, "LaunchStage": { "values": { "LAUNCH_STAGE_UNSPECIFIED": 0, @@ -1660,6 +1703,11 @@ "format": { "type": "Format", "id": 1 + }, + "referencedTypes": { + "rule": "repeated", + "type": "TypeReference", + "id": 2 } }, "nested": { @@ -1673,6 +1721,14 @@ } } } + }, + "TypeReference": { + "fields": { + "typeName": { + "type": "string", + "id": 1 + } + } } } }, @@ -1695,12 +1751,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, @@ -1739,6 +1802,11 @@ "type": "int32", "id": 11 }, + "optionDependency": { + "rule": "repeated", + "type": "string", + "id": 15 + }, "messageType": { "rule": "repeated", "type": "DescriptorProto", @@ -1827,6 +1895,10 @@ "rule": "repeated", "type": "string", "id": 10 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 11 } }, "nested": { @@ -2052,6 +2124,10 @@ "rule": "repeated", "type": "string", "id": 5 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 6 } }, "nested": { @@ -2102,7 +2178,14 @@ "type": "ServiceOptions", "id": 3 } - } + }, + "reserved": [ + [ + 4, + 4 + ], + "stream" + ] }, "MethodDescriptorProto": { "edition": "proto2", @@ -2266,6 +2349,7 @@ 42, 42 ], + "php_generic_services", [ 38, 38 @@ -2401,7 +2485,8 @@ "type": "bool", "id": 10, "options": { - "default": false + "default": false, + "deprecated": true } }, "debugRedact": { @@ -2429,6 +2514,10 @@ "type": "FeatureSet", "id": 21 }, + "featureSupport": { + "type": "FeatureSupport", + "id": 22 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -2498,6 +2587,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 + } + } } } }, @@ -2586,6 +2695,10 @@ "default": false } }, + "featureSupport": { + "type": "FieldOptions.FeatureSupport", + "id": 4 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -2728,6 +2841,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_2023", "edition_defaults.value": "EXPLICIT" } @@ -2738,6 +2852,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "OPEN" } @@ -2748,6 +2863,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "PACKED" } @@ -2758,6 +2874,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "VERIFY" } @@ -2768,7 +2885,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" } }, @@ -2778,27 +2896,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, @@ -2843,7 +2972,13 @@ "UTF8_VALIDATION_UNKNOWN": 0, "VERIFY": 2, "NONE": 3 - } + }, + "reserved": [ + [ + 1, + 1 + ] + ] }, "MessageEncoding": { "values": { @@ -2858,6 +2993,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 + } + } + } } } }, @@ -2885,11 +3047,26 @@ "type": "Edition", "id": 3 }, - "features": { + "overridableFeatures": { "type": "FeatureSet", - "id": 2 + "id": 4 + }, + "fixedFeatures": { + "type": "FeatureSet", + "id": 5 } - } + }, + "reserved": [ + [ + 1, + 1 + ], + [ + 2, + 2 + ], + "features" + ] } } }, @@ -2902,6 +3079,12 @@ "id": 1 } }, + "extensions": [ + [ + 536000000, + 536000000 + ] + ], "nested": { "Location": { "fields": { @@ -2987,6 +3170,14 @@ } } }, + "SymbolVisibility": { + "edition": "proto2", + "values": { + "VISIBILITY_UNSET": 0, + "VISIBILITY_LOCAL": 1, + "VISIBILITY_EXPORT": 2 + } + }, "Timestamp": { "fields": { "seconds": { @@ -3045,6 +3236,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-licensemanager/samples/generated/v1/snippet_metadata_google.cloud.licensemanager.v1.json b/packages/google-cloud-licensemanager/samples/generated/v1/snippet_metadata_google.cloud.licensemanager.v1.json index 1bada8727c26..5aa64dcaeaf7 100644 --- a/packages/google-cloud-licensemanager/samples/generated/v1/snippet_metadata_google.cloud.licensemanager.v1.json +++ b/packages/google-cloud-licensemanager/samples/generated/v1/snippet_metadata_google.cloud.licensemanager.v1.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-licensemanager", - "version": "0.1.1", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-licensemanager/src/v1/index.ts b/packages/google-cloud-licensemanager/src/v1/index.ts index abeb78df0916..f306d71e17d3 100644 --- a/packages/google-cloud-licensemanager/src/v1/index.ts +++ b/packages/google-cloud-licensemanager/src/v1/index.ts @@ -16,4 +16,4 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {LicenseManagerClient} from './license_manager_client'; +export { LicenseManagerClient } from './license_manager_client'; diff --git a/packages/google-cloud-licensemanager/src/v1/license_manager_client.ts b/packages/google-cloud-licensemanager/src/v1/license_manager_client.ts index 46027510bb2a..3799e9aa24b1 100644 --- a/packages/google-cloud-licensemanager/src/v1/license_manager_client.ts +++ b/packages/google-cloud-licensemanager/src/v1/license_manager_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 LicenseManagerClient { 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('licensemanager'); @@ -57,11 +68,11 @@ export class LicenseManagerClient { 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; - licenseManagerStub?: Promise<{[name: string]: Function}>; + licenseManagerStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of LicenseManagerClient. @@ -102,21 +113,42 @@ export class LicenseManagerClient { * const client = new LicenseManagerClient({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 LicenseManagerClient; - 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 = 'licensemanager.' + 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 LicenseManagerClient { 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 LicenseManagerClient { } 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 LicenseManagerClient { // Create useful helper objects for these. this.pathTemplates = { configurationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/configurations/{configuration}' + 'projects/{project}/locations/{location}/configurations/{configuration}', ), instancePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/instances/{instance}' + 'projects/{project}/locations/{location}/instances/{instance}', ), locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' + 'projects/{project}/locations/{location}', ), productPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/products/{product}' + 'projects/{project}/locations/{location}/products/{product}', ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' + 'projects/{project}', ), }; @@ -205,14 +233,26 @@ export class LicenseManagerClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listConfigurations: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'configurations'), - listInstances: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'instances'), - aggregateUsage: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'usages'), - listProducts: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'products') + listConfigurations: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'configurations', + ), + listInstances: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'instances', + ), + aggregateUsage: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'usages', + ), + listProducts: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'products', + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -221,61 +261,115 @@ export class LicenseManagerClient { // 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 createConfigurationResponse = protoFilesRoot.lookup( - '.google.cloud.licensemanager.v1.Configuration') as gax.protobuf.Type; + '.google.cloud.licensemanager.v1.Configuration', + ) as gax.protobuf.Type; const createConfigurationMetadata = protoFilesRoot.lookup( - '.google.cloud.licensemanager.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.licensemanager.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateConfigurationResponse = protoFilesRoot.lookup( - '.google.cloud.licensemanager.v1.Configuration') as gax.protobuf.Type; + '.google.cloud.licensemanager.v1.Configuration', + ) as gax.protobuf.Type; const updateConfigurationMetadata = protoFilesRoot.lookup( - '.google.cloud.licensemanager.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.licensemanager.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteConfigurationResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteConfigurationMetadata = protoFilesRoot.lookup( - '.google.cloud.licensemanager.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.licensemanager.v1.OperationMetadata', + ) as gax.protobuf.Type; const deactivateConfigurationResponse = protoFilesRoot.lookup( - '.google.cloud.licensemanager.v1.Configuration') as gax.protobuf.Type; + '.google.cloud.licensemanager.v1.Configuration', + ) as gax.protobuf.Type; const deactivateConfigurationMetadata = protoFilesRoot.lookup( - '.google.cloud.licensemanager.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.licensemanager.v1.OperationMetadata', + ) as gax.protobuf.Type; const reactivateConfigurationResponse = protoFilesRoot.lookup( - '.google.cloud.licensemanager.v1.Configuration') as gax.protobuf.Type; + '.google.cloud.licensemanager.v1.Configuration', + ) as gax.protobuf.Type; const reactivateConfigurationMetadata = protoFilesRoot.lookup( - '.google.cloud.licensemanager.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.licensemanager.v1.OperationMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { createConfiguration: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createConfigurationResponse.decode.bind(createConfigurationResponse), - createConfigurationMetadata.decode.bind(createConfigurationMetadata)), + createConfigurationMetadata.decode.bind(createConfigurationMetadata), + ), updateConfiguration: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateConfigurationResponse.decode.bind(updateConfigurationResponse), - updateConfigurationMetadata.decode.bind(updateConfigurationMetadata)), + updateConfigurationMetadata.decode.bind(updateConfigurationMetadata), + ), deleteConfiguration: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteConfigurationResponse.decode.bind(deleteConfigurationResponse), - deleteConfigurationMetadata.decode.bind(deleteConfigurationMetadata)), + deleteConfigurationMetadata.decode.bind(deleteConfigurationMetadata), + ), deactivateConfiguration: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - deactivateConfigurationResponse.decode.bind(deactivateConfigurationResponse), - deactivateConfigurationMetadata.decode.bind(deactivateConfigurationMetadata)), + deactivateConfigurationResponse.decode.bind( + deactivateConfigurationResponse, + ), + deactivateConfigurationMetadata.decode.bind( + deactivateConfigurationMetadata, + ), + ), reactivateConfiguration: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - reactivateConfigurationResponse.decode.bind(reactivateConfigurationResponse), - reactivateConfigurationMetadata.decode.bind(reactivateConfigurationMetadata)) + reactivateConfigurationResponse.decode.bind( + reactivateConfigurationResponse, + ), + reactivateConfigurationMetadata.decode.bind( + reactivateConfigurationMetadata, + ), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.licensemanager.v1.LicenseManager', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.licensemanager.v1.LicenseManager', + 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 @@ -306,28 +400,47 @@ export class LicenseManagerClient { // Put together the "service stub" for // google.cloud.licensemanager.v1.LicenseManager. this.licenseManagerStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.licensemanager.v1.LicenseManager') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.licensemanager.v1.LicenseManager', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.licensemanager.v1.LicenseManager, - 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 licenseManagerStubMethods = - ['listConfigurations', 'getConfiguration', 'createConfiguration', 'updateConfiguration', 'deleteConfiguration', 'listInstances', 'getInstance', 'deactivateConfiguration', 'reactivateConfiguration', 'queryConfigurationLicenseUsage', 'aggregateUsage', 'listProducts', 'getProduct']; + const licenseManagerStubMethods = [ + 'listConfigurations', + 'getConfiguration', + 'createConfiguration', + 'updateConfiguration', + 'deleteConfiguration', + 'listInstances', + 'getInstance', + 'deactivateConfiguration', + 'reactivateConfiguration', + 'queryConfigurationLicenseUsage', + 'aggregateUsage', + 'listProducts', + 'getProduct', + ]; for (const methodName of licenseManagerStubMethods) { const callPromise = this.licenseManagerStub.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] || @@ -337,7 +450,7 @@ export class LicenseManagerClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -352,8 +465,14 @@ export class LicenseManagerClient { * @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 'licensemanager.googleapis.com'; } @@ -364,8 +483,14 @@ export class LicenseManagerClient { * @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 'licensemanager.googleapis.com'; } @@ -396,9 +521,7 @@ export class LicenseManagerClient { * @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; @@ -407,8 +530,9 @@ export class LicenseManagerClient { * 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; @@ -419,1090 +543,1609 @@ export class LicenseManagerClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Gets details of a single Configuration. - * - * @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.licensemanager.v1.Configuration|Configuration}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/license_manager.get_configuration.js - * region_tag:licensemanager_v1_generated_LicenseManager_GetConfiguration_async - */ + /** + * Gets details of a single Configuration. + * + * @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.licensemanager.v1.Configuration|Configuration}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/license_manager.get_configuration.js + * region_tag:licensemanager_v1_generated_LicenseManager_GetConfiguration_async + */ getConfiguration( - request?: protos.google.cloud.licensemanager.v1.IGetConfigurationRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.licensemanager.v1.IConfiguration, - protos.google.cloud.licensemanager.v1.IGetConfigurationRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.licensemanager.v1.IGetConfigurationRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.licensemanager.v1.IConfiguration, + ( + | protos.google.cloud.licensemanager.v1.IGetConfigurationRequest + | undefined + ), + {} | undefined, + ] + >; getConfiguration( - request: protos.google.cloud.licensemanager.v1.IGetConfigurationRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.licensemanager.v1.IConfiguration, - protos.google.cloud.licensemanager.v1.IGetConfigurationRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.licensemanager.v1.IGetConfigurationRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.licensemanager.v1.IConfiguration, + | protos.google.cloud.licensemanager.v1.IGetConfigurationRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getConfiguration( - request: protos.google.cloud.licensemanager.v1.IGetConfigurationRequest, - callback: Callback< - protos.google.cloud.licensemanager.v1.IConfiguration, - protos.google.cloud.licensemanager.v1.IGetConfigurationRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.licensemanager.v1.IGetConfigurationRequest, + callback: Callback< + protos.google.cloud.licensemanager.v1.IConfiguration, + | protos.google.cloud.licensemanager.v1.IGetConfigurationRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getConfiguration( - request?: protos.google.cloud.licensemanager.v1.IGetConfigurationRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.licensemanager.v1.IConfiguration, - protos.google.cloud.licensemanager.v1.IGetConfigurationRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.licensemanager.v1.IGetConfigurationRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.licensemanager.v1.IConfiguration, - protos.google.cloud.licensemanager.v1.IGetConfigurationRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.licensemanager.v1.IConfiguration, - protos.google.cloud.licensemanager.v1.IGetConfigurationRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.licensemanager.v1.IGetConfigurationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.licensemanager.v1.IConfiguration, + | protos.google.cloud.licensemanager.v1.IGetConfigurationRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.licensemanager.v1.IConfiguration, + ( + | protos.google.cloud.licensemanager.v1.IGetConfigurationRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getConfiguration request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.licensemanager.v1.IConfiguration, - protos.google.cloud.licensemanager.v1.IGetConfigurationRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.licensemanager.v1.IConfiguration, + | protos.google.cloud.licensemanager.v1.IGetConfigurationRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getConfiguration response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getConfiguration(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.licensemanager.v1.IConfiguration, - protos.google.cloud.licensemanager.v1.IGetConfigurationRequest|undefined, - {}|undefined - ]) => { - this._log.info('getConfiguration response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getConfiguration(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.licensemanager.v1.IConfiguration, + ( + | protos.google.cloud.licensemanager.v1.IGetConfigurationRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getConfiguration response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 Instance. - * - * @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.licensemanager.v1.Instance|Instance}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/license_manager.get_instance.js - * region_tag:licensemanager_v1_generated_LicenseManager_GetInstance_async - */ + /** + * Gets details of a single Instance. + * + * @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.licensemanager.v1.Instance|Instance}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/license_manager.get_instance.js + * region_tag:licensemanager_v1_generated_LicenseManager_GetInstance_async + */ getInstance( - request?: protos.google.cloud.licensemanager.v1.IGetInstanceRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.licensemanager.v1.IInstance, - protos.google.cloud.licensemanager.v1.IGetInstanceRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.licensemanager.v1.IGetInstanceRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.licensemanager.v1.IInstance, + protos.google.cloud.licensemanager.v1.IGetInstanceRequest | undefined, + {} | undefined, + ] + >; getInstance( - request: protos.google.cloud.licensemanager.v1.IGetInstanceRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.licensemanager.v1.IInstance, - protos.google.cloud.licensemanager.v1.IGetInstanceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.licensemanager.v1.IGetInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.licensemanager.v1.IInstance, + | protos.google.cloud.licensemanager.v1.IGetInstanceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getInstance( - request: protos.google.cloud.licensemanager.v1.IGetInstanceRequest, - callback: Callback< - protos.google.cloud.licensemanager.v1.IInstance, - protos.google.cloud.licensemanager.v1.IGetInstanceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.licensemanager.v1.IGetInstanceRequest, + callback: Callback< + protos.google.cloud.licensemanager.v1.IInstance, + | protos.google.cloud.licensemanager.v1.IGetInstanceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getInstance( - request?: protos.google.cloud.licensemanager.v1.IGetInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.licensemanager.v1.IInstance, - protos.google.cloud.licensemanager.v1.IGetInstanceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.licensemanager.v1.IGetInstanceRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.licensemanager.v1.IInstance, - protos.google.cloud.licensemanager.v1.IGetInstanceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.licensemanager.v1.IInstance, - protos.google.cloud.licensemanager.v1.IGetInstanceRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.licensemanager.v1.IGetInstanceRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.licensemanager.v1.IInstance, + | protos.google.cloud.licensemanager.v1.IGetInstanceRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.licensemanager.v1.IInstance, + protos.google.cloud.licensemanager.v1.IGetInstanceRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getInstance request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.licensemanager.v1.IInstance, - protos.google.cloud.licensemanager.v1.IGetInstanceRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.licensemanager.v1.IInstance, + | protos.google.cloud.licensemanager.v1.IGetInstanceRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getInstance response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getInstance(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.licensemanager.v1.IInstance, - protos.google.cloud.licensemanager.v1.IGetInstanceRequest|undefined, - {}|undefined - ]) => { - this._log.info('getInstance response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getInstance(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.licensemanager.v1.IInstance, + protos.google.cloud.licensemanager.v1.IGetInstanceRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getInstance response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails instanceof Array + ) { + const protos = this._gaxModule.protobuf.Root.fromJSON( + jsonProtos, + ) as unknown as gax.protobuf.Type; + error.statusDetails = decodeAnyProtosInArray( + error.statusDetails, + protos, + ); } throw error; }); } -/** - * License Usage information for a Configuration. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource path of the Configuration. - * @param {google.protobuf.Timestamp} request.startTime - * Required. The start time for retrieving the usage. If not specified, we - * will use the first day of the current billing period. - * @param {google.protobuf.Timestamp} request.endTime - * Required. The end time for retrieving the usage. If not specified, we will - * use the last day of the current billing period. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.licensemanager.v1.QueryConfigurationLicenseUsageResponse|QueryConfigurationLicenseUsageResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/license_manager.query_configuration_license_usage.js - * region_tag:licensemanager_v1_generated_LicenseManager_QueryConfigurationLicenseUsage_async - */ + /** + * License Usage information for a Configuration. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource path of the Configuration. + * @param {google.protobuf.Timestamp} request.startTime + * Required. The start time for retrieving the usage. If not specified, we + * will use the first day of the current billing period. + * @param {google.protobuf.Timestamp} request.endTime + * Required. The end time for retrieving the usage. If not specified, we will + * use the last day of the current billing period. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.licensemanager.v1.QueryConfigurationLicenseUsageResponse|QueryConfigurationLicenseUsageResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/license_manager.query_configuration_license_usage.js + * region_tag:licensemanager_v1_generated_LicenseManager_QueryConfigurationLicenseUsage_async + */ queryConfigurationLicenseUsage( - request?: protos.google.cloud.licensemanager.v1.IQueryConfigurationLicenseUsageRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.licensemanager.v1.IQueryConfigurationLicenseUsageResponse, - protos.google.cloud.licensemanager.v1.IQueryConfigurationLicenseUsageRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.licensemanager.v1.IQueryConfigurationLicenseUsageRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.licensemanager.v1.IQueryConfigurationLicenseUsageResponse, + ( + | protos.google.cloud.licensemanager.v1.IQueryConfigurationLicenseUsageRequest + | undefined + ), + {} | undefined, + ] + >; queryConfigurationLicenseUsage( - request: protos.google.cloud.licensemanager.v1.IQueryConfigurationLicenseUsageRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.licensemanager.v1.IQueryConfigurationLicenseUsageResponse, - protos.google.cloud.licensemanager.v1.IQueryConfigurationLicenseUsageRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.licensemanager.v1.IQueryConfigurationLicenseUsageRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.licensemanager.v1.IQueryConfigurationLicenseUsageResponse, + | protos.google.cloud.licensemanager.v1.IQueryConfigurationLicenseUsageRequest + | null + | undefined, + {} | null | undefined + >, + ): void; queryConfigurationLicenseUsage( - request: protos.google.cloud.licensemanager.v1.IQueryConfigurationLicenseUsageRequest, - callback: Callback< - protos.google.cloud.licensemanager.v1.IQueryConfigurationLicenseUsageResponse, - protos.google.cloud.licensemanager.v1.IQueryConfigurationLicenseUsageRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.licensemanager.v1.IQueryConfigurationLicenseUsageRequest, + callback: Callback< + protos.google.cloud.licensemanager.v1.IQueryConfigurationLicenseUsageResponse, + | protos.google.cloud.licensemanager.v1.IQueryConfigurationLicenseUsageRequest + | null + | undefined, + {} | null | undefined + >, + ): void; queryConfigurationLicenseUsage( - request?: protos.google.cloud.licensemanager.v1.IQueryConfigurationLicenseUsageRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.licensemanager.v1.IQueryConfigurationLicenseUsageResponse, - protos.google.cloud.licensemanager.v1.IQueryConfigurationLicenseUsageRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.licensemanager.v1.IQueryConfigurationLicenseUsageRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.licensemanager.v1.IQueryConfigurationLicenseUsageResponse, - protos.google.cloud.licensemanager.v1.IQueryConfigurationLicenseUsageRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.licensemanager.v1.IQueryConfigurationLicenseUsageResponse, - protos.google.cloud.licensemanager.v1.IQueryConfigurationLicenseUsageRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.licensemanager.v1.IQueryConfigurationLicenseUsageRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.licensemanager.v1.IQueryConfigurationLicenseUsageResponse, + | protos.google.cloud.licensemanager.v1.IQueryConfigurationLicenseUsageRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.licensemanager.v1.IQueryConfigurationLicenseUsageResponse, + ( + | protos.google.cloud.licensemanager.v1.IQueryConfigurationLicenseUsageRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('queryConfigurationLicenseUsage request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.licensemanager.v1.IQueryConfigurationLicenseUsageResponse, - protos.google.cloud.licensemanager.v1.IQueryConfigurationLicenseUsageRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.licensemanager.v1.IQueryConfigurationLicenseUsageResponse, + | protos.google.cloud.licensemanager.v1.IQueryConfigurationLicenseUsageRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { - this._log.info('queryConfigurationLicenseUsage response %j', response); + this._log.info( + 'queryConfigurationLicenseUsage response %j', + response, + ); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.queryConfigurationLicenseUsage(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.licensemanager.v1.IQueryConfigurationLicenseUsageResponse, - protos.google.cloud.licensemanager.v1.IQueryConfigurationLicenseUsageRequest|undefined, - {}|undefined - ]) => { - this._log.info('queryConfigurationLicenseUsage response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .queryConfigurationLicenseUsage(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.licensemanager.v1.IQueryConfigurationLicenseUsageResponse, + ( + | protos.google.cloud.licensemanager.v1.IQueryConfigurationLicenseUsageRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info( + 'queryConfigurationLicenseUsage response %j', + response, + ); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 Product. - * - * @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.licensemanager.v1.Product|Product}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1/license_manager.get_product.js - * region_tag:licensemanager_v1_generated_LicenseManager_GetProduct_async - */ + /** + * Gets details of a single Product. + * + * @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.licensemanager.v1.Product|Product}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1/license_manager.get_product.js + * region_tag:licensemanager_v1_generated_LicenseManager_GetProduct_async + */ getProduct( - request?: protos.google.cloud.licensemanager.v1.IGetProductRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.licensemanager.v1.IProduct, - protos.google.cloud.licensemanager.v1.IGetProductRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.licensemanager.v1.IGetProductRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.licensemanager.v1.IProduct, + protos.google.cloud.licensemanager.v1.IGetProductRequest | undefined, + {} | undefined, + ] + >; getProduct( - request: protos.google.cloud.licensemanager.v1.IGetProductRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.licensemanager.v1.IProduct, - protos.google.cloud.licensemanager.v1.IGetProductRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.licensemanager.v1.IGetProductRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.licensemanager.v1.IProduct, + | protos.google.cloud.licensemanager.v1.IGetProductRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getProduct( - request: protos.google.cloud.licensemanager.v1.IGetProductRequest, - callback: Callback< - protos.google.cloud.licensemanager.v1.IProduct, - protos.google.cloud.licensemanager.v1.IGetProductRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.licensemanager.v1.IGetProductRequest, + callback: Callback< + protos.google.cloud.licensemanager.v1.IProduct, + | protos.google.cloud.licensemanager.v1.IGetProductRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getProduct( - request?: protos.google.cloud.licensemanager.v1.IGetProductRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.licensemanager.v1.IProduct, - protos.google.cloud.licensemanager.v1.IGetProductRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.licensemanager.v1.IGetProductRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.licensemanager.v1.IProduct, - protos.google.cloud.licensemanager.v1.IGetProductRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.licensemanager.v1.IProduct, - protos.google.cloud.licensemanager.v1.IGetProductRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.licensemanager.v1.IGetProductRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.licensemanager.v1.IProduct, + | protos.google.cloud.licensemanager.v1.IGetProductRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.licensemanager.v1.IProduct, + protos.google.cloud.licensemanager.v1.IGetProductRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getProduct request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.licensemanager.v1.IProduct, - protos.google.cloud.licensemanager.v1.IGetProductRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.licensemanager.v1.IProduct, + | protos.google.cloud.licensemanager.v1.IGetProductRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getProduct response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getProduct(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.licensemanager.v1.IProduct, - protos.google.cloud.licensemanager.v1.IGetProductRequest|undefined, - {}|undefined - ]) => { - this._log.info('getProduct response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getProduct(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.licensemanager.v1.IProduct, + protos.google.cloud.licensemanager.v1.IGetProductRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getProduct response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 Configuration in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Value for parent. - * @param {string} request.configurationId - * Required. Id of the requesting object - * @param {google.cloud.licensemanager.v1.Configuration} request.configuration - * Required. The resource being created - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and the - * request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/license_manager.create_configuration.js - * region_tag:licensemanager_v1_generated_LicenseManager_CreateConfiguration_async - */ + /** + * Creates a new Configuration in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Value for parent. + * @param {string} request.configurationId + * Required. Id of the requesting object + * @param {google.cloud.licensemanager.v1.Configuration} request.configuration + * Required. The resource being created + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and the + * request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/license_manager.create_configuration.js + * region_tag:licensemanager_v1_generated_LicenseManager_CreateConfiguration_async + */ createConfiguration( - request?: protos.google.cloud.licensemanager.v1.ICreateConfigurationRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.licensemanager.v1.ICreateConfigurationRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.licensemanager.v1.IConfiguration, + protos.google.cloud.licensemanager.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createConfiguration( - request: protos.google.cloud.licensemanager.v1.ICreateConfigurationRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.licensemanager.v1.ICreateConfigurationRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.licensemanager.v1.IConfiguration, + protos.google.cloud.licensemanager.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createConfiguration( - request: protos.google.cloud.licensemanager.v1.ICreateConfigurationRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.licensemanager.v1.ICreateConfigurationRequest, + callback: Callback< + LROperation< + protos.google.cloud.licensemanager.v1.IConfiguration, + protos.google.cloud.licensemanager.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createConfiguration( - request?: protos.google.cloud.licensemanager.v1.ICreateConfigurationRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.licensemanager.v1.ICreateConfigurationRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.licensemanager.v1.IConfiguration, + protos.google.cloud.licensemanager.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.licensemanager.v1.IConfiguration, + protos.google.cloud.licensemanager.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.licensemanager.v1.IConfiguration, + protos.google.cloud.licensemanager.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.licensemanager.v1.IConfiguration, + protos.google.cloud.licensemanager.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createConfiguration response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createConfiguration request %j', request); - return this.innerApiCalls.createConfiguration(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createConfiguration response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createConfiguration(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.licensemanager.v1.IConfiguration, + protos.google.cloud.licensemanager.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createConfiguration response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createConfiguration()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/license_manager.create_configuration.js - * region_tag:licensemanager_v1_generated_LicenseManager_CreateConfiguration_async - */ - async checkCreateConfigurationProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createConfiguration()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/license_manager.create_configuration.js + * region_tag:licensemanager_v1_generated_LicenseManager_CreateConfiguration_async + */ + async checkCreateConfigurationProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.licensemanager.v1.Configuration, + protos.google.cloud.licensemanager.v1.OperationMetadata + > + > { this._log.info('createConfiguration long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createConfiguration, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createConfiguration, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.licensemanager.v1.Configuration, + protos.google.cloud.licensemanager.v1.OperationMetadata + >; } -/** - * Updates the parameters of a single Configuration. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.protobuf.FieldMask} [request.updateMask] - * Optional. Field mask is used to specify the fields to be overwritten in the - * Configuration 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.licensemanager.v1.Configuration} request.configuration - * Required. The resource being updated - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes since the first request. - * - * For example, consider a situation where you make an initial request and the - * request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/license_manager.update_configuration.js - * region_tag:licensemanager_v1_generated_LicenseManager_UpdateConfiguration_async - */ + /** + * Updates the parameters of a single Configuration. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.protobuf.FieldMask} [request.updateMask] + * Optional. Field mask is used to specify the fields to be overwritten in the + * Configuration 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.licensemanager.v1.Configuration} request.configuration + * Required. The resource being updated + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes since the first request. + * + * For example, consider a situation where you make an initial request and the + * request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/license_manager.update_configuration.js + * region_tag:licensemanager_v1_generated_LicenseManager_UpdateConfiguration_async + */ updateConfiguration( - request?: protos.google.cloud.licensemanager.v1.IUpdateConfigurationRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.licensemanager.v1.IUpdateConfigurationRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.licensemanager.v1.IConfiguration, + protos.google.cloud.licensemanager.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateConfiguration( - request: protos.google.cloud.licensemanager.v1.IUpdateConfigurationRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.licensemanager.v1.IUpdateConfigurationRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.licensemanager.v1.IConfiguration, + protos.google.cloud.licensemanager.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateConfiguration( - request: protos.google.cloud.licensemanager.v1.IUpdateConfigurationRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.licensemanager.v1.IUpdateConfigurationRequest, + callback: Callback< + LROperation< + protos.google.cloud.licensemanager.v1.IConfiguration, + protos.google.cloud.licensemanager.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateConfiguration( - request?: protos.google.cloud.licensemanager.v1.IUpdateConfigurationRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.licensemanager.v1.IUpdateConfigurationRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.licensemanager.v1.IConfiguration, + protos.google.cloud.licensemanager.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.licensemanager.v1.IConfiguration, + protos.google.cloud.licensemanager.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.licensemanager.v1.IConfiguration, + protos.google.cloud.licensemanager.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({ - 'configuration.name': request.configuration!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'configuration.name': request.configuration!.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.licensemanager.v1.IConfiguration, + protos.google.cloud.licensemanager.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateConfiguration response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateConfiguration request %j', request); - return this.innerApiCalls.updateConfiguration(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateConfiguration response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateConfiguration(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.licensemanager.v1.IConfiguration, + protos.google.cloud.licensemanager.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateConfiguration response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateConfiguration()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/license_manager.update_configuration.js - * region_tag:licensemanager_v1_generated_LicenseManager_UpdateConfiguration_async - */ - async checkUpdateConfigurationProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateConfiguration()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/license_manager.update_configuration.js + * region_tag:licensemanager_v1_generated_LicenseManager_UpdateConfiguration_async + */ + async checkUpdateConfigurationProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.licensemanager.v1.Configuration, + protos.google.cloud.licensemanager.v1.OperationMetadata + > + > { this._log.info('updateConfiguration long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.updateConfiguration, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateConfiguration, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.licensemanager.v1.Configuration, + protos.google.cloud.licensemanager.v1.OperationMetadata + >; } -/** - * Deletes a single Configuration. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the resource - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and the - * request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/license_manager.delete_configuration.js - * region_tag:licensemanager_v1_generated_LicenseManager_DeleteConfiguration_async - */ + /** + * Deletes a single Configuration. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the resource + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and the + * request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/license_manager.delete_configuration.js + * region_tag:licensemanager_v1_generated_LicenseManager_DeleteConfiguration_async + */ deleteConfiguration( - request?: protos.google.cloud.licensemanager.v1.IDeleteConfigurationRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.licensemanager.v1.IDeleteConfigurationRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.licensemanager.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteConfiguration( - request: protos.google.cloud.licensemanager.v1.IDeleteConfigurationRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.licensemanager.v1.IDeleteConfigurationRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.licensemanager.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteConfiguration( - request: protos.google.cloud.licensemanager.v1.IDeleteConfigurationRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.licensemanager.v1.IDeleteConfigurationRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.licensemanager.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteConfiguration( - request?: protos.google.cloud.licensemanager.v1.IDeleteConfigurationRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.licensemanager.v1.IDeleteConfigurationRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.licensemanager.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.licensemanager.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.licensemanager.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.licensemanager.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteConfiguration response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteConfiguration request %j', request); - return this.innerApiCalls.deleteConfiguration(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteConfiguration response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteConfiguration(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.licensemanager.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteConfiguration response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteConfiguration()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/license_manager.delete_configuration.js - * region_tag:licensemanager_v1_generated_LicenseManager_DeleteConfiguration_async - */ - async checkDeleteConfigurationProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteConfiguration()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/license_manager.delete_configuration.js + * region_tag:licensemanager_v1_generated_LicenseManager_DeleteConfiguration_async + */ + async checkDeleteConfigurationProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.licensemanager.v1.OperationMetadata + > + > { this._log.info('deleteConfiguration long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteConfiguration, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteConfiguration, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.licensemanager.v1.OperationMetadata + >; } -/** - * Deactivates the given configuration. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the resource. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/license_manager.deactivate_configuration.js - * region_tag:licensemanager_v1_generated_LicenseManager_DeactivateConfiguration_async - */ + /** + * Deactivates the given configuration. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the resource. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/license_manager.deactivate_configuration.js + * region_tag:licensemanager_v1_generated_LicenseManager_DeactivateConfiguration_async + */ deactivateConfiguration( - request?: protos.google.cloud.licensemanager.v1.IDeactivateConfigurationRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.licensemanager.v1.IDeactivateConfigurationRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.licensemanager.v1.IConfiguration, + protos.google.cloud.licensemanager.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deactivateConfiguration( - request: protos.google.cloud.licensemanager.v1.IDeactivateConfigurationRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.licensemanager.v1.IDeactivateConfigurationRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.licensemanager.v1.IConfiguration, + protos.google.cloud.licensemanager.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deactivateConfiguration( - request: protos.google.cloud.licensemanager.v1.IDeactivateConfigurationRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.licensemanager.v1.IDeactivateConfigurationRequest, + callback: Callback< + LROperation< + protos.google.cloud.licensemanager.v1.IConfiguration, + protos.google.cloud.licensemanager.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deactivateConfiguration( - request?: protos.google.cloud.licensemanager.v1.IDeactivateConfigurationRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.licensemanager.v1.IDeactivateConfigurationRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.licensemanager.v1.IConfiguration, + protos.google.cloud.licensemanager.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.licensemanager.v1.IConfiguration, + protos.google.cloud.licensemanager.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.licensemanager.v1.IConfiguration, + protos.google.cloud.licensemanager.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.licensemanager.v1.IConfiguration, + protos.google.cloud.licensemanager.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deactivateConfiguration response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deactivateConfiguration request %j', request); - return this.innerApiCalls.deactivateConfiguration(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deactivateConfiguration response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deactivateConfiguration(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.licensemanager.v1.IConfiguration, + protos.google.cloud.licensemanager.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deactivateConfiguration response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deactivateConfiguration()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/license_manager.deactivate_configuration.js - * region_tag:licensemanager_v1_generated_LicenseManager_DeactivateConfiguration_async - */ - async checkDeactivateConfigurationProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deactivateConfiguration()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/license_manager.deactivate_configuration.js + * region_tag:licensemanager_v1_generated_LicenseManager_DeactivateConfiguration_async + */ + async checkDeactivateConfigurationProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.licensemanager.v1.Configuration, + protos.google.cloud.licensemanager.v1.OperationMetadata + > + > { this._log.info('deactivateConfiguration long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deactivateConfiguration, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deactivateConfiguration, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.licensemanager.v1.Configuration, + protos.google.cloud.licensemanager.v1.OperationMetadata + >; } -/** - * Reactivates the given configuration. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the resource. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID so that if you must retry your request, the server will know to - * ignore the request if it has already been completed. The server will - * guarantee that for at least 60 minutes after the first request. - * - * For example, consider a situation where you make an initial request and - * the request times out. If you make the request again with the same request - * ID, the server can check if original operation with the same request ID - * was received, and if so, will ignore the second request. This prevents - * clients from accidentally creating duplicate commitments. - * - * The request ID must be a valid UUID with the exception that zero UUID is - * not supported (00000000-0000-0000-0000-000000000000). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/license_manager.reactivate_configuration.js - * region_tag:licensemanager_v1_generated_LicenseManager_ReactivateConfiguration_async - */ + /** + * Reactivates the given configuration. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the resource. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID so that if you must retry your request, the server will know to + * ignore the request if it has already been completed. The server will + * guarantee that for at least 60 minutes after the first request. + * + * For example, consider a situation where you make an initial request and + * the request times out. If you make the request again with the same request + * ID, the server can check if original operation with the same request ID + * was received, and if so, will ignore the second request. This prevents + * clients from accidentally creating duplicate commitments. + * + * The request ID must be a valid UUID with the exception that zero UUID is + * not supported (00000000-0000-0000-0000-000000000000). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/license_manager.reactivate_configuration.js + * region_tag:licensemanager_v1_generated_LicenseManager_ReactivateConfiguration_async + */ reactivateConfiguration( - request?: protos.google.cloud.licensemanager.v1.IReactivateConfigurationRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.licensemanager.v1.IReactivateConfigurationRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.licensemanager.v1.IConfiguration, + protos.google.cloud.licensemanager.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; reactivateConfiguration( - request: protos.google.cloud.licensemanager.v1.IReactivateConfigurationRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.licensemanager.v1.IReactivateConfigurationRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.licensemanager.v1.IConfiguration, + protos.google.cloud.licensemanager.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; reactivateConfiguration( - request: protos.google.cloud.licensemanager.v1.IReactivateConfigurationRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.licensemanager.v1.IReactivateConfigurationRequest, + callback: Callback< + LROperation< + protos.google.cloud.licensemanager.v1.IConfiguration, + protos.google.cloud.licensemanager.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; reactivateConfiguration( - request?: protos.google.cloud.licensemanager.v1.IReactivateConfigurationRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.licensemanager.v1.IReactivateConfigurationRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.licensemanager.v1.IConfiguration, + protos.google.cloud.licensemanager.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.licensemanager.v1.IConfiguration, + protos.google.cloud.licensemanager.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.licensemanager.v1.IConfiguration, + protos.google.cloud.licensemanager.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.licensemanager.v1.IConfiguration, + protos.google.cloud.licensemanager.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('reactivateConfiguration response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('reactivateConfiguration request %j', request); - return this.innerApiCalls.reactivateConfiguration(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('reactivateConfiguration response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .reactivateConfiguration(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.licensemanager.v1.IConfiguration, + protos.google.cloud.licensemanager.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('reactivateConfiguration response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `reactivateConfiguration()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/license_manager.reactivate_configuration.js - * region_tag:licensemanager_v1_generated_LicenseManager_ReactivateConfiguration_async - */ - async checkReactivateConfigurationProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `reactivateConfiguration()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/license_manager.reactivate_configuration.js + * region_tag:licensemanager_v1_generated_LicenseManager_ReactivateConfiguration_async + */ + async checkReactivateConfigurationProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.licensemanager.v1.Configuration, + protos.google.cloud.licensemanager.v1.OperationMetadata + > + > { this._log.info('reactivateConfiguration long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.reactivateConfiguration, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.reactivateConfiguration, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.licensemanager.v1.Configuration, + protos.google.cloud.licensemanager.v1.OperationMetadata + >; } - /** - * Lists Configurations in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for ListConfigurationsRequest - * @param {number} [request.pageSize] - * Optional. Requested page size. Server may return fewer items than - * requested. If unspecified, server will pick an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. Filtering results - * @param {string} [request.orderBy] - * Optional. Hint for how to order the results - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link protos.google.cloud.licensemanager.v1.Configuration|Configuration}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listConfigurationsAsync()` - * method described below for async iteration which you can stop as 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 Configurations in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for ListConfigurationsRequest + * @param {number} [request.pageSize] + * Optional. Requested page size. Server may return fewer items than + * requested. If unspecified, server will pick an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. Filtering results + * @param {string} [request.orderBy] + * Optional. Hint for how to order the results + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.licensemanager.v1.Configuration|Configuration}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listConfigurationsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listConfigurations( - request?: protos.google.cloud.licensemanager.v1.IListConfigurationsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.licensemanager.v1.IConfiguration[], - protos.google.cloud.licensemanager.v1.IListConfigurationsRequest|null, - protos.google.cloud.licensemanager.v1.IListConfigurationsResponse - ]>; + request?: protos.google.cloud.licensemanager.v1.IListConfigurationsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.licensemanager.v1.IConfiguration[], + protos.google.cloud.licensemanager.v1.IListConfigurationsRequest | null, + protos.google.cloud.licensemanager.v1.IListConfigurationsResponse, + ] + >; listConfigurations( - request: protos.google.cloud.licensemanager.v1.IListConfigurationsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.licensemanager.v1.IListConfigurationsRequest, - protos.google.cloud.licensemanager.v1.IListConfigurationsResponse|null|undefined, - protos.google.cloud.licensemanager.v1.IConfiguration>): void; + request: protos.google.cloud.licensemanager.v1.IListConfigurationsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.licensemanager.v1.IListConfigurationsRequest, + | protos.google.cloud.licensemanager.v1.IListConfigurationsResponse + | null + | undefined, + protos.google.cloud.licensemanager.v1.IConfiguration + >, + ): void; listConfigurations( - request: protos.google.cloud.licensemanager.v1.IListConfigurationsRequest, - callback: PaginationCallback< - protos.google.cloud.licensemanager.v1.IListConfigurationsRequest, - protos.google.cloud.licensemanager.v1.IListConfigurationsResponse|null|undefined, - protos.google.cloud.licensemanager.v1.IConfiguration>): void; + request: protos.google.cloud.licensemanager.v1.IListConfigurationsRequest, + callback: PaginationCallback< + protos.google.cloud.licensemanager.v1.IListConfigurationsRequest, + | protos.google.cloud.licensemanager.v1.IListConfigurationsResponse + | null + | undefined, + protos.google.cloud.licensemanager.v1.IConfiguration + >, + ): void; listConfigurations( - request?: protos.google.cloud.licensemanager.v1.IListConfigurationsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.licensemanager.v1.IListConfigurationsRequest, - protos.google.cloud.licensemanager.v1.IListConfigurationsResponse|null|undefined, - protos.google.cloud.licensemanager.v1.IConfiguration>, - callback?: PaginationCallback< + request?: protos.google.cloud.licensemanager.v1.IListConfigurationsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.licensemanager.v1.IListConfigurationsRequest, - protos.google.cloud.licensemanager.v1.IListConfigurationsResponse|null|undefined, - protos.google.cloud.licensemanager.v1.IConfiguration>): - Promise<[ - protos.google.cloud.licensemanager.v1.IConfiguration[], - protos.google.cloud.licensemanager.v1.IListConfigurationsRequest|null, - protos.google.cloud.licensemanager.v1.IListConfigurationsResponse - ]>|void { + | protos.google.cloud.licensemanager.v1.IListConfigurationsResponse + | null + | undefined, + protos.google.cloud.licensemanager.v1.IConfiguration + >, + callback?: PaginationCallback< + protos.google.cloud.licensemanager.v1.IListConfigurationsRequest, + | protos.google.cloud.licensemanager.v1.IListConfigurationsResponse + | null + | undefined, + protos.google.cloud.licensemanager.v1.IConfiguration + >, + ): Promise< + [ + protos.google.cloud.licensemanager.v1.IConfiguration[], + protos.google.cloud.licensemanager.v1.IListConfigurationsRequest | null, + protos.google.cloud.licensemanager.v1.IListConfigurationsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-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.licensemanager.v1.IListConfigurationsRequest, - protos.google.cloud.licensemanager.v1.IListConfigurationsResponse|null|undefined, - protos.google.cloud.licensemanager.v1.IConfiguration>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.licensemanager.v1.IListConfigurationsRequest, + | protos.google.cloud.licensemanager.v1.IListConfigurationsResponse + | null + | undefined, + protos.google.cloud.licensemanager.v1.IConfiguration + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listConfigurations values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1511,204 +2154,233 @@ export class LicenseManagerClient { this._log.info('listConfigurations request %j', request); return this.innerApiCalls .listConfigurations(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.licensemanager.v1.IConfiguration[], - protos.google.cloud.licensemanager.v1.IListConfigurationsRequest|null, - protos.google.cloud.licensemanager.v1.IListConfigurationsResponse - ]) => { - this._log.info('listConfigurations values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.licensemanager.v1.IConfiguration[], + protos.google.cloud.licensemanager.v1.IListConfigurationsRequest | null, + protos.google.cloud.licensemanager.v1.IListConfigurationsResponse, + ]) => { + this._log.info('listConfigurations values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listConfigurations`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for ListConfigurationsRequest - * @param {number} [request.pageSize] - * Optional. Requested page size. Server may return fewer items than - * requested. If unspecified, server will pick an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. Filtering results - * @param {string} [request.orderBy] - * Optional. Hint for how to order the results - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.licensemanager.v1.Configuration|Configuration} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listConfigurationsAsync()` - * method described below for async iteration which you can stop as 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 `listConfigurations`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for ListConfigurationsRequest + * @param {number} [request.pageSize] + * Optional. Requested page size. Server may return fewer items than + * requested. If unspecified, server will pick an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. Filtering results + * @param {string} [request.orderBy] + * Optional. Hint for how to order the results + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.licensemanager.v1.Configuration|Configuration} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listConfigurationsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listConfigurationsStream( - request?: protos.google.cloud.licensemanager.v1.IListConfigurationsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.licensemanager.v1.IListConfigurationsRequest, + 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['listConfigurations']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listConfigurations stream %j', request); return this.descriptors.page.listConfigurations.createStream( this.innerApiCalls.listConfigurations as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listConfigurations`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used 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 ListConfigurationsRequest - * @param {number} [request.pageSize] - * Optional. Requested page size. Server may return fewer items than - * requested. If unspecified, server will pick an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. Filtering results - * @param {string} [request.orderBy] - * Optional. Hint for how to order the results - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.licensemanager.v1.Configuration|Configuration}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@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/license_manager.list_configurations.js - * region_tag:licensemanager_v1_generated_LicenseManager_ListConfigurations_async - */ + /** + * Equivalent to `listConfigurations`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used 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 ListConfigurationsRequest + * @param {number} [request.pageSize] + * Optional. Requested page size. Server may return fewer items than + * requested. If unspecified, server will pick an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. Filtering results + * @param {string} [request.orderBy] + * Optional. Hint for how to order the results + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.licensemanager.v1.Configuration|Configuration}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@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/license_manager.list_configurations.js + * region_tag:licensemanager_v1_generated_LicenseManager_ListConfigurations_async + */ listConfigurationsAsync( - request?: protos.google.cloud.licensemanager.v1.IListConfigurationsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.licensemanager.v1.IListConfigurationsRequest, + 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['listConfigurations']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listConfigurations iterate %j', request); return this.descriptors.page.listConfigurations.asyncIterate( this.innerApiCalls['listConfigurations'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists Instances in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for ListInstancesRequest - * @param {number} [request.pageSize] - * Optional. Requested page size. Server may return fewer items than - * requested. If unspecified, server will pick an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. Filtering results - * @param {string} [request.orderBy] - * Optional. Hint for how to order the results - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link protos.google.cloud.licensemanager.v1.Instance|Instance}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listInstancesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Lists Instances in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for ListInstancesRequest + * @param {number} [request.pageSize] + * Optional. Requested page size. Server may return fewer items than + * requested. If unspecified, server will pick an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. Filtering results + * @param {string} [request.orderBy] + * Optional. Hint for how to order the results + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.licensemanager.v1.Instance|Instance}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listInstancesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listInstances( - request?: protos.google.cloud.licensemanager.v1.IListInstancesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.licensemanager.v1.IInstance[], - protos.google.cloud.licensemanager.v1.IListInstancesRequest|null, - protos.google.cloud.licensemanager.v1.IListInstancesResponse - ]>; + request?: protos.google.cloud.licensemanager.v1.IListInstancesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.licensemanager.v1.IInstance[], + protos.google.cloud.licensemanager.v1.IListInstancesRequest | null, + protos.google.cloud.licensemanager.v1.IListInstancesResponse, + ] + >; listInstances( - request: protos.google.cloud.licensemanager.v1.IListInstancesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.licensemanager.v1.IListInstancesRequest, - protos.google.cloud.licensemanager.v1.IListInstancesResponse|null|undefined, - protos.google.cloud.licensemanager.v1.IInstance>): void; + request: protos.google.cloud.licensemanager.v1.IListInstancesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.licensemanager.v1.IListInstancesRequest, + | protos.google.cloud.licensemanager.v1.IListInstancesResponse + | null + | undefined, + protos.google.cloud.licensemanager.v1.IInstance + >, + ): void; listInstances( - request: protos.google.cloud.licensemanager.v1.IListInstancesRequest, - callback: PaginationCallback< - protos.google.cloud.licensemanager.v1.IListInstancesRequest, - protos.google.cloud.licensemanager.v1.IListInstancesResponse|null|undefined, - protos.google.cloud.licensemanager.v1.IInstance>): void; + request: protos.google.cloud.licensemanager.v1.IListInstancesRequest, + callback: PaginationCallback< + protos.google.cloud.licensemanager.v1.IListInstancesRequest, + | protos.google.cloud.licensemanager.v1.IListInstancesResponse + | null + | undefined, + protos.google.cloud.licensemanager.v1.IInstance + >, + ): void; listInstances( - request?: protos.google.cloud.licensemanager.v1.IListInstancesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.licensemanager.v1.IListInstancesRequest, - protos.google.cloud.licensemanager.v1.IListInstancesResponse|null|undefined, - protos.google.cloud.licensemanager.v1.IInstance>, - callback?: PaginationCallback< + request?: protos.google.cloud.licensemanager.v1.IListInstancesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.licensemanager.v1.IListInstancesRequest, - protos.google.cloud.licensemanager.v1.IListInstancesResponse|null|undefined, - protos.google.cloud.licensemanager.v1.IInstance>): - Promise<[ - protos.google.cloud.licensemanager.v1.IInstance[], - protos.google.cloud.licensemanager.v1.IListInstancesRequest|null, - protos.google.cloud.licensemanager.v1.IListInstancesResponse - ]>|void { + | protos.google.cloud.licensemanager.v1.IListInstancesResponse + | null + | undefined, + protos.google.cloud.licensemanager.v1.IInstance + >, + callback?: PaginationCallback< + protos.google.cloud.licensemanager.v1.IListInstancesRequest, + | protos.google.cloud.licensemanager.v1.IListInstancesResponse + | null + | undefined, + protos.google.cloud.licensemanager.v1.IInstance + >, + ): Promise< + [ + protos.google.cloud.licensemanager.v1.IInstance[], + protos.google.cloud.licensemanager.v1.IListInstancesRequest | null, + protos.google.cloud.licensemanager.v1.IListInstancesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.licensemanager.v1.IListInstancesRequest, - protos.google.cloud.licensemanager.v1.IListInstancesResponse|null|undefined, - protos.google.cloud.licensemanager.v1.IInstance>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.licensemanager.v1.IListInstancesRequest, + | protos.google.cloud.licensemanager.v1.IListInstancesResponse + | null + | undefined, + protos.google.cloud.licensemanager.v1.IInstance + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listInstances values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1717,210 +2389,239 @@ export class LicenseManagerClient { this._log.info('listInstances request %j', request); return this.innerApiCalls .listInstances(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.licensemanager.v1.IInstance[], - protos.google.cloud.licensemanager.v1.IListInstancesRequest|null, - protos.google.cloud.licensemanager.v1.IListInstancesResponse - ]) => { - this._log.info('listInstances values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.licensemanager.v1.IInstance[], + protos.google.cloud.licensemanager.v1.IListInstancesRequest | null, + protos.google.cloud.licensemanager.v1.IListInstancesResponse, + ]) => { + this._log.info('listInstances values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listInstances`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for ListInstancesRequest - * @param {number} [request.pageSize] - * Optional. Requested page size. Server may return fewer items than - * requested. If unspecified, server will pick an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. Filtering results - * @param {string} [request.orderBy] - * Optional. Hint for how to order the results - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.licensemanager.v1.Instance|Instance} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listInstancesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Equivalent to `listInstances`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for ListInstancesRequest + * @param {number} [request.pageSize] + * Optional. Requested page size. Server may return fewer items than + * requested. If unspecified, server will pick an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. Filtering results + * @param {string} [request.orderBy] + * Optional. Hint for how to order the results + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.licensemanager.v1.Instance|Instance} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listInstancesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listInstancesStream( - request?: protos.google.cloud.licensemanager.v1.IListInstancesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.licensemanager.v1.IListInstancesRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listInstances']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listInstances stream %j', request); return this.descriptors.page.listInstances.createStream( this.innerApiCalls.listInstances as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listInstances`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for ListInstancesRequest - * @param {number} [request.pageSize] - * Optional. Requested page size. Server may return fewer items than - * requested. If unspecified, server will pick an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. Filtering results - * @param {string} [request.orderBy] - * Optional. Hint for how to order the results - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.licensemanager.v1.Instance|Instance}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/license_manager.list_instances.js - * region_tag:licensemanager_v1_generated_LicenseManager_ListInstances_async - */ + /** + * Equivalent to `listInstances`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for ListInstancesRequest + * @param {number} [request.pageSize] + * Optional. Requested page size. Server may return fewer items than + * requested. If unspecified, server will pick an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. Filtering results + * @param {string} [request.orderBy] + * Optional. Hint for how to order the results + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.licensemanager.v1.Instance|Instance}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/license_manager.list_instances.js + * region_tag:licensemanager_v1_generated_LicenseManager_ListInstances_async + */ listInstancesAsync( - request?: protos.google.cloud.licensemanager.v1.IListInstancesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.licensemanager.v1.IListInstancesRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); const defaultCallSettings = this._defaults['listInstances']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listInstances iterate %j', request); return this.descriptors.page.listInstances.asyncIterate( this.innerApiCalls['listInstances'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Aggregates Usage per Instance for a Configuration. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Parent value for AggregateUsageRequest - * @param {number} [request.pageSize] - * Optional. Requested page size. Server may return fewer items than - * requested. If unspecified, server will pick an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. Filtering results - * @param {string} [request.orderBy] - * Optional. Hint for how to order the results - * @param {google.protobuf.Timestamp} request.startTime - * Required. Licenses are purchased per month - so usage track needs start - * time of a month. - * @param {google.protobuf.Timestamp} request.endTime - * Required. Usage track is always for a month. This parameter is for the end - * time of the month. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link protos.google.cloud.licensemanager.v1.Usage|Usage}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `aggregateUsageAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Aggregates Usage per Instance for a Configuration. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Parent value for AggregateUsageRequest + * @param {number} [request.pageSize] + * Optional. Requested page size. Server may return fewer items than + * requested. If unspecified, server will pick an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. Filtering results + * @param {string} [request.orderBy] + * Optional. Hint for how to order the results + * @param {google.protobuf.Timestamp} request.startTime + * Required. Licenses are purchased per month - so usage track needs start + * time of a month. + * @param {google.protobuf.Timestamp} request.endTime + * Required. Usage track is always for a month. This parameter is for the end + * time of the month. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.licensemanager.v1.Usage|Usage}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `aggregateUsageAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ aggregateUsage( - request?: protos.google.cloud.licensemanager.v1.IAggregateUsageRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.licensemanager.v1.IUsage[], - protos.google.cloud.licensemanager.v1.IAggregateUsageRequest|null, - protos.google.cloud.licensemanager.v1.IAggregateUsageResponse - ]>; + request?: protos.google.cloud.licensemanager.v1.IAggregateUsageRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.licensemanager.v1.IUsage[], + protos.google.cloud.licensemanager.v1.IAggregateUsageRequest | null, + protos.google.cloud.licensemanager.v1.IAggregateUsageResponse, + ] + >; aggregateUsage( - request: protos.google.cloud.licensemanager.v1.IAggregateUsageRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.licensemanager.v1.IAggregateUsageRequest, - protos.google.cloud.licensemanager.v1.IAggregateUsageResponse|null|undefined, - protos.google.cloud.licensemanager.v1.IUsage>): void; + request: protos.google.cloud.licensemanager.v1.IAggregateUsageRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.licensemanager.v1.IAggregateUsageRequest, + | protos.google.cloud.licensemanager.v1.IAggregateUsageResponse + | null + | undefined, + protos.google.cloud.licensemanager.v1.IUsage + >, + ): void; aggregateUsage( - request: protos.google.cloud.licensemanager.v1.IAggregateUsageRequest, - callback: PaginationCallback< - protos.google.cloud.licensemanager.v1.IAggregateUsageRequest, - protos.google.cloud.licensemanager.v1.IAggregateUsageResponse|null|undefined, - protos.google.cloud.licensemanager.v1.IUsage>): void; + request: protos.google.cloud.licensemanager.v1.IAggregateUsageRequest, + callback: PaginationCallback< + protos.google.cloud.licensemanager.v1.IAggregateUsageRequest, + | protos.google.cloud.licensemanager.v1.IAggregateUsageResponse + | null + | undefined, + protos.google.cloud.licensemanager.v1.IUsage + >, + ): void; aggregateUsage( - request?: protos.google.cloud.licensemanager.v1.IAggregateUsageRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.licensemanager.v1.IAggregateUsageRequest, - protos.google.cloud.licensemanager.v1.IAggregateUsageResponse|null|undefined, - protos.google.cloud.licensemanager.v1.IUsage>, - callback?: PaginationCallback< + request?: protos.google.cloud.licensemanager.v1.IAggregateUsageRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.licensemanager.v1.IAggregateUsageRequest, - protos.google.cloud.licensemanager.v1.IAggregateUsageResponse|null|undefined, - protos.google.cloud.licensemanager.v1.IUsage>): - Promise<[ - protos.google.cloud.licensemanager.v1.IUsage[], - protos.google.cloud.licensemanager.v1.IAggregateUsageRequest|null, - protos.google.cloud.licensemanager.v1.IAggregateUsageResponse - ]>|void { + | protos.google.cloud.licensemanager.v1.IAggregateUsageResponse + | null + | undefined, + protos.google.cloud.licensemanager.v1.IUsage + >, + callback?: PaginationCallback< + protos.google.cloud.licensemanager.v1.IAggregateUsageRequest, + | protos.google.cloud.licensemanager.v1.IAggregateUsageResponse + | null + | undefined, + protos.google.cloud.licensemanager.v1.IUsage + >, + ): Promise< + [ + protos.google.cloud.licensemanager.v1.IUsage[], + protos.google.cloud.licensemanager.v1.IAggregateUsageRequest | null, + protos.google.cloud.licensemanager.v1.IAggregateUsageResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.licensemanager.v1.IAggregateUsageRequest, - protos.google.cloud.licensemanager.v1.IAggregateUsageResponse|null|undefined, - protos.google.cloud.licensemanager.v1.IUsage>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.licensemanager.v1.IAggregateUsageRequest, + | protos.google.cloud.licensemanager.v1.IAggregateUsageResponse + | null + | undefined, + protos.google.cloud.licensemanager.v1.IUsage + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('aggregateUsage values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1929,216 +2630,245 @@ export class LicenseManagerClient { this._log.info('aggregateUsage request %j', request); return this.innerApiCalls .aggregateUsage(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.licensemanager.v1.IUsage[], - protos.google.cloud.licensemanager.v1.IAggregateUsageRequest|null, - protos.google.cloud.licensemanager.v1.IAggregateUsageResponse - ]) => { - this._log.info('aggregateUsage values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.licensemanager.v1.IUsage[], + protos.google.cloud.licensemanager.v1.IAggregateUsageRequest | null, + protos.google.cloud.licensemanager.v1.IAggregateUsageResponse, + ]) => { + this._log.info('aggregateUsage values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `aggregateUsage`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Parent value for AggregateUsageRequest - * @param {number} [request.pageSize] - * Optional. Requested page size. Server may return fewer items than - * requested. If unspecified, server will pick an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. Filtering results - * @param {string} [request.orderBy] - * Optional. Hint for how to order the results - * @param {google.protobuf.Timestamp} request.startTime - * Required. Licenses are purchased per month - so usage track needs start - * time of a month. - * @param {google.protobuf.Timestamp} request.endTime - * Required. Usage track is always for a month. This parameter is for the end - * time of the month. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.licensemanager.v1.Usage|Usage} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `aggregateUsageAsync()` - * method described below for async iteration which you can stop as 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 `aggregateUsage`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Parent value for AggregateUsageRequest + * @param {number} [request.pageSize] + * Optional. Requested page size. Server may return fewer items than + * requested. If unspecified, server will pick an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. Filtering results + * @param {string} [request.orderBy] + * Optional. Hint for how to order the results + * @param {google.protobuf.Timestamp} request.startTime + * Required. Licenses are purchased per month - so usage track needs start + * time of a month. + * @param {google.protobuf.Timestamp} request.endTime + * Required. Usage track is always for a month. This parameter is for the end + * time of the month. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.licensemanager.v1.Usage|Usage} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `aggregateUsageAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ aggregateUsageStream( - request?: protos.google.cloud.licensemanager.v1.IAggregateUsageRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.licensemanager.v1.IAggregateUsageRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); const defaultCallSettings = this._defaults['aggregateUsage']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('aggregateUsage stream %j', request); return this.descriptors.page.aggregateUsage.createStream( this.innerApiCalls.aggregateUsage as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `aggregateUsage`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Parent value for AggregateUsageRequest - * @param {number} [request.pageSize] - * Optional. Requested page size. Server may return fewer items than - * requested. If unspecified, server will pick an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. Filtering results - * @param {string} [request.orderBy] - * Optional. Hint for how to order the results - * @param {google.protobuf.Timestamp} request.startTime - * Required. Licenses are purchased per month - so usage track needs start - * time of a month. - * @param {google.protobuf.Timestamp} request.endTime - * Required. Usage track is always for a month. This parameter is for the end - * time of the month. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.licensemanager.v1.Usage|Usage}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@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/license_manager.aggregate_usage.js - * region_tag:licensemanager_v1_generated_LicenseManager_AggregateUsage_async - */ + /** + * Equivalent to `aggregateUsage`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Parent value for AggregateUsageRequest + * @param {number} [request.pageSize] + * Optional. Requested page size. Server may return fewer items than + * requested. If unspecified, server will pick an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. Filtering results + * @param {string} [request.orderBy] + * Optional. Hint for how to order the results + * @param {google.protobuf.Timestamp} request.startTime + * Required. Licenses are purchased per month - so usage track needs start + * time of a month. + * @param {google.protobuf.Timestamp} request.endTime + * Required. Usage track is always for a month. This parameter is for the end + * time of the month. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.licensemanager.v1.Usage|Usage}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@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/license_manager.aggregate_usage.js + * region_tag:licensemanager_v1_generated_LicenseManager_AggregateUsage_async + */ aggregateUsageAsync( - request?: protos.google.cloud.licensemanager.v1.IAggregateUsageRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.licensemanager.v1.IAggregateUsageRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', - }); + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + name: request.name ?? '', + }); const defaultCallSettings = this._defaults['aggregateUsage']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('aggregateUsage iterate %j', request); return this.descriptors.page.aggregateUsage.asyncIterate( this.innerApiCalls['aggregateUsage'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists Products in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for ListProductsRequest - * @param {number} [request.pageSize] - * Optional. Requested page size. Server may return fewer items than - * requested. If unspecified, server will pick an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. Filtering results - * @param {string} [request.orderBy] - * Optional. Hint for how to order the results - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link protos.google.cloud.licensemanager.v1.Product|Product}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listProductsAsync()` - * method described below for async iteration which you can stop as 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 Products in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for ListProductsRequest + * @param {number} [request.pageSize] + * Optional. Requested page size. Server may return fewer items than + * requested. If unspecified, server will pick an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. Filtering results + * @param {string} [request.orderBy] + * Optional. Hint for how to order the results + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.licensemanager.v1.Product|Product}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listProductsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listProducts( - request?: protos.google.cloud.licensemanager.v1.IListProductsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.licensemanager.v1.IProduct[], - protos.google.cloud.licensemanager.v1.IListProductsRequest|null, - protos.google.cloud.licensemanager.v1.IListProductsResponse - ]>; + request?: protos.google.cloud.licensemanager.v1.IListProductsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.licensemanager.v1.IProduct[], + protos.google.cloud.licensemanager.v1.IListProductsRequest | null, + protos.google.cloud.licensemanager.v1.IListProductsResponse, + ] + >; listProducts( - request: protos.google.cloud.licensemanager.v1.IListProductsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.licensemanager.v1.IListProductsRequest, - protos.google.cloud.licensemanager.v1.IListProductsResponse|null|undefined, - protos.google.cloud.licensemanager.v1.IProduct>): void; + request: protos.google.cloud.licensemanager.v1.IListProductsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.licensemanager.v1.IListProductsRequest, + | protos.google.cloud.licensemanager.v1.IListProductsResponse + | null + | undefined, + protos.google.cloud.licensemanager.v1.IProduct + >, + ): void; listProducts( - request: protos.google.cloud.licensemanager.v1.IListProductsRequest, - callback: PaginationCallback< - protos.google.cloud.licensemanager.v1.IListProductsRequest, - protos.google.cloud.licensemanager.v1.IListProductsResponse|null|undefined, - protos.google.cloud.licensemanager.v1.IProduct>): void; + request: protos.google.cloud.licensemanager.v1.IListProductsRequest, + callback: PaginationCallback< + protos.google.cloud.licensemanager.v1.IListProductsRequest, + | protos.google.cloud.licensemanager.v1.IListProductsResponse + | null + | undefined, + protos.google.cloud.licensemanager.v1.IProduct + >, + ): void; listProducts( - request?: protos.google.cloud.licensemanager.v1.IListProductsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.licensemanager.v1.IListProductsRequest, - protos.google.cloud.licensemanager.v1.IListProductsResponse|null|undefined, - protos.google.cloud.licensemanager.v1.IProduct>, - callback?: PaginationCallback< + request?: protos.google.cloud.licensemanager.v1.IListProductsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.licensemanager.v1.IListProductsRequest, - protos.google.cloud.licensemanager.v1.IListProductsResponse|null|undefined, - protos.google.cloud.licensemanager.v1.IProduct>): - Promise<[ - protos.google.cloud.licensemanager.v1.IProduct[], - protos.google.cloud.licensemanager.v1.IListProductsRequest|null, - protos.google.cloud.licensemanager.v1.IListProductsResponse - ]>|void { + | protos.google.cloud.licensemanager.v1.IListProductsResponse + | null + | undefined, + protos.google.cloud.licensemanager.v1.IProduct + >, + callback?: PaginationCallback< + protos.google.cloud.licensemanager.v1.IListProductsRequest, + | protos.google.cloud.licensemanager.v1.IListProductsResponse + | null + | undefined, + protos.google.cloud.licensemanager.v1.IProduct + >, + ): Promise< + [ + protos.google.cloud.licensemanager.v1.IProduct[], + protos.google.cloud.licensemanager.v1.IListProductsRequest | null, + protos.google.cloud.licensemanager.v1.IListProductsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-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.licensemanager.v1.IListProductsRequest, - protos.google.cloud.licensemanager.v1.IListProductsResponse|null|undefined, - protos.google.cloud.licensemanager.v1.IProduct>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.licensemanager.v1.IListProductsRequest, + | protos.google.cloud.licensemanager.v1.IListProductsResponse + | null + | undefined, + protos.google.cloud.licensemanager.v1.IProduct + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listProducts values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -2147,119 +2877,124 @@ export class LicenseManagerClient { this._log.info('listProducts request %j', request); return this.innerApiCalls .listProducts(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.licensemanager.v1.IProduct[], - protos.google.cloud.licensemanager.v1.IListProductsRequest|null, - protos.google.cloud.licensemanager.v1.IListProductsResponse - ]) => { - this._log.info('listProducts values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.licensemanager.v1.IProduct[], + protos.google.cloud.licensemanager.v1.IListProductsRequest | null, + protos.google.cloud.licensemanager.v1.IListProductsResponse, + ]) => { + this._log.info('listProducts values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listProducts`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for ListProductsRequest - * @param {number} [request.pageSize] - * Optional. Requested page size. Server may return fewer items than - * requested. If unspecified, server will pick an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. Filtering results - * @param {string} [request.orderBy] - * Optional. Hint for how to order the results - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.licensemanager.v1.Product|Product} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listProductsAsync()` - * method described below for async iteration which you can stop as 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 `listProducts`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for ListProductsRequest + * @param {number} [request.pageSize] + * Optional. Requested page size. Server may return fewer items than + * requested. If unspecified, server will pick an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. Filtering results + * @param {string} [request.orderBy] + * Optional. Hint for how to order the results + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.licensemanager.v1.Product|Product} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listProductsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listProductsStream( - request?: protos.google.cloud.licensemanager.v1.IListProductsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.licensemanager.v1.IListProductsRequest, + 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['listProducts']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listProducts stream %j', request); return this.descriptors.page.listProducts.createStream( this.innerApiCalls.listProducts as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listProducts`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used 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 ListProductsRequest - * @param {number} [request.pageSize] - * Optional. Requested page size. Server may return fewer items than - * requested. If unspecified, server will pick an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * @param {string} [request.filter] - * Optional. Filtering results - * @param {string} [request.orderBy] - * Optional. Hint for how to order the results - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.licensemanager.v1.Product|Product}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@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/license_manager.list_products.js - * region_tag:licensemanager_v1_generated_LicenseManager_ListProducts_async - */ + /** + * Equivalent to `listProducts`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used 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 ListProductsRequest + * @param {number} [request.pageSize] + * Optional. Requested page size. Server may return fewer items than + * requested. If unspecified, server will pick an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * @param {string} [request.filter] + * Optional. Filtering results + * @param {string} [request.orderBy] + * Optional. Hint for how to order the results + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.licensemanager.v1.Product|Product}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@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/license_manager.list_products.js + * region_tag:licensemanager_v1_generated_LicenseManager_ListProducts_async + */ listProductsAsync( - request?: protos.google.cloud.licensemanager.v1.IListProductsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.licensemanager.v1.IListProductsRequest, + 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['listProducts']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listProducts iterate %j', request); return this.descriptors.page.listProducts.asyncIterate( this.innerApiCalls['listProducts'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** + + /** * Gets information about a location. * * @param {Object} request @@ -2294,12 +3029,11 @@ export class LicenseManagerClient { | 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. @@ -2332,12 +3066,12 @@ export class LicenseManagerClient { */ 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. @@ -2380,22 +3114,22 @@ export class LicenseManagerClient { 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); } /** @@ -2430,15 +3164,15 @@ export class LicenseManagerClient { */ 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); } /** @@ -2472,7 +3206,7 @@ export class LicenseManagerClient { * await client.cancelOperation({name: ''}); * ``` */ - cancelOperation( + cancelOperation( request: protos.google.longrunning.CancelOperationRequest, optionsOrCallback?: | gax.CallOptions @@ -2485,25 +3219,24 @@ export class LicenseManagerClient { 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 @@ -2542,22 +3275,22 @@ export class LicenseManagerClient { 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); } @@ -2573,7 +3306,7 @@ export class LicenseManagerClient { * @param {string} configuration * @returns {string} Resource name string. */ - configurationPath(project:string,location:string,configuration:string) { + configurationPath(project: string, location: string, configuration: string) { return this.pathTemplates.configurationPathTemplate.render({ project: project, location: location, @@ -2589,7 +3322,8 @@ export class LicenseManagerClient { * @returns {string} A string representing the project. */ matchProjectFromConfigurationName(configurationName: string) { - return this.pathTemplates.configurationPathTemplate.match(configurationName).project; + return this.pathTemplates.configurationPathTemplate.match(configurationName) + .project; } /** @@ -2600,7 +3334,8 @@ export class LicenseManagerClient { * @returns {string} A string representing the location. */ matchLocationFromConfigurationName(configurationName: string) { - return this.pathTemplates.configurationPathTemplate.match(configurationName).location; + return this.pathTemplates.configurationPathTemplate.match(configurationName) + .location; } /** @@ -2611,7 +3346,8 @@ export class LicenseManagerClient { * @returns {string} A string representing the configuration. */ matchConfigurationFromConfigurationName(configurationName: string) { - return this.pathTemplates.configurationPathTemplate.match(configurationName).configuration; + return this.pathTemplates.configurationPathTemplate.match(configurationName) + .configuration; } /** @@ -2622,7 +3358,7 @@ export class LicenseManagerClient { * @param {string} instance * @returns {string} Resource name string. */ - instancePath(project:string,location:string,instance:string) { + instancePath(project: string, location: string, instance: string) { return this.pathTemplates.instancePathTemplate.render({ project: project, location: location, @@ -2670,7 +3406,7 @@ export class LicenseManagerClient { * @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, @@ -2707,7 +3443,7 @@ export class LicenseManagerClient { * @param {string} product * @returns {string} Resource name string. */ - productPath(project:string,location:string,product:string) { + productPath(project: string, location: string, product: string) { return this.pathTemplates.productPathTemplate.render({ project: project, location: location, @@ -2754,7 +3490,7 @@ export class LicenseManagerClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -2779,14 +3515,16 @@ export class LicenseManagerClient { */ close(): Promise { if (this.licenseManagerStub && !this._terminated) { - return this.licenseManagerStub.then(stub => { + return this.licenseManagerStub.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-licensemanager/system-test/fixtures/sample/src/index.ts b/packages/google-cloud-licensemanager/system-test/fixtures/sample/src/index.ts index 888ea5fab965..ea7e0bfbca09 100644 --- a/packages/google-cloud-licensemanager/system-test/fixtures/sample/src/index.ts +++ b/packages/google-cloud-licensemanager/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 {LicenseManagerClient} from '@google-cloud/licensemanager'; +import { LicenseManagerClient } from '@google-cloud/licensemanager'; // check that the client class type name can be used function doStuffWithLicenseManagerClient(client: LicenseManagerClient) { diff --git a/packages/google-cloud-licensemanager/system-test/install.ts b/packages/google-cloud-licensemanager/system-test/install.ts index f66069aa3940..ccf167042d2e 100644 --- a/packages/google-cloud-licensemanager/system-test/install.ts +++ b/packages/google-cloud-licensemanager/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-licensemanager/test/gapic_license_manager_v1.ts b/packages/google-cloud-licensemanager/test/gapic_license_manager_v1.ts index 35511a334628..89019787f425 100644 --- a/packages/google-cloud-licensemanager/test/gapic_license_manager_v1.ts +++ b/packages/google-cloud-licensemanager/test/gapic_license_manager_v1.ts @@ -19,3075 +19,3961 @@ 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 licensemanagerModule 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.LicenseManagerClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new licensemanagerModule.v1.LicenseManagerClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'licensemanager.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new licensemanagerModule.v1.LicenseManagerClient(); - 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 = licensemanagerModule.v1.LicenseManagerClient.servicePath; - assert.strictEqual(servicePath, 'licensemanager.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = licensemanagerModule.v1.LicenseManagerClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'licensemanager.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'licensemanager.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'licensemanager.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 licensemanagerModule.v1.LicenseManagerClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'licensemanager.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 licensemanagerModule.v1.LicenseManagerClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'licensemanager.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 licensemanagerModule.v1.LicenseManagerClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); - - it('has port', () => { - const port = licensemanagerModule.v1.LicenseManagerClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new licensemanagerModule.v1.LicenseManagerClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.licenseManagerStub, undefined); - await client.initialize(); - assert(client.licenseManagerStub); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new licensemanagerModule.v1.LicenseManagerClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'licensemanager.googleapis.com'); + }); - it('has close method for the initialized client', done => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.licenseManagerStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has universeDomain', () => { + const client = new licensemanagerModule.v1.LicenseManagerClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('has close method for the non-initialized client', done => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.licenseManagerStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + licensemanagerModule.v1.LicenseManagerClient.servicePath; + assert.strictEqual(servicePath, 'licensemanager.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + licensemanagerModule.v1.LicenseManagerClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'licensemanager.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'licensemanager.example.com'); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'licensemanager.example.com'); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new licensemanagerModule.v1.LicenseManagerClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'licensemanager.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 licensemanagerModule.v1.LicenseManagerClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual( + servicePath, + 'licensemanager.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 licensemanagerModule.v1.LicenseManagerClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); }); - describe('getConfiguration', () => { - it('invokes getConfiguration without error', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.GetConfigurationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.GetConfigurationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.Configuration() - ); - client.innerApiCalls.getConfiguration = stubSimpleCall(expectedResponse); - const [response] = await client.getConfiguration(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getConfiguration as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getConfiguration as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has port', () => { + const port = licensemanagerModule.v1.LicenseManagerClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('invokes getConfiguration without error using callback', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.GetConfigurationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.GetConfigurationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.Configuration() - ); - client.innerApiCalls.getConfiguration = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getConfiguration( - request, - (err?: Error|null, result?: protos.google.cloud.licensemanager.v1.IConfiguration|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getConfiguration as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getConfiguration 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 licensemanagerModule.v1.LicenseManagerClient(); + assert(client); + }); - it('invokes getConfiguration with error', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.GetConfigurationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.GetConfigurationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getConfiguration = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getConfiguration(request), expectedError); - const actualRequest = (client.innerApiCalls.getConfiguration as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getConfiguration 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 licensemanagerModule.v1.LicenseManagerClient({ + fallback: true, + }); + assert(client); + }); - it('invokes getConfiguration with closed client', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.GetConfigurationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.GetConfigurationRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getConfiguration(request), expectedError); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.licenseManagerStub, undefined); + await client.initialize(); + assert(client.licenseManagerStub); }); - describe('getInstance', () => { - it('invokes getInstance without error', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.GetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.GetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.Instance() - ); - client.innerApiCalls.getInstance = stubSimpleCall(expectedResponse); - const [response] = await client.getInstance(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('has close method for the initialized client', (done) => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.licenseManagerStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes getInstance without error using callback', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.GetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.GetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.Instance() - ); - client.innerApiCalls.getInstance = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getInstance( - request, - (err?: Error|null, result?: protos.google.cloud.licensemanager.v1.IInstance|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('has close method for the non-initialized client', (done) => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.licenseManagerStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes getInstance with error', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.GetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.GetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getInstance = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getInstance(request), expectedError); - const actualRequest = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getInstance as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new licensemanagerModule.v1.LicenseManagerClient({ + 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 getInstance with closed client', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.GetInstanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.GetInstanceRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getInstance(request), expectedError); - }); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new licensemanagerModule.v1.LicenseManagerClient({ + 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('getConfiguration', () => { + it('invokes getConfiguration without error', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.GetConfigurationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.GetConfigurationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.Configuration(), + ); + client.innerApiCalls.getConfiguration = stubSimpleCall(expectedResponse); + const [response] = await client.getConfiguration(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getConfiguration as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getConfiguration as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('queryConfigurationLicenseUsage', () => { - it('invokes queryConfigurationLicenseUsage without error', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.QueryConfigurationLicenseUsageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.QueryConfigurationLicenseUsageRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.QueryConfigurationLicenseUsageResponse() - ); - client.innerApiCalls.queryConfigurationLicenseUsage = stubSimpleCall(expectedResponse); - const [response] = await client.queryConfigurationLicenseUsage(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.queryConfigurationLicenseUsage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.queryConfigurationLicenseUsage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getConfiguration without error using callback', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.GetConfigurationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.GetConfigurationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.Configuration(), + ); + client.innerApiCalls.getConfiguration = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getConfiguration( + request, + ( + err?: Error | null, + result?: protos.google.cloud.licensemanager.v1.IConfiguration | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getConfiguration as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getConfiguration as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes queryConfigurationLicenseUsage without error using callback', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.QueryConfigurationLicenseUsageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.QueryConfigurationLicenseUsageRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.QueryConfigurationLicenseUsageResponse() - ); - client.innerApiCalls.queryConfigurationLicenseUsage = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.queryConfigurationLicenseUsage( - request, - (err?: Error|null, result?: protos.google.cloud.licensemanager.v1.IQueryConfigurationLicenseUsageResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.queryConfigurationLicenseUsage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.queryConfigurationLicenseUsage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getConfiguration with error', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.GetConfigurationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.GetConfigurationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getConfiguration = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getConfiguration(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getConfiguration as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getConfiguration as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes queryConfigurationLicenseUsage with error', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.QueryConfigurationLicenseUsageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.QueryConfigurationLicenseUsageRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.queryConfigurationLicenseUsage = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.queryConfigurationLicenseUsage(request), expectedError); - const actualRequest = (client.innerApiCalls.queryConfigurationLicenseUsage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.queryConfigurationLicenseUsage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getConfiguration with closed client', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.GetConfigurationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.GetConfigurationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getConfiguration(request), expectedError); + }); + }); + + describe('getInstance', () => { + it('invokes getInstance without error', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.GetInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.GetInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.Instance(), + ); + client.innerApiCalls.getInstance = stubSimpleCall(expectedResponse); + const [response] = await client.getInstance(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes queryConfigurationLicenseUsage with closed client', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.QueryConfigurationLicenseUsageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.QueryConfigurationLicenseUsageRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.queryConfigurationLicenseUsage(request), expectedError); - }); + it('invokes getInstance without error using callback', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.GetInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.GetInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.Instance(), + ); + client.innerApiCalls.getInstance = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getInstance( + request, + ( + err?: Error | null, + result?: protos.google.cloud.licensemanager.v1.IInstance | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getProduct', () => { - it('invokes getProduct without error', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.GetProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.GetProductRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.Product() - ); - client.innerApiCalls.getProduct = stubSimpleCall(expectedResponse); - const [response] = await client.getProduct(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getInstance with error', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.GetInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.GetInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getInstance = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getInstance(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getInstance as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getInstance as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getProduct without error using callback', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.GetProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.GetProductRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.Product() - ); - client.innerApiCalls.getProduct = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getProduct( - request, - (err?: Error|null, result?: protos.google.cloud.licensemanager.v1.IProduct|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getInstance with closed client', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.GetInstanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.GetInstanceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getInstance(request), expectedError); + }); + }); + + describe('queryConfigurationLicenseUsage', () => { + it('invokes queryConfigurationLicenseUsage without error', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.QueryConfigurationLicenseUsageRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.QueryConfigurationLicenseUsageRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.QueryConfigurationLicenseUsageResponse(), + ); + client.innerApiCalls.queryConfigurationLicenseUsage = + stubSimpleCall(expectedResponse); + const [response] = await client.queryConfigurationLicenseUsage(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.queryConfigurationLicenseUsage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.queryConfigurationLicenseUsage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getProduct with error', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.GetProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.GetProductRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getProduct = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getProduct(request), expectedError); - const actualRequest = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getProduct as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes queryConfigurationLicenseUsage without error using callback', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.QueryConfigurationLicenseUsageRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.QueryConfigurationLicenseUsageRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.QueryConfigurationLicenseUsageResponse(), + ); + client.innerApiCalls.queryConfigurationLicenseUsage = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.queryConfigurationLicenseUsage( + request, + ( + err?: Error | null, + result?: protos.google.cloud.licensemanager.v1.IQueryConfigurationLicenseUsageResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.queryConfigurationLicenseUsage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.queryConfigurationLicenseUsage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getProduct with closed client', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.GetProductRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.GetProductRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getProduct(request), expectedError); - }); + it('invokes queryConfigurationLicenseUsage with error', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.QueryConfigurationLicenseUsageRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.QueryConfigurationLicenseUsageRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.queryConfigurationLicenseUsage = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.queryConfigurationLicenseUsage(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.queryConfigurationLicenseUsage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.queryConfigurationLicenseUsage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createConfiguration', () => { - it('invokes createConfiguration without error', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.CreateConfigurationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.CreateConfigurationRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createConfiguration = stubLongRunningCall(expectedResponse); - const [operation] = await client.createConfiguration(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createConfiguration as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createConfiguration as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes queryConfigurationLicenseUsage with closed client', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.QueryConfigurationLicenseUsageRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.QueryConfigurationLicenseUsageRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.queryConfigurationLicenseUsage(request), + expectedError, + ); + }); + }); + + describe('getProduct', () => { + it('invokes getProduct without error', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.GetProductRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.GetProductRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.Product(), + ); + client.innerApiCalls.getProduct = stubSimpleCall(expectedResponse); + const [response] = await client.getProduct(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createConfiguration without error using callback', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.CreateConfigurationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.CreateConfigurationRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createConfiguration = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createConfiguration( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createConfiguration as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createConfiguration as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getProduct without error using callback', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.GetProductRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.GetProductRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.Product(), + ); + client.innerApiCalls.getProduct = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getProduct( + request, + ( + err?: Error | null, + result?: protos.google.cloud.licensemanager.v1.IProduct | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createConfiguration with call error', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.CreateConfigurationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.CreateConfigurationRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createConfiguration = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createConfiguration(request), expectedError); - const actualRequest = (client.innerApiCalls.createConfiguration as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createConfiguration as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getProduct with error', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.GetProductRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.GetProductRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getProduct = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getProduct(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getProduct as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createConfiguration with LRO error', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.CreateConfigurationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.CreateConfigurationRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createConfiguration = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createConfiguration(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createConfiguration as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createConfiguration as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getProduct with closed client', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.GetProductRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.GetProductRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getProduct(request), expectedError); + }); + }); + + describe('createConfiguration', () => { + it('invokes createConfiguration without error', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.CreateConfigurationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.CreateConfigurationRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createConfiguration = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createConfiguration(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createConfiguration as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createConfiguration as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateConfigurationProgress without error', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateConfigurationProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createConfiguration without error using callback', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.CreateConfigurationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.CreateConfigurationRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createConfiguration = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createConfiguration( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.licensemanager.v1.IConfiguration, + protos.google.cloud.licensemanager.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.licensemanager.v1.IConfiguration, + protos.google.cloud.licensemanager.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createConfiguration as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createConfiguration as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateConfigurationProgress with error', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateConfigurationProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes createConfiguration with call error', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.CreateConfigurationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.CreateConfigurationRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createConfiguration = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createConfiguration(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createConfiguration as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createConfiguration as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateConfiguration', () => { - it('invokes updateConfiguration without error', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.UpdateConfigurationRequest() - ); - request.configuration ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.UpdateConfigurationRequest', ['configuration', 'name']); - request.configuration.name = defaultValue1; - const expectedHeaderRequestParams = `configuration.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateConfiguration = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateConfiguration(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateConfiguration as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateConfiguration as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createConfiguration with LRO error', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.CreateConfigurationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.CreateConfigurationRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createConfiguration = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createConfiguration(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createConfiguration as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createConfiguration as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateConfiguration without error using callback', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.UpdateConfigurationRequest() - ); - request.configuration ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.UpdateConfigurationRequest', ['configuration', 'name']); - request.configuration.name = defaultValue1; - const expectedHeaderRequestParams = `configuration.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateConfiguration = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateConfiguration( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateConfiguration as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateConfiguration as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateConfigurationProgress without error', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateConfigurationProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes updateConfiguration with call error', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.UpdateConfigurationRequest() - ); - request.configuration ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.UpdateConfigurationRequest', ['configuration', 'name']); - request.configuration.name = defaultValue1; - const expectedHeaderRequestParams = `configuration.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateConfiguration = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateConfiguration(request), expectedError); - const actualRequest = (client.innerApiCalls.updateConfiguration as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateConfiguration as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateConfigurationProgress with error', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateConfigurationProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateConfiguration', () => { + it('invokes updateConfiguration without error', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.UpdateConfigurationRequest(), + ); + request.configuration ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.UpdateConfigurationRequest', + ['configuration', 'name'], + ); + request.configuration.name = defaultValue1; + const expectedHeaderRequestParams = `configuration.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateConfiguration = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateConfiguration(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateConfiguration as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateConfiguration as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateConfiguration with LRO error', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.UpdateConfigurationRequest() - ); - request.configuration ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.UpdateConfigurationRequest', ['configuration', 'name']); - request.configuration.name = defaultValue1; - const expectedHeaderRequestParams = `configuration.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateConfiguration = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateConfiguration(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateConfiguration as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateConfiguration as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateConfiguration without error using callback', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.UpdateConfigurationRequest(), + ); + request.configuration ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.UpdateConfigurationRequest', + ['configuration', 'name'], + ); + request.configuration.name = defaultValue1; + const expectedHeaderRequestParams = `configuration.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateConfiguration = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateConfiguration( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.licensemanager.v1.IConfiguration, + protos.google.cloud.licensemanager.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.licensemanager.v1.IConfiguration, + protos.google.cloud.licensemanager.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateConfiguration as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateConfiguration as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateConfigurationProgress without error', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateConfigurationProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes updateConfiguration with call error', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.UpdateConfigurationRequest(), + ); + request.configuration ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.UpdateConfigurationRequest', + ['configuration', 'name'], + ); + request.configuration.name = defaultValue1; + const expectedHeaderRequestParams = `configuration.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateConfiguration = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateConfiguration(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateConfiguration as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateConfiguration as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateConfigurationProgress with error', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateConfigurationProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes updateConfiguration with LRO error', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.UpdateConfigurationRequest(), + ); + request.configuration ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.UpdateConfigurationRequest', + ['configuration', 'name'], + ); + request.configuration.name = defaultValue1; + const expectedHeaderRequestParams = `configuration.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateConfiguration = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateConfiguration(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateConfiguration as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateConfiguration as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteConfiguration', () => { - it('invokes deleteConfiguration without error', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.DeleteConfigurationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.DeleteConfigurationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteConfiguration = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteConfiguration(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteConfiguration as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteConfiguration as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateConfigurationProgress without error', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdateConfigurationProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes deleteConfiguration without error using callback', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.DeleteConfigurationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.DeleteConfigurationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteConfiguration = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteConfiguration( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteConfiguration as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteConfiguration as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateConfigurationProgress with error', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateConfigurationProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteConfiguration', () => { + it('invokes deleteConfiguration without error', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.DeleteConfigurationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.DeleteConfigurationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteConfiguration = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteConfiguration(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteConfiguration as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteConfiguration as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteConfiguration with call error', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.DeleteConfigurationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.DeleteConfigurationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteConfiguration = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteConfiguration(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteConfiguration as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteConfiguration as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteConfiguration without error using callback', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.DeleteConfigurationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.DeleteConfigurationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteConfiguration = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteConfiguration( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.licensemanager.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.licensemanager.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteConfiguration as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteConfiguration as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteConfiguration with LRO error', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.DeleteConfigurationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.DeleteConfigurationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteConfiguration = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteConfiguration(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteConfiguration as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteConfiguration as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteConfiguration with call error', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.DeleteConfigurationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.DeleteConfigurationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteConfiguration = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteConfiguration(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteConfiguration as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteConfiguration as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteConfigurationProgress without error', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteConfigurationProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes deleteConfiguration with LRO error', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.DeleteConfigurationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.DeleteConfigurationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteConfiguration = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteConfiguration(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteConfiguration as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteConfiguration as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteConfigurationProgress with error', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteConfigurationProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkDeleteConfigurationProgress without error', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteConfigurationProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('deactivateConfiguration', () => { - it('invokes deactivateConfiguration without error', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.DeactivateConfigurationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.DeactivateConfigurationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deactivateConfiguration = stubLongRunningCall(expectedResponse); - const [operation] = await client.deactivateConfiguration(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deactivateConfiguration as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deactivateConfiguration as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteConfigurationProgress with error', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteConfigurationProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deactivateConfiguration', () => { + it('invokes deactivateConfiguration without error', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.DeactivateConfigurationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.DeactivateConfigurationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deactivateConfiguration = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deactivateConfiguration(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deactivateConfiguration as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deactivateConfiguration as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deactivateConfiguration without error using callback', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.DeactivateConfigurationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.DeactivateConfigurationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deactivateConfiguration = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deactivateConfiguration( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deactivateConfiguration as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deactivateConfiguration as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deactivateConfiguration without error using callback', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.DeactivateConfigurationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.DeactivateConfigurationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deactivateConfiguration = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deactivateConfiguration( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.licensemanager.v1.IConfiguration, + protos.google.cloud.licensemanager.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.licensemanager.v1.IConfiguration, + protos.google.cloud.licensemanager.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deactivateConfiguration as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deactivateConfiguration as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deactivateConfiguration with call error', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.DeactivateConfigurationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.DeactivateConfigurationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deactivateConfiguration = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deactivateConfiguration(request), expectedError); - const actualRequest = (client.innerApiCalls.deactivateConfiguration as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deactivateConfiguration as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deactivateConfiguration with call error', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.DeactivateConfigurationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.DeactivateConfigurationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deactivateConfiguration = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.deactivateConfiguration(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.deactivateConfiguration as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deactivateConfiguration as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deactivateConfiguration with LRO error', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.DeactivateConfigurationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.DeactivateConfigurationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deactivateConfiguration = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deactivateConfiguration(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deactivateConfiguration as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deactivateConfiguration as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deactivateConfiguration with LRO error', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.DeactivateConfigurationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.DeactivateConfigurationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deactivateConfiguration = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deactivateConfiguration(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deactivateConfiguration as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deactivateConfiguration as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeactivateConfigurationProgress without error', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeactivateConfigurationProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkDeactivateConfigurationProgress without error', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = + await client.checkDeactivateConfigurationProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkDeactivateConfigurationProgress with error', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeactivateConfigurationProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkDeactivateConfigurationProgress with error', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeactivateConfigurationProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('reactivateConfiguration', () => { + it('invokes reactivateConfiguration without error', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.ReactivateConfigurationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.ReactivateConfigurationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.reactivateConfiguration = + stubLongRunningCall(expectedResponse); + const [operation] = await client.reactivateConfiguration(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.reactivateConfiguration as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.reactivateConfiguration as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('reactivateConfiguration', () => { - it('invokes reactivateConfiguration without error', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.ReactivateConfigurationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.ReactivateConfigurationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.reactivateConfiguration = stubLongRunningCall(expectedResponse); - const [operation] = await client.reactivateConfiguration(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.reactivateConfiguration as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.reactivateConfiguration as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes reactivateConfiguration without error using callback', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.ReactivateConfigurationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.ReactivateConfigurationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.reactivateConfiguration = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.reactivateConfiguration( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.licensemanager.v1.IConfiguration, + protos.google.cloud.licensemanager.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.licensemanager.v1.IConfiguration, + protos.google.cloud.licensemanager.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.reactivateConfiguration as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.reactivateConfiguration as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes reactivateConfiguration without error using callback', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.ReactivateConfigurationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.ReactivateConfigurationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.reactivateConfiguration = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.reactivateConfiguration( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.reactivateConfiguration as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.reactivateConfiguration as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes reactivateConfiguration with call error', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.ReactivateConfigurationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.ReactivateConfigurationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.reactivateConfiguration = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects( + client.reactivateConfiguration(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.reactivateConfiguration as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.reactivateConfiguration as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes reactivateConfiguration with call error', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.ReactivateConfigurationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.ReactivateConfigurationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.reactivateConfiguration = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.reactivateConfiguration(request), expectedError); - const actualRequest = (client.innerApiCalls.reactivateConfiguration as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.reactivateConfiguration as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes reactivateConfiguration with LRO error', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.ReactivateConfigurationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.ReactivateConfigurationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.reactivateConfiguration = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.reactivateConfiguration(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.reactivateConfiguration as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.reactivateConfiguration as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes reactivateConfiguration with LRO error', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.ReactivateConfigurationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.ReactivateConfigurationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.reactivateConfiguration = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.reactivateConfiguration(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.reactivateConfiguration as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.reactivateConfiguration as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkReactivateConfigurationProgress without error', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = + await client.checkReactivateConfigurationProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkReactivateConfigurationProgress without error', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkReactivateConfigurationProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkReactivateConfigurationProgress with error', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkReactivateConfigurationProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listConfigurations', () => { + it('invokes listConfigurations without error', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.ListConfigurationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.ListConfigurationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.licensemanager.v1.Configuration(), + ), + generateSampleMessage( + new protos.google.cloud.licensemanager.v1.Configuration(), + ), + generateSampleMessage( + new protos.google.cloud.licensemanager.v1.Configuration(), + ), + ]; + client.innerApiCalls.listConfigurations = + stubSimpleCall(expectedResponse); + const [response] = await client.listConfigurations(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listConfigurations as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listConfigurations as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkReactivateConfigurationProgress with error', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkReactivateConfigurationProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes listConfigurations without error using callback', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.ListConfigurationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.ListConfigurationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.licensemanager.v1.Configuration(), + ), + generateSampleMessage( + new protos.google.cloud.licensemanager.v1.Configuration(), + ), + generateSampleMessage( + new protos.google.cloud.licensemanager.v1.Configuration(), + ), + ]; + client.innerApiCalls.listConfigurations = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listConfigurations( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.licensemanager.v1.IConfiguration[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listConfigurations as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listConfigurations as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listConfigurations', () => { - it('invokes listConfigurations without error', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.ListConfigurationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.ListConfigurationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.licensemanager.v1.Configuration()), - generateSampleMessage(new protos.google.cloud.licensemanager.v1.Configuration()), - generateSampleMessage(new protos.google.cloud.licensemanager.v1.Configuration()), - ]; - client.innerApiCalls.listConfigurations = stubSimpleCall(expectedResponse); - const [response] = await client.listConfigurations(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listConfigurations as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listConfigurations as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listConfigurations with error', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.ListConfigurationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.ListConfigurationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listConfigurations = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listConfigurations(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listConfigurations as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listConfigurations as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listConfigurations without error using callback', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.ListConfigurationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.ListConfigurationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.licensemanager.v1.Configuration()), - generateSampleMessage(new protos.google.cloud.licensemanager.v1.Configuration()), - generateSampleMessage(new protos.google.cloud.licensemanager.v1.Configuration()), - ]; - client.innerApiCalls.listConfigurations = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listConfigurations( - request, - (err?: Error|null, result?: protos.google.cloud.licensemanager.v1.IConfiguration[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listConfigurations as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listConfigurations as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listConfigurationsStream without error', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.ListConfigurationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.ListConfigurationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.licensemanager.v1.Configuration(), + ), + generateSampleMessage( + new protos.google.cloud.licensemanager.v1.Configuration(), + ), + generateSampleMessage( + new protos.google.cloud.licensemanager.v1.Configuration(), + ), + ]; + client.descriptors.page.listConfigurations.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listConfigurationsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.licensemanager.v1.Configuration[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.licensemanager.v1.Configuration) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listConfigurations.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listConfigurations, request), + ); + assert( + (client.descriptors.page.listConfigurations.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listConfigurations with error', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.ListConfigurationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.ListConfigurationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listConfigurations = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listConfigurations(request), expectedError); - const actualRequest = (client.innerApiCalls.listConfigurations as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listConfigurations as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listConfigurationsStream with error', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.ListConfigurationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.ListConfigurationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listConfigurations.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listConfigurationsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.licensemanager.v1.Configuration[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.licensemanager.v1.Configuration) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listConfigurations.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listConfigurations, request), + ); + assert( + (client.descriptors.page.listConfigurations.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listConfigurationsStream without error', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.ListConfigurationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.ListConfigurationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.licensemanager.v1.Configuration()), - generateSampleMessage(new protos.google.cloud.licensemanager.v1.Configuration()), - generateSampleMessage(new protos.google.cloud.licensemanager.v1.Configuration()), - ]; - client.descriptors.page.listConfigurations.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listConfigurationsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.licensemanager.v1.Configuration[] = []; - stream.on('data', (response: protos.google.cloud.licensemanager.v1.Configuration) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listConfigurations.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listConfigurations, request)); - assert( - (client.descriptors.page.listConfigurations.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listConfigurations without error', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.ListConfigurationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.ListConfigurationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.licensemanager.v1.Configuration(), + ), + generateSampleMessage( + new protos.google.cloud.licensemanager.v1.Configuration(), + ), + generateSampleMessage( + new protos.google.cloud.licensemanager.v1.Configuration(), + ), + ]; + client.descriptors.page.listConfigurations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.licensemanager.v1.IConfiguration[] = + []; + const iterable = client.listConfigurationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listConfigurations.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listConfigurations.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listConfigurationsStream with error', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.ListConfigurationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.ListConfigurationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listConfigurations.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listConfigurationsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.licensemanager.v1.Configuration[] = []; - stream.on('data', (response: protos.google.cloud.licensemanager.v1.Configuration) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listConfigurations.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listConfigurations, request)); - assert( - (client.descriptors.page.listConfigurations.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listConfigurations with error', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.ListConfigurationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.ListConfigurationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listConfigurations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listConfigurationsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.licensemanager.v1.IConfiguration[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listConfigurations.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listConfigurations.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listInstances', () => { + it('invokes listInstances without error', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.ListInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.ListInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.licensemanager.v1.Instance(), + ), + generateSampleMessage( + new protos.google.cloud.licensemanager.v1.Instance(), + ), + generateSampleMessage( + new protos.google.cloud.licensemanager.v1.Instance(), + ), + ]; + client.innerApiCalls.listInstances = stubSimpleCall(expectedResponse); + const [response] = await client.listInstances(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listInstances as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listInstances as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listConfigurations without error', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.ListConfigurationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.ListConfigurationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.licensemanager.v1.Configuration()), - generateSampleMessage(new protos.google.cloud.licensemanager.v1.Configuration()), - generateSampleMessage(new protos.google.cloud.licensemanager.v1.Configuration()), - ]; - client.descriptors.page.listConfigurations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.licensemanager.v1.IConfiguration[] = []; - const iterable = client.listConfigurationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listInstances without error using callback', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.ListInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.ListInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.licensemanager.v1.Instance(), + ), + generateSampleMessage( + new protos.google.cloud.licensemanager.v1.Instance(), + ), + generateSampleMessage( + new protos.google.cloud.licensemanager.v1.Instance(), + ), + ]; + client.innerApiCalls.listInstances = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listInstances( + request, + ( + err?: Error | null, + result?: protos.google.cloud.licensemanager.v1.IInstance[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listConfigurations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listConfigurations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listConfigurations with error', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.ListConfigurationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.ListConfigurationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listConfigurations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listConfigurationsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.licensemanager.v1.IConfiguration[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listConfigurations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listConfigurations.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.listInstances as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listInstances as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listInstances', () => { - it('invokes listInstances without error', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.licensemanager.v1.Instance()), - generateSampleMessage(new protos.google.cloud.licensemanager.v1.Instance()), - generateSampleMessage(new protos.google.cloud.licensemanager.v1.Instance()), - ]; - client.innerApiCalls.listInstances = stubSimpleCall(expectedResponse); - const [response] = await client.listInstances(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listInstances with error', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.ListInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.ListInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listInstances = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listInstances(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listInstances as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listInstances as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listInstances without error using callback', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.licensemanager.v1.Instance()), - generateSampleMessage(new protos.google.cloud.licensemanager.v1.Instance()), - generateSampleMessage(new protos.google.cloud.licensemanager.v1.Instance()), - ]; - client.innerApiCalls.listInstances = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listInstances( - request, - (err?: Error|null, result?: protos.google.cloud.licensemanager.v1.IInstance[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listInstancesStream without error', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.ListInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.ListInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.licensemanager.v1.Instance(), + ), + generateSampleMessage( + new protos.google.cloud.licensemanager.v1.Instance(), + ), + generateSampleMessage( + new protos.google.cloud.licensemanager.v1.Instance(), + ), + ]; + client.descriptors.page.listInstances.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listInstancesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.licensemanager.v1.Instance[] = []; + stream.on( + 'data', + (response: protos.google.cloud.licensemanager.v1.Instance) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listInstances.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listInstances, request), + ); + assert( + (client.descriptors.page.listInstances.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listInstances with error', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listInstances = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listInstances(request), expectedError); - const actualRequest = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listInstances as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listInstancesStream with error', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.ListInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.ListInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listInstances.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listInstancesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.licensemanager.v1.Instance[] = []; + stream.on( + 'data', + (response: protos.google.cloud.licensemanager.v1.Instance) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listInstances.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listInstances, request), + ); + assert( + (client.descriptors.page.listInstances.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listInstancesStream without error', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.licensemanager.v1.Instance()), - generateSampleMessage(new protos.google.cloud.licensemanager.v1.Instance()), - generateSampleMessage(new protos.google.cloud.licensemanager.v1.Instance()), - ]; - client.descriptors.page.listInstances.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listInstancesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.licensemanager.v1.Instance[] = []; - stream.on('data', (response: protos.google.cloud.licensemanager.v1.Instance) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listInstances.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listInstances, request)); - assert( - (client.descriptors.page.listInstances.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listInstances without error', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.ListInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.ListInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.licensemanager.v1.Instance(), + ), + generateSampleMessage( + new protos.google.cloud.licensemanager.v1.Instance(), + ), + generateSampleMessage( + new protos.google.cloud.licensemanager.v1.Instance(), + ), + ]; + client.descriptors.page.listInstances.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.licensemanager.v1.IInstance[] = []; + const iterable = client.listInstancesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listInstances.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listInstances.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listInstancesStream with error', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listInstances.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listInstancesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.licensemanager.v1.Instance[] = []; - stream.on('data', (response: protos.google.cloud.licensemanager.v1.Instance) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listInstances.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listInstances, request)); - assert( - (client.descriptors.page.listInstances.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listInstances with error', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.ListInstancesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.ListInstancesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listInstances.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listInstancesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.licensemanager.v1.IInstance[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listInstances.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listInstances.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('aggregateUsage', () => { + it('invokes aggregateUsage without error', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.AggregateUsageRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.AggregateUsageRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.licensemanager.v1.Usage(), + ), + generateSampleMessage( + new protos.google.cloud.licensemanager.v1.Usage(), + ), + generateSampleMessage( + new protos.google.cloud.licensemanager.v1.Usage(), + ), + ]; + client.innerApiCalls.aggregateUsage = stubSimpleCall(expectedResponse); + const [response] = await client.aggregateUsage(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.aggregateUsage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.aggregateUsage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listInstances without error', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.licensemanager.v1.Instance()), - generateSampleMessage(new protos.google.cloud.licensemanager.v1.Instance()), - generateSampleMessage(new protos.google.cloud.licensemanager.v1.Instance()), - ]; - client.descriptors.page.listInstances.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.licensemanager.v1.IInstance[] = []; - const iterable = client.listInstancesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes aggregateUsage without error using callback', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.AggregateUsageRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.AggregateUsageRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.licensemanager.v1.Usage(), + ), + generateSampleMessage( + new protos.google.cloud.licensemanager.v1.Usage(), + ), + generateSampleMessage( + new protos.google.cloud.licensemanager.v1.Usage(), + ), + ]; + client.innerApiCalls.aggregateUsage = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.aggregateUsage( + request, + ( + err?: Error | null, + result?: protos.google.cloud.licensemanager.v1.IUsage[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listInstances.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listInstances.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listInstances with error', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.ListInstancesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.ListInstancesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listInstances.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listInstancesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.licensemanager.v1.IInstance[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listInstances.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listInstances.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.aggregateUsage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.aggregateUsage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('aggregateUsage', () => { - it('invokes aggregateUsage without error', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.AggregateUsageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.AggregateUsageRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.licensemanager.v1.Usage()), - generateSampleMessage(new protos.google.cloud.licensemanager.v1.Usage()), - generateSampleMessage(new protos.google.cloud.licensemanager.v1.Usage()), - ]; - client.innerApiCalls.aggregateUsage = stubSimpleCall(expectedResponse); - const [response] = await client.aggregateUsage(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.aggregateUsage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.aggregateUsage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes aggregateUsage with error', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.AggregateUsageRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.AggregateUsageRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.aggregateUsage = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.aggregateUsage(request), expectedError); + const actualRequest = ( + client.innerApiCalls.aggregateUsage as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.aggregateUsage as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes aggregateUsage without error using callback', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.AggregateUsageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.AggregateUsageRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.licensemanager.v1.Usage()), - generateSampleMessage(new protos.google.cloud.licensemanager.v1.Usage()), - generateSampleMessage(new protos.google.cloud.licensemanager.v1.Usage()), - ]; - client.innerApiCalls.aggregateUsage = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.aggregateUsage( - request, - (err?: Error|null, result?: protos.google.cloud.licensemanager.v1.IUsage[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.aggregateUsage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.aggregateUsage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes aggregateUsageStream without error', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.AggregateUsageRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.AggregateUsageRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.licensemanager.v1.Usage(), + ), + generateSampleMessage( + new protos.google.cloud.licensemanager.v1.Usage(), + ), + generateSampleMessage( + new protos.google.cloud.licensemanager.v1.Usage(), + ), + ]; + client.descriptors.page.aggregateUsage.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.aggregateUsageStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.licensemanager.v1.Usage[] = []; + stream.on( + 'data', + (response: protos.google.cloud.licensemanager.v1.Usage) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.aggregateUsage.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.aggregateUsage, request), + ); + assert( + (client.descriptors.page.aggregateUsage.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes aggregateUsage with error', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.AggregateUsageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.AggregateUsageRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.aggregateUsage = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.aggregateUsage(request), expectedError); - const actualRequest = (client.innerApiCalls.aggregateUsage as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.aggregateUsage as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes aggregateUsageStream with error', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.AggregateUsageRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.AggregateUsageRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.aggregateUsage.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.aggregateUsageStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.licensemanager.v1.Usage[] = []; + stream.on( + 'data', + (response: protos.google.cloud.licensemanager.v1.Usage) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.aggregateUsage.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.aggregateUsage, request), + ); + assert( + (client.descriptors.page.aggregateUsage.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes aggregateUsageStream without error', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.AggregateUsageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.AggregateUsageRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.licensemanager.v1.Usage()), - generateSampleMessage(new protos.google.cloud.licensemanager.v1.Usage()), - generateSampleMessage(new protos.google.cloud.licensemanager.v1.Usage()), - ]; - client.descriptors.page.aggregateUsage.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.aggregateUsageStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.licensemanager.v1.Usage[] = []; - stream.on('data', (response: protos.google.cloud.licensemanager.v1.Usage) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.aggregateUsage.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.aggregateUsage, request)); - assert( - (client.descriptors.page.aggregateUsage.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with aggregateUsage without error', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.AggregateUsageRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.AggregateUsageRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.licensemanager.v1.Usage(), + ), + generateSampleMessage( + new protos.google.cloud.licensemanager.v1.Usage(), + ), + generateSampleMessage( + new protos.google.cloud.licensemanager.v1.Usage(), + ), + ]; + client.descriptors.page.aggregateUsage.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.licensemanager.v1.IUsage[] = []; + const iterable = client.aggregateUsageAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.aggregateUsage.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.aggregateUsage.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes aggregateUsageStream with error', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.AggregateUsageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.AggregateUsageRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.aggregateUsage.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.aggregateUsageStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.licensemanager.v1.Usage[] = []; - stream.on('data', (response: protos.google.cloud.licensemanager.v1.Usage) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.aggregateUsage.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.aggregateUsage, request)); - assert( - (client.descriptors.page.aggregateUsage.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with aggregateUsage with error', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.AggregateUsageRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.AggregateUsageRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.aggregateUsage.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.aggregateUsageAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.licensemanager.v1.IUsage[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.aggregateUsage.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.aggregateUsage.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listProducts', () => { + it('invokes listProducts without error', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.ListProductsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.ListProductsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.licensemanager.v1.Product(), + ), + generateSampleMessage( + new protos.google.cloud.licensemanager.v1.Product(), + ), + generateSampleMessage( + new protos.google.cloud.licensemanager.v1.Product(), + ), + ]; + client.innerApiCalls.listProducts = stubSimpleCall(expectedResponse); + const [response] = await client.listProducts(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with aggregateUsage without error', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.AggregateUsageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.AggregateUsageRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.licensemanager.v1.Usage()), - generateSampleMessage(new protos.google.cloud.licensemanager.v1.Usage()), - generateSampleMessage(new protos.google.cloud.licensemanager.v1.Usage()), - ]; - client.descriptors.page.aggregateUsage.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.licensemanager.v1.IUsage[] = []; - const iterable = client.aggregateUsageAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listProducts without error using callback', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.ListProductsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.ListProductsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.licensemanager.v1.Product(), + ), + generateSampleMessage( + new protos.google.cloud.licensemanager.v1.Product(), + ), + generateSampleMessage( + new protos.google.cloud.licensemanager.v1.Product(), + ), + ]; + client.innerApiCalls.listProducts = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listProducts( + request, + ( + err?: Error | null, + result?: protos.google.cloud.licensemanager.v1.IProduct[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.aggregateUsage.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.aggregateUsage.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with aggregateUsage with error', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.AggregateUsageRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.AggregateUsageRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.aggregateUsage.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.aggregateUsageAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.licensemanager.v1.IUsage[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.aggregateUsage.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.aggregateUsage.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.listProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listProducts', () => { - it('invokes listProducts without error', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.licensemanager.v1.Product()), - generateSampleMessage(new protos.google.cloud.licensemanager.v1.Product()), - generateSampleMessage(new protos.google.cloud.licensemanager.v1.Product()), - ]; - client.innerApiCalls.listProducts = stubSimpleCall(expectedResponse); - const [response] = await client.listProducts(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProducts without error using callback', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.licensemanager.v1.Product()), - generateSampleMessage(new protos.google.cloud.licensemanager.v1.Product()), - generateSampleMessage(new protos.google.cloud.licensemanager.v1.Product()), - ]; - client.innerApiCalls.listProducts = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listProducts( - request, - (err?: Error|null, result?: protos.google.cloud.licensemanager.v1.IProduct[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listProducts with error', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listProducts = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listProducts(request), expectedError); - const actualRequest = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listProducts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listProducts with error', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.ListProductsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.ListProductsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listProducts = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listProducts(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listProducts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listProductsStream without error', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.licensemanager.v1.Product()), - generateSampleMessage(new protos.google.cloud.licensemanager.v1.Product()), - generateSampleMessage(new protos.google.cloud.licensemanager.v1.Product()), - ]; - client.descriptors.page.listProducts.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listProductsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.licensemanager.v1.Product[] = []; - stream.on('data', (response: protos.google.cloud.licensemanager.v1.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); - assert( - (client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listProductsStream without error', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.ListProductsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.ListProductsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.licensemanager.v1.Product(), + ), + generateSampleMessage( + new protos.google.cloud.licensemanager.v1.Product(), + ), + generateSampleMessage( + new protos.google.cloud.licensemanager.v1.Product(), + ), + ]; + client.descriptors.page.listProducts.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listProductsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.licensemanager.v1.Product[] = []; + stream.on( + 'data', + (response: protos.google.cloud.licensemanager.v1.Product) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listProducts, request), + ); + assert( + (client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listProductsStream with error', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listProducts.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listProductsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.licensemanager.v1.Product[] = []; - stream.on('data', (response: protos.google.cloud.licensemanager.v1.Product) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listProducts, request)); - assert( - (client.descriptors.page.listProducts.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listProductsStream with error', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.ListProductsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.ListProductsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProducts.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listProductsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.licensemanager.v1.Product[] = []; + stream.on( + 'data', + (response: protos.google.cloud.licensemanager.v1.Product) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listProducts, request), + ); + assert( + (client.descriptors.page.listProducts.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listProducts without error', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.licensemanager.v1.Product()), - generateSampleMessage(new protos.google.cloud.licensemanager.v1.Product()), - generateSampleMessage(new protos.google.cloud.licensemanager.v1.Product()), - ]; - client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.licensemanager.v1.IProduct[] = []; - const iterable = client.listProductsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listProducts without error', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.ListProductsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.ListProductsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.licensemanager.v1.Product(), + ), + generateSampleMessage( + new protos.google.cloud.licensemanager.v1.Product(), + ), + generateSampleMessage( + new protos.google.cloud.licensemanager.v1.Product(), + ), + ]; + client.descriptors.page.listProducts.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.licensemanager.v1.IProduct[] = []; + const iterable = client.listProductsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listProducts.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listProducts.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listProducts with error', async () => { - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.licensemanager.v1.ListProductsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.licensemanager.v1.ListProductsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listProducts.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listProductsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.licensemanager.v1.IProduct[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listProducts.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listProducts with error', async () => { + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.licensemanager.v1.ListProductsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.licensemanager.v1.ListProductsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listProducts.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listProductsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.licensemanager.v1.IProduct[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listProducts.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listProducts.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 licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - 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 licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - 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 licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - 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 licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + 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 licensemanagerModule.v1.LicenseManagerClient({ - 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 licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + 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 licensemanagerModule.v1.LicenseManagerClient({ - 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 licensemanagerModule.v1.LicenseManagerClient({ - 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 licensemanagerModule.v1.LicenseManagerClient({ - 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 licensemanagerModule.v1.LicenseManagerClient({ - 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 licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + 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 licensemanagerModule.v1.LicenseManagerClient({ - 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 licensemanagerModule.v1.LicenseManagerClient({ - 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 licensemanagerModule.v1.LicenseManagerClient({ - 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 licensemanagerModule.v1.LicenseManagerClient({ + 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 licensemanagerModule.v1.LicenseManagerClient({ - 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 licensemanagerModule.v1.LicenseManagerClient({ - 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 licensemanagerModule.v1.LicenseManagerClient({ - 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 licensemanagerModule.v1.LicenseManagerClient({ + 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 licensemanagerModule.v1.LicenseManagerClient({ - 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 licensemanagerModule.v1.LicenseManagerClient({ - 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 licensemanagerModule.v1.LicenseManagerClient({ + 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 licensemanagerModule.v1.LicenseManagerClient({ + 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 licensemanagerModule.v1.LicenseManagerClient({ + 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 licensemanagerModule.v1.LicenseManagerClient({ + 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 licensemanagerModule.v1.LicenseManagerClient({ + 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 licensemanagerModule.v1.LicenseManagerClient({ + 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 licensemanagerModule.v1.LicenseManagerClient({ + 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 licensemanagerModule.v1.LicenseManagerClient({ + 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 licensemanagerModule.v1.LicenseManagerClient({ + 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 licensemanagerModule.v1.LicenseManagerClient({ + 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 licensemanagerModule.v1.LicenseManagerClient({ + 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('configuration', async () => { + const fakePath = '/rendered/path/configuration'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + configuration: 'configurationValue', + }; + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.configurationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.configurationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('configurationPath', () => { + const result = client.configurationPath( + 'projectValue', + 'locationValue', + 'configurationValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.configurationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromConfigurationName', () => { + const result = client.matchProjectFromConfigurationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.configurationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromConfigurationName', () => { + const result = client.matchLocationFromConfigurationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.configurationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchConfigurationFromConfigurationName', () => { + const result = client.matchConfigurationFromConfigurationName(fakePath); + assert.strictEqual(result, 'configurationValue'); + assert( + (client.pathTemplates.configurationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); - describe('Path templates', () => { - - describe('configuration', async () => { - const fakePath = "/rendered/path/configuration"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - configuration: "configurationValue", - }; - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.configurationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.configurationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('configurationPath', () => { - const result = client.configurationPath("projectValue", "locationValue", "configurationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.configurationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromConfigurationName', () => { - const result = client.matchProjectFromConfigurationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.configurationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromConfigurationName', () => { - const result = client.matchLocationFromConfigurationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.configurationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchConfigurationFromConfigurationName', () => { - const result = client.matchConfigurationFromConfigurationName(fakePath); - assert.strictEqual(result, "configurationValue"); - assert((client.pathTemplates.configurationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('instance', async () => { - const fakePath = "/rendered/path/instance"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - instance: "instanceValue", - }; - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.instancePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.instancePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('instancePath', () => { - const result = client.instancePath("projectValue", "locationValue", "instanceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.instancePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromInstanceName', () => { - const result = client.matchProjectFromInstanceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromInstanceName', () => { - const result = client.matchLocationFromInstanceName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInstanceFromInstanceName', () => { - const result = client.matchInstanceFromInstanceName(fakePath); - assert.strictEqual(result, "instanceValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('instance', async () => { + const fakePath = '/rendered/path/instance'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + instance: 'instanceValue', + }; + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.instancePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.instancePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('instancePath', () => { + const result = client.instancePath( + 'projectValue', + 'locationValue', + 'instanceValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.instancePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromInstanceName', () => { + const result = client.matchProjectFromInstanceName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromInstanceName', () => { + const result = client.matchLocationFromInstanceName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchInstanceFromInstanceName', () => { + const result = client.matchInstanceFromInstanceName(fakePath); + assert.strictEqual(result, 'instanceValue'); + assert( + (client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('location', async () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new licensemanagerModule.v1.LicenseManagerClient({ - 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 licensemanagerModule.v1.LicenseManagerClient({ + 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('product', async () => { - const fakePath = "/rendered/path/product"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - product: "productValue", - }; - const client = new licensemanagerModule.v1.LicenseManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.productPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.productPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('productPath', () => { - const result = client.productPath("projectValue", "locationValue", "productValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.productPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProductName', () => { - const result = client.matchProjectFromProductName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromProductName', () => { - const result = client.matchLocationFromProductName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchProductFromProductName', () => { - const result = client.matchProductFromProductName(fakePath); - assert.strictEqual(result, "productValue"); - assert((client.pathTemplates.productPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('product', async () => { + const fakePath = '/rendered/path/product'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + product: 'productValue', + }; + const client = new licensemanagerModule.v1.LicenseManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.productPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.productPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('productPath', () => { + const result = client.productPath( + 'projectValue', + 'locationValue', + 'productValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.productPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProductName', () => { + const result = client.matchProjectFromProductName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromProductName', () => { + const result = client.matchLocationFromProductName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchProductFromProductName', () => { + const result = client.matchProductFromProductName(fakePath); + assert.strictEqual(result, 'productValue'); + assert( + (client.pathTemplates.productPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('project', async () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new licensemanagerModule.v1.LicenseManagerClient({ - 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 licensemanagerModule.v1.LicenseManagerClient({ + 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-licensemanager/webpack.config.js b/packages/google-cloud-licensemanager/webpack.config.js index 5f8fcc338cdd..8f066e365205 100644 --- a/packages/google-cloud-licensemanager/webpack.config.js +++ b/packages/google-cloud-licensemanager/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-lifesciences/.eslintignore b/packages/google-cloud-lifesciences/.eslintignore new file mode 100644 index 000000000000..cfc348ec4d11 --- /dev/null +++ b/packages/google-cloud-lifesciences/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/packages/google-cloud-lifesciences/.eslintrc.json b/packages/google-cloud-lifesciences/.eslintrc.json new file mode 100644 index 000000000000..3e8d97ccb390 --- /dev/null +++ b/packages/google-cloud-lifesciences/.eslintrc.json @@ -0,0 +1,4 @@ +{ + "extends": "./node_modules/gts", + "root": true +} diff --git a/packages/google-cloud-lifesciences/README.md b/packages/google-cloud-lifesciences/README.md index d56893490c01..2af6921064fd 100644 --- a/packages/google-cloud-lifesciences/README.md +++ b/packages/google-cloud-lifesciences/README.md @@ -92,7 +92,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-lifesciences/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`) @@ -102,7 +102,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-lifesciences/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-lifesciences/protos/protos.d.ts b/packages/google-cloud-lifesciences/protos/protos.d.ts index 689a514ac505..240ebdf3da73 100644 --- a/packages/google-cloud-lifesciences/protos/protos.d.ts +++ b/packages/google-cloud-lifesciences/protos/protos.d.ts @@ -3665,6 +3665,9 @@ export namespace google { /** CommonLanguageSettings destinations */ destinations?: (google.api.ClientLibraryDestination[]|null); + + /** CommonLanguageSettings selectiveGapicGeneration */ + selectiveGapicGeneration?: (google.api.ISelectiveGapicGeneration|null); } /** Represents a CommonLanguageSettings. */ @@ -3682,6 +3685,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 @@ -4382,6 +4388,9 @@ export namespace google { /** PythonSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** PythonSettings experimentalFeatures */ + experimentalFeatures?: (google.api.PythonSettings.IExperimentalFeatures|null); } /** Represents a PythonSettings. */ @@ -4396,6 +4405,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 @@ -4474,6 +4486,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 { @@ -4800,6 +4924,9 @@ export namespace google { /** GoSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** GoSettings renamedServices */ + renamedServices?: ({ [k: string]: string }|null); } /** Represents a GoSettings. */ @@ -4814,6 +4941,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 @@ -5138,6 +5268,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, @@ -5267,6 +5500,7 @@ export namespace google { /** Edition enum. */ enum Edition { EDITION_UNKNOWN = 0, + EDITION_LEGACY = 900, EDITION_PROTO2 = 998, EDITION_PROTO3 = 999, EDITION_2023 = 1000, @@ -5297,6 +5531,9 @@ export namespace google { /** FileDescriptorProto weakDependency */ weakDependency?: (number[]|null); + /** FileDescriptorProto optionDependency */ + optionDependency?: (string[]|null); + /** FileDescriptorProto messageType */ messageType?: (google.protobuf.IDescriptorProto[]|null); @@ -5346,6 +5583,9 @@ export namespace google { /** FileDescriptorProto weakDependency. */ public weakDependency: number[]; + /** FileDescriptorProto optionDependency. */ + public optionDependency: string[]; + /** FileDescriptorProto messageType. */ public messageType: google.protobuf.IDescriptorProto[]; @@ -5480,6 +5720,9 @@ export namespace google { /** DescriptorProto reservedName */ reservedName?: (string[]|null); + + /** DescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents a DescriptorProto. */ @@ -5521,6 +5764,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 @@ -6368,6 +6614,9 @@ export namespace google { /** EnumDescriptorProto reservedName */ reservedName?: (string[]|null); + + /** EnumDescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents an EnumDescriptorProto. */ @@ -6394,6 +6643,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 @@ -7322,6 +7574,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); @@ -7374,6 +7629,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[]; @@ -7594,6 +7852,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. */ @@ -7832,6 +8205,9 @@ export namespace google { /** EnumValueOptions debugRedact */ debugRedact?: (boolean|null); + /** EnumValueOptions featureSupport */ + featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** EnumValueOptions uninterpretedOption */ uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); } @@ -7854,6 +8230,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[]; @@ -8446,6 +8825,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. */ @@ -8475,6 +8860,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 @@ -8597,6 +8988,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. */ @@ -8716,8 +9217,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. */ @@ -8732,8 +9236,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. @@ -9266,6 +9773,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-lifesciences/protos/protos.js b/packages/google-cloud-lifesciences/protos/protos.js index 535e111dfd16..2441fe375e7c 100644 --- a/packages/google-cloud-lifesciences/protos/protos.js +++ b/packages/google-cloud-lifesciences/protos/protos.js @@ -9679,6 +9679,7 @@ * @interface ICommonLanguageSettings * @property {string|null} [referenceDocsUri] CommonLanguageSettings referenceDocsUri * @property {Array.|null} [destinations] CommonLanguageSettings destinations + * @property {google.api.ISelectiveGapicGeneration|null} [selectiveGapicGeneration] CommonLanguageSettings selectiveGapicGeneration */ /** @@ -9713,6 +9714,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 @@ -9745,6 +9754,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; }; @@ -9796,6 +9807,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; @@ -9847,6 +9862,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; }; @@ -9889,6 +9909,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; }; @@ -9907,8 +9932,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) { @@ -9916,6 +9943,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; }; @@ -11738,6 +11767,7 @@ * @memberof google.api * @interface IPythonSettings * @property {google.api.ICommonLanguageSettings|null} [common] PythonSettings common + * @property {google.api.PythonSettings.IExperimentalFeatures|null} [experimentalFeatures] PythonSettings experimentalFeatures */ /** @@ -11763,6 +11793,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 @@ -11789,6 +11827,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; }; @@ -11829,6 +11869,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; @@ -11869,6 +11913,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; }; @@ -11889,6 +11938,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; }; @@ -11905,10 +11959,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; }; @@ -11938,6 +11996,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; })(); @@ -12814,6 +13124,7 @@ * @memberof google.api * @interface IGoSettings * @property {google.api.ICommonLanguageSettings|null} [common] GoSettings common + * @property {Object.|null} [renamedServices] GoSettings renamedServices */ /** @@ -12825,6 +13136,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) @@ -12839,6 +13151,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 @@ -12865,6 +13185,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; }; @@ -12895,7 +13218,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) @@ -12905,6 +13228,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; @@ -12945,6 +13291,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; }; @@ -12965,6 +13319,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; }; @@ -12981,10 +13342,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; }; @@ -13623,29 +13992,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; })(); @@ -13920,6 +14534,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 @@ -13934,6 +14549,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; @@ -13958,6 +14574,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 @@ -13980,6 +14597,7 @@ this.dependency = []; this.publicDependency = []; this.weakDependency = []; + this.optionDependency = []; this.messageType = []; this.enumType = []; this.service = []; @@ -14030,6 +14648,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 @@ -14151,6 +14777,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; }; @@ -14223,6 +14852,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 = []; @@ -14325,6 +14960,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"; @@ -14379,6 +15021,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -14431,6 +15074,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"); @@ -14494,6 +15144,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -14559,6 +15213,7 @@ object.extension = []; object.publicDependency = []; object.weakDependency = []; + object.optionDependency = []; } if (options.defaults) { object.name = ""; @@ -14615,6 +15270,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; }; @@ -14663,6 +15323,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 */ /** @@ -14768,6 +15429,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 @@ -14820,6 +15489,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; }; @@ -14912,6 +15583,10 @@ message.reservedName.push(reader.string()); break; } + case 11: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -15025,6 +15700,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; }; @@ -15124,6 +15808,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; }; @@ -15153,6 +15857,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; @@ -15198,6 +15903,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; }; @@ -17242,6 +17949,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 */ /** @@ -17302,6 +18010,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 @@ -17339,6 +18055,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; }; @@ -17401,6 +18119,10 @@ message.reservedName.push(reader.string()); break; } + case 6: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -17469,6 +18191,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; }; @@ -17518,6 +18249,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; }; @@ -17542,6 +18293,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; @@ -17562,6 +18314,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; }; @@ -19807,6 +20561,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 */ @@ -19926,6 +20681,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 @@ -19992,6 +20755,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(); @@ -20091,6 +20856,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 = []; @@ -20222,6 +20991,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"; @@ -20405,6 +21179,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"); @@ -20497,6 +21276,7 @@ object.debugRedact = false; object.retention = options.enums === String ? "RETENTION_UNKNOWN" : 0; object.features = null; + object.featureSupport = null; } if (message.ctype != null && message.hasOwnProperty("ctype")) object.ctype = options.enums === String ? $root.google.protobuf.FieldOptions.CType[message.ctype] === undefined ? message.ctype : $root.google.protobuf.FieldOptions.CType[message.ctype] : message.ctype; @@ -20528,6 +21308,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) @@ -20798,6 +21580,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -20839,103 +21622,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; @@ -21530,6 +22799,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 */ @@ -21573,6 +22843,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 @@ -21611,6 +22889,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(); @@ -21662,6 +22942,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 = []; @@ -21714,6 +22998,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"; @@ -21747,6 +23036,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"); @@ -21779,6 +23073,7 @@ object.deprecated = false; object.features = null; object.debugRedact = false; + object.featureSupport = null; } if (message.deprecated != null && message.hasOwnProperty("deprecated")) object.deprecated = message.deprecated; @@ -21786,6 +23081,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) @@ -23253,6 +24550,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 */ /** @@ -23318,6 +24617,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 @@ -23354,6 +24669,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; }; @@ -23414,6 +24733,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; @@ -23504,6 +24831,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; }; @@ -23643,6 +24990,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; }; @@ -23666,6 +25061,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; @@ -23679,6 +25076,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; }; @@ -23806,6 +25207,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; })(); @@ -23990,6 +25604,7 @@ default: return "minimumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -24007,6 +25622,7 @@ default: return "maximumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -24055,6 +25671,10 @@ case 0: message.minimumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.minimumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.minimumEdition = 998; @@ -24107,6 +25727,10 @@ case 0: message.maximumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.maximumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.maximumEdition = 998; @@ -24215,7 +25839,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 */ /** @@ -24242,12 +25867,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. @@ -24273,10 +25906,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; }; @@ -24317,8 +25952,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: @@ -24361,6 +26000,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -24373,10 +26013,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; }; @@ -24404,6 +26049,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -24445,10 +26094,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; }; @@ -24467,13 +26121,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; }; @@ -25688,6 +27345,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-lifesciences/protos/protos.json b/packages/google-cloud-lifesciences/protos/protos.json index 4dc024280120..136ea03d54fb 100644 --- a/packages/google-cloud-lifesciences/protos/protos.json +++ b/packages/google-cloud-lifesciences/protos/protos.json @@ -674,8 +674,7 @@ "java_multiple_files": true, "java_outer_classname": "FieldBehaviorProto", "java_package": "com.google.api", - "objc_class_prefix": "GAPI", - "cc_enable_arenas": true + "objc_class_prefix": "GAPI" }, "nested": { "http": { @@ -799,6 +798,10 @@ "rule": "repeated", "type": "ClientLibraryDestination", "id": 2 + }, + "selectiveGapicGeneration": { + "type": "SelectiveGapicGeneration", + "id": 3 } } }, @@ -939,6 +942,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 + } + } } } }, @@ -996,6 +1021,11 @@ "common": { "type": "CommonLanguageSettings", "id": 1 + }, + "renamedServices": { + "keyType": "string", + "type": "string", + "id": 2 } } }, @@ -1057,6 +1087,19 @@ "PACKAGE_MANAGER": 20 } }, + "SelectiveGapicGeneration": { + "fields": { + "methods": { + "rule": "repeated", + "type": "string", + "id": 1 + }, + "generateOmittedAsInternal": { + "type": "bool", + "id": 2 + } + } + }, "LaunchStage": { "values": { "LAUNCH_STAGE_UNSPECIFIED": 0, @@ -1112,12 +1155,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, @@ -1156,6 +1206,11 @@ "type": "int32", "id": 11 }, + "optionDependency": { + "rule": "repeated", + "type": "string", + "id": 15 + }, "messageType": { "rule": "repeated", "type": "DescriptorProto", @@ -1244,6 +1299,10 @@ "rule": "repeated", "type": "string", "id": 10 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 11 } }, "nested": { @@ -1469,6 +1528,10 @@ "rule": "repeated", "type": "string", "id": 5 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 6 } }, "nested": { @@ -1519,7 +1582,14 @@ "type": "ServiceOptions", "id": 3 } - } + }, + "reserved": [ + [ + 4, + 4 + ], + "stream" + ] }, "MethodDescriptorProto": { "edition": "proto2", @@ -1683,6 +1753,7 @@ 42, 42 ], + "php_generic_services", [ 38, 38 @@ -1818,7 +1889,8 @@ "type": "bool", "id": 10, "options": { - "default": false + "default": false, + "deprecated": true } }, "debugRedact": { @@ -1846,6 +1918,10 @@ "type": "FeatureSet", "id": 21 }, + "featureSupport": { + "type": "FeatureSupport", + "id": 22 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -1915,6 +1991,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 + } + } } } }, @@ -2003,6 +2099,10 @@ "default": false } }, + "featureSupport": { + "type": "FieldOptions.FeatureSupport", + "id": 4 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -2145,6 +2245,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_2023", "edition_defaults.value": "EXPLICIT" } @@ -2155,6 +2256,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "OPEN" } @@ -2165,6 +2267,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "PACKED" } @@ -2175,6 +2278,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "VERIFY" } @@ -2185,7 +2289,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" } }, @@ -2195,27 +2300,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, @@ -2260,7 +2376,13 @@ "UTF8_VALIDATION_UNKNOWN": 0, "VERIFY": 2, "NONE": 3 - } + }, + "reserved": [ + [ + 1, + 1 + ] + ] }, "MessageEncoding": { "values": { @@ -2275,6 +2397,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 + } + } + } } } }, @@ -2302,11 +2451,26 @@ "type": "Edition", "id": 3 }, - "features": { + "overridableFeatures": { "type": "FeatureSet", - "id": 2 + "id": 4 + }, + "fixedFeatures": { + "type": "FeatureSet", + "id": 5 } - } + }, + "reserved": [ + [ + 1, + 1 + ], + [ + 2, + 2 + ], + "features" + ] } } }, @@ -2319,6 +2483,12 @@ "id": 1 } }, + "extensions": [ + [ + 536000000, + 536000000 + ] + ], "nested": { "Location": { "fields": { @@ -2404,6 +2574,14 @@ } } }, + "SymbolVisibility": { + "edition": "proto2", + "values": { + "VISIBILITY_UNSET": 0, + "VISIBILITY_LOCAL": 1, + "VISIBILITY_EXPORT": 2 + } + }, "Duration": { "fields": { "seconds": { @@ -2453,6 +2631,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-lifesciences/samples/generated/v2beta/snippet_metadata_google.cloud.lifesciences.v2beta.json b/packages/google-cloud-lifesciences/samples/generated/v2beta/snippet_metadata_google.cloud.lifesciences.v2beta.json index 0710c5d1a402..3785dc98d684 100644 --- a/packages/google-cloud-lifesciences/samples/generated/v2beta/snippet_metadata_google.cloud.lifesciences.v2beta.json +++ b/packages/google-cloud-lifesciences/samples/generated/v2beta/snippet_metadata_google.cloud.lifesciences.v2beta.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-lifesciences", - "version": "4.2.1", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-lifesciences/src/v2beta/index.ts b/packages/google-cloud-lifesciences/src/v2beta/index.ts index 185759b57571..d3c5384cd760 100644 --- a/packages/google-cloud-lifesciences/src/v2beta/index.ts +++ b/packages/google-cloud-lifesciences/src/v2beta/index.ts @@ -16,4 +16,4 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {WorkflowsServiceV2BetaClient} from './workflows_service_v2_beta_client'; +export { WorkflowsServiceV2BetaClient } from './workflows_service_v2_beta_client'; diff --git a/packages/google-cloud-lifesciences/src/v2beta/workflows_service_v2_beta_client.ts b/packages/google-cloud-lifesciences/src/v2beta/workflows_service_v2_beta_client.ts index 7b4b1d25b439..3f167d23d614 100644 --- a/packages/google-cloud-lifesciences/src/v2beta/workflows_service_v2_beta_client.ts +++ b/packages/google-cloud-lifesciences/src/v2beta/workflows_service_v2_beta_client.ts @@ -18,11 +18,20 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, LocationsClient, LocationProtos} from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, + 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 @@ -45,7 +54,7 @@ export class WorkflowsServiceV2BetaClient { 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('life-sciences'); @@ -58,10 +67,10 @@ export class WorkflowsServiceV2BetaClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; locationsClient: LocationsClient; operationsClient: gax.OperationsClient; - workflowsServiceV2BetaStub?: Promise<{[name: string]: Function}>; + workflowsServiceV2BetaStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of WorkflowsServiceV2BetaClient. @@ -102,21 +111,43 @@ export class WorkflowsServiceV2BetaClient { * const client = new WorkflowsServiceV2BetaClient({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 WorkflowsServiceV2BetaClient; - 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 WorkflowsServiceV2BetaClient; + 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 = 'lifesciences.' + 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 +172,7 @@ export class WorkflowsServiceV2BetaClient { 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 +186,11 @@ export class WorkflowsServiceV2BetaClient { } 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 { @@ -186,29 +213,59 @@ export class WorkflowsServiceV2BetaClient { // 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: '/v2beta/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v2beta/{name=projects/*}/locations',},{selector: 'google.longrunning.Operations.CancelOperation',post: '/v2beta/{name=projects/*/locations/*/operations/*}:cancel',body: '*',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v2beta/{name=projects/*/locations/*/operations/*}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v2beta/{name=projects/*/locations/*}/operations',}]; + lroOptions.httpRules = [ + { + selector: 'google.cloud.location.Locations.GetLocation', + get: '/v2beta/{name=projects/*/locations/*}', + }, + { + selector: 'google.cloud.location.Locations.ListLocations', + get: '/v2beta/{name=projects/*}/locations', + }, + { + selector: 'google.longrunning.Operations.CancelOperation', + post: '/v2beta/{name=projects/*/locations/*/operations/*}:cancel', + body: '*', + }, + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v2beta/{name=projects/*/locations/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v2beta/{name=projects/*/locations/*}/operations', + }, + ]; } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); const runPipelineResponse = protoFilesRoot.lookup( - '.google.cloud.lifesciences.v2beta.RunPipelineResponse') as gax.protobuf.Type; + '.google.cloud.lifesciences.v2beta.RunPipelineResponse', + ) as gax.protobuf.Type; const runPipelineMetadata = protoFilesRoot.lookup( - '.google.cloud.lifesciences.v2beta.Metadata') as gax.protobuf.Type; + '.google.cloud.lifesciences.v2beta.Metadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { runPipeline: new this._gaxModule.LongrunningDescriptor( this.operationsClient, runPipelineResponse.decode.bind(runPipelineResponse), - runPipelineMetadata.decode.bind(runPipelineMetadata)) + runPipelineMetadata.decode.bind(runPipelineMetadata), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.lifesciences.v2beta.WorkflowsServiceV2Beta', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.lifesciences.v2beta.WorkflowsServiceV2Beta', + 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 +296,41 @@ export class WorkflowsServiceV2BetaClient { // Put together the "service stub" for // google.cloud.lifesciences.v2beta.WorkflowsServiceV2Beta. this.workflowsServiceV2BetaStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.lifesciences.v2beta.WorkflowsServiceV2Beta') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.lifesciences.v2beta.WorkflowsServiceV2Beta, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.lifesciences.v2beta.WorkflowsServiceV2Beta', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.lifesciences.v2beta + .WorkflowsServiceV2Beta, + 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 workflowsServiceV2BetaStubMethods = - ['runPipeline']; + const workflowsServiceV2BetaStubMethods = ['runPipeline']; for (const methodName of workflowsServiceV2BetaStubMethods) { const callPromise = this.workflowsServiceV2BetaStub.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; @@ -284,8 +345,14 @@ export class WorkflowsServiceV2BetaClient { * @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 'lifesciences.googleapis.com'; } @@ -296,8 +363,14 @@ export class WorkflowsServiceV2BetaClient { * @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 'lifesciences.googleapis.com'; } @@ -328,9 +401,7 @@ export class WorkflowsServiceV2BetaClient { * @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 +410,9 @@ export class WorkflowsServiceV2BetaClient { * 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,144 +424,207 @@ export class WorkflowsServiceV2BetaClient { // -- Service calls -- // ------------------- -/** - * Runs a pipeline. The returned Operation's [metadata] - * [google.longrunning.Operation.metadata] field will contain a - * {@link protos.google.cloud.lifesciences.v2beta.Metadata|google.cloud.lifesciences.v2beta.Metadata} - * object describing the status of the pipeline execution. The - * {@link protos.google.longrunning.Operation.response|response} field will contain a - * {@link protos.google.cloud.lifesciences.v2beta.RunPipelineResponse|google.cloud.lifesciences.v2beta.RunPipelineResponse} - * object if the pipeline completes successfully. - * - * **Note:** Before you can use this method, the *Life Sciences Service Agent* - * must have access to your project. This is done automatically when the - * Cloud Life Sciences API is first enabled, but if you delete this permission - * you must disable and re-enable the API to grant the Life Sciences - * Service Agent the required permissions. - * Authorization requires the following [Google - * IAM](https://cloud.google.com/iam/) permission: - * - * * `lifesciences.workflows.run` - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * The project and location that this request should be executed against. - * @param {google.cloud.lifesciences.v2beta.Pipeline} request.pipeline - * Required. The description of the pipeline to run. - * @param {number[]} request.labels - * User-defined labels to associate with the returned operation. These - * labels are not propagated to any Google Cloud Platform resources used by - * the operation, and can be modified at any time. - * - * To associate labels with resources created while executing the operation, - * see the appropriate resource message (for example, `VirtualMachine`). - * @param {string} request.pubSubTopic - * The name of an existing Pub/Sub topic. The server will publish - * messages to this topic whenever the status of the operation changes. - * The Life Sciences Service Agent account must have publisher permissions to - * the specified topic or notifications will not be sent. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v2beta/workflows_service_v2_beta.run_pipeline.js - * region_tag:lifesciences_v2beta_generated_WorkflowsServiceV2Beta_RunPipeline_async - */ + /** + * Runs a pipeline. The returned Operation's [metadata] + * [google.longrunning.Operation.metadata] field will contain a + * {@link protos.google.cloud.lifesciences.v2beta.Metadata|google.cloud.lifesciences.v2beta.Metadata} + * object describing the status of the pipeline execution. The + * {@link protos.google.longrunning.Operation.response|response} field will contain a + * {@link protos.google.cloud.lifesciences.v2beta.RunPipelineResponse|google.cloud.lifesciences.v2beta.RunPipelineResponse} + * object if the pipeline completes successfully. + * + * **Note:** Before you can use this method, the *Life Sciences Service Agent* + * must have access to your project. This is done automatically when the + * Cloud Life Sciences API is first enabled, but if you delete this permission + * you must disable and re-enable the API to grant the Life Sciences + * Service Agent the required permissions. + * Authorization requires the following [Google + * IAM](https://cloud.google.com/iam/) permission: + * + * * `lifesciences.workflows.run` + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * The project and location that this request should be executed against. + * @param {google.cloud.lifesciences.v2beta.Pipeline} request.pipeline + * Required. The description of the pipeline to run. + * @param {number[]} request.labels + * User-defined labels to associate with the returned operation. These + * labels are not propagated to any Google Cloud Platform resources used by + * the operation, and can be modified at any time. + * + * To associate labels with resources created while executing the operation, + * see the appropriate resource message (for example, `VirtualMachine`). + * @param {string} request.pubSubTopic + * The name of an existing Pub/Sub topic. The server will publish + * messages to this topic whenever the status of the operation changes. + * The Life Sciences Service Agent account must have publisher permissions to + * the specified topic or notifications will not be sent. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v2beta/workflows_service_v2_beta.run_pipeline.js + * region_tag:lifesciences_v2beta_generated_WorkflowsServiceV2Beta_RunPipeline_async + */ runPipeline( - request?: protos.google.cloud.lifesciences.v2beta.IRunPipelineRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.lifesciences.v2beta.IRunPipelineRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.lifesciences.v2beta.IRunPipelineResponse, + protos.google.cloud.lifesciences.v2beta.IMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; runPipeline( - request: protos.google.cloud.lifesciences.v2beta.IRunPipelineRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.lifesciences.v2beta.IRunPipelineRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.lifesciences.v2beta.IRunPipelineResponse, + protos.google.cloud.lifesciences.v2beta.IMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; runPipeline( - request: protos.google.cloud.lifesciences.v2beta.IRunPipelineRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.lifesciences.v2beta.IRunPipelineRequest, + callback: Callback< + LROperation< + protos.google.cloud.lifesciences.v2beta.IRunPipelineResponse, + protos.google.cloud.lifesciences.v2beta.IMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; runPipeline( - request?: protos.google.cloud.lifesciences.v2beta.IRunPipelineRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.lifesciences.v2beta.IRunPipelineRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.lifesciences.v2beta.IRunPipelineResponse, + protos.google.cloud.lifesciences.v2beta.IMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.lifesciences.v2beta.IRunPipelineResponse, + protos.google.cloud.lifesciences.v2beta.IMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.lifesciences.v2beta.IRunPipelineResponse, + protos.google.cloud.lifesciences.v2beta.IMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-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.lifesciences.v2beta.IRunPipelineResponse, + protos.google.cloud.lifesciences.v2beta.IMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('runPipeline response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('runPipeline request %j', request); - return this.innerApiCalls.runPipeline(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('runPipeline response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .runPipeline(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.lifesciences.v2beta.IRunPipelineResponse, + protos.google.cloud.lifesciences.v2beta.IMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('runPipeline response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `runPipeline()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v2beta/workflows_service_v2_beta.run_pipeline.js - * region_tag:lifesciences_v2beta_generated_WorkflowsServiceV2Beta_RunPipeline_async - */ - async checkRunPipelineProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `runPipeline()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v2beta/workflows_service_v2_beta.run_pipeline.js + * region_tag:lifesciences_v2beta_generated_WorkflowsServiceV2Beta_RunPipeline_async + */ + async checkRunPipelineProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.lifesciences.v2beta.RunPipelineResponse, + protos.google.cloud.lifesciences.v2beta.Metadata + > + > { this._log.info('runPipeline long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.runPipeline, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.runPipeline, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.lifesciences.v2beta.RunPipelineResponse, + protos.google.cloud.lifesciences.v2beta.Metadata + >; } -/** + + /** * Gets information about a location. * * @param {Object} request @@ -524,12 +659,11 @@ export class WorkflowsServiceV2BetaClient { | 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. @@ -562,12 +696,12 @@ export class WorkflowsServiceV2BetaClient { */ 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. @@ -610,22 +744,22 @@ export class WorkflowsServiceV2BetaClient { 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); } /** @@ -660,15 +794,15 @@ export class WorkflowsServiceV2BetaClient { */ 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); } /** @@ -702,7 +836,7 @@ export class WorkflowsServiceV2BetaClient { * await client.cancelOperation({name: ''}); * ``` */ - cancelOperation( + cancelOperation( request: protos.google.longrunning.CancelOperationRequest, optionsOrCallback?: | gax.CallOptions @@ -715,25 +849,24 @@ export class WorkflowsServiceV2BetaClient { 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 @@ -772,26 +905,25 @@ export class WorkflowsServiceV2BetaClient { 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); } - /** * Terminate the gRPC channel and close the client. * @@ -800,14 +932,16 @@ export class WorkflowsServiceV2BetaClient { */ close(): Promise { if (this.workflowsServiceV2BetaStub && !this._terminated) { - return this.workflowsServiceV2BetaStub.then(stub => { + return this.workflowsServiceV2BetaStub.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-lifesciences/system-test/fixtures/sample/src/index.ts b/packages/google-cloud-lifesciences/system-test/fixtures/sample/src/index.ts index 4ac75c4d74ea..299c4b1c1dbf 100644 --- a/packages/google-cloud-lifesciences/system-test/fixtures/sample/src/index.ts +++ b/packages/google-cloud-lifesciences/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 {WorkflowsServiceV2BetaClient} from '@google-cloud/life-sciences'; +import { WorkflowsServiceV2BetaClient } from '@google-cloud/life-sciences'; // check that the client class type name can be used -function doStuffWithWorkflowsServiceV2BetaClient(client: WorkflowsServiceV2BetaClient) { +function doStuffWithWorkflowsServiceV2BetaClient( + client: WorkflowsServiceV2BetaClient, +) { client.close(); } diff --git a/packages/google-cloud-lifesciences/system-test/install.ts b/packages/google-cloud-lifesciences/system-test/install.ts index f66069aa3940..ccf167042d2e 100644 --- a/packages/google-cloud-lifesciences/system-test/install.ts +++ b/packages/google-cloud-lifesciences/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-lifesciences/test/gapic_workflows_service_v2_beta_v2beta.ts b/packages/google-cloud-lifesciences/test/gapic_workflows_service_v2_beta_v2beta.ts index 7510dba84de6..8650c53da6e2 100644 --- a/packages/google-cloud-lifesciences/test/gapic_workflows_service_v2_beta_v2beta.ts +++ b/packages/google-cloud-lifesciences/test/gapic_workflows_service_v2_beta_v2beta.ts @@ -19,803 +19,1033 @@ 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 workflowsservicev2betaModule from '../src'; -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 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('v2beta.WorkflowsServiceV2BetaClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'lifesciences.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient(); - 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 = workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient.servicePath; - assert.strictEqual(servicePath, 'lifesciences.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'lifesciences.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'lifesciences.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'lifesciences.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 workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'lifesciences.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 workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'lifesciences.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 workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); - - it('has port', () => { - const port = workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.workflowsServiceV2BetaStub, undefined); - await client.initialize(); - assert(client.workflowsServiceV2BetaStub); - }); - - it('has close method for the initialized client', done => { - const client = new workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.workflowsServiceV2BetaStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); - - it('has close method for the non-initialized client', done => { - const client = new workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.workflowsServiceV2BetaStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ - 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 workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ - 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('runPipeline', () => { - it('invokes runPipeline without error', async () => { - const client = new workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.lifesciences.v2beta.RunPipelineRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.lifesciences.v2beta.RunPipelineRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.runPipeline = stubLongRunningCall(expectedResponse); - const [operation] = await client.runPipeline(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.runPipeline as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.runPipeline as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes runPipeline without error using callback', async () => { - const client = new workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.lifesciences.v2beta.RunPipelineRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.lifesciences.v2beta.RunPipelineRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.runPipeline = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.runPipeline( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.runPipeline as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.runPipeline as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes runPipeline with call error', async () => { - const client = new workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.lifesciences.v2beta.RunPipelineRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.lifesciences.v2beta.RunPipelineRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.runPipeline = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.runPipeline(request), expectedError); - const actualRequest = (client.innerApiCalls.runPipeline as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.runPipeline as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes runPipeline with LRO error', async () => { - const client = new workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.lifesciences.v2beta.RunPipelineRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.lifesciences.v2beta.RunPipelineRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.runPipeline = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.runPipeline(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.runPipeline as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.runPipeline as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkRunPipelineProgress without error', async () => { - const client = new workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkRunPipelineProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkRunPipelineProgress with error', async () => { - const client = new workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkRunPipelineProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - 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 workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - 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 workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - 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 workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = + new workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'lifesciences.googleapis.com'); + }); + + it('has universeDomain', () => { + const client = + new workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient(); + 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 = + workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient + .servicePath; + assert.strictEqual(servicePath, 'lifesciences.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient + .apiEndpoint; + assert.strictEqual(apiEndpoint, 'lifesciences.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = + new workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'lifesciences.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = + new workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'lifesciences.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 workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'lifesciences.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 workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient( + { universeDomain: 'configured.example.com' }, ); - 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 servicePath = client.apiEndpoint; + assert.strictEqual( + servicePath, + 'lifesciences.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 workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); + }); + + it('has port', () => { + const port = + workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = + new workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = + new workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = + new workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.workflowsServiceV2BetaStub, undefined); + await client.initialize(); + assert(client.workflowsServiceV2BetaStub); + }); + + it('has close method for the initialized client', (done) => { + const client = + new workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.workflowsServiceV2BetaStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; + }); + }); + + it('has close method for the non-initialized client', (done) => { + const client = + new workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.workflowsServiceV2BetaStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ + 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 workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ + 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('runPipeline', () => { + it('invokes runPipeline without error', async () => { + const client = + new workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.lifesciences.v2beta.RunPipelineRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.lifesciences.v2beta.RunPipelineRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.runPipeline = stubLongRunningCall(expectedResponse); + const [operation] = await client.runPipeline(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.runPipeline as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.runPipeline as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes runPipeline without error using callback', async () => { + const client = + new workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.lifesciences.v2beta.RunPipelineRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.lifesciences.v2beta.RunPipelineRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.runPipeline = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.runPipeline( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.lifesciences.v2beta.IRunPipelineResponse, + protos.google.cloud.lifesciences.v2beta.IMetadata + > | 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 - ) - ); + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.lifesciences.v2beta.IRunPipelineResponse, + protos.google.cloud.lifesciences.v2beta.IMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.runPipeline as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.runPipeline as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes runPipeline with call error', async () => { + const client = + new workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); - it('uses async iteration with listLocations with error', async () => { - const client = new workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ - 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 protos.google.cloud.lifesciences.v2beta.RunPipelineRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.lifesciences.v2beta.RunPipelineRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.runPipeline = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.runPipeline(request), expectedError); + const actualRequest = ( + client.innerApiCalls.runPipeline as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.runPipeline as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes runPipeline with LRO error', async () => { + const client = + new workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.lifesciences.v2beta.RunPipelineRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.lifesciences.v2beta.RunPipelineRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.runPipeline = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.runPipeline(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.runPipeline as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.runPipeline as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ - 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 checkRunPipelineProgress without error', async () => { + const client = + new workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); - it('invokes getOperation without error using callback', async () => { - const client = new workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ - 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 workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ - 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 workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ - 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) - ); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkRunPipelineProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkRunPipelineProgress with error', async () => { + const client = + new workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); - it('invokes cancelOperation without error using callback', async () => { - const client = new workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ - 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 workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ - 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 workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ - 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) - ); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkRunPipelineProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = + new workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); - it('invokes deleteOperation without error using callback', async () => { - const client = new workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ - 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 workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ - 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 workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ - 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!); + await client.initialize(); + 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 workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest(), + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location(), + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.IOperation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = + new workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + 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 workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ + 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 workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ + 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 workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ + 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 workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ + 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 workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ + 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 workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ + 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 workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ + 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 workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ + 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 workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ + 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 workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ + 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 workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ + 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 workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ + 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 workflowsservicev2betaModule.v2beta.WorkflowsServiceV2BetaClient({ + 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, + ); }); + }); }); diff --git a/packages/google-cloud-lifesciences/webpack.config.js b/packages/google-cloud-lifesciences/webpack.config.js index c1d3b4d52d48..e7f6079e4d21 100644 --- a/packages/google-cloud-lifesciences/webpack.config.js +++ b/packages/google-cloud-lifesciences/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-locationfinder/$1/.eslintignore b/packages/google-cloud-locationfinder/$1/.eslintignore new file mode 100644 index 000000000000..cfc348ec4d11 --- /dev/null +++ b/packages/google-cloud-locationfinder/$1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/packages/google-cloud-locationfinder/$1/.eslintrc.json b/packages/google-cloud-locationfinder/$1/.eslintrc.json new file mode 100644 index 000000000000..3e8d97ccb390 --- /dev/null +++ b/packages/google-cloud-locationfinder/$1/.eslintrc.json @@ -0,0 +1,4 @@ +{ + "extends": "./node_modules/gts", + "root": true +} diff --git a/packages/google-cloud-locationfinder/$1/README.md b/packages/google-cloud-locationfinder/$1/README.md index 0d57e774741a..954b30a9948d 100644 --- a/packages/google-cloud-locationfinder/$1/README.md +++ b/packages/google-cloud-locationfinder/$1/README.md @@ -94,7 +94,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-locationfinder/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`) @@ -104,7 +104,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-locationfinder/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-locationfinder/$1/protos/protos.d.ts b/packages/google-cloud-locationfinder/$1/protos/protos.d.ts index 51e6d124829e..572f6c68ecf6 100644 --- a/packages/google-cloud-locationfinder/$1/protos/protos.d.ts +++ b/packages/google-cloud-locationfinder/$1/protos/protos.d.ts @@ -1445,6 +1445,9 @@ export namespace google { /** CommonLanguageSettings destinations */ destinations?: (google.api.ClientLibraryDestination[]|null); + + /** CommonLanguageSettings selectiveGapicGeneration */ + selectiveGapicGeneration?: (google.api.ISelectiveGapicGeneration|null); } /** Represents a CommonLanguageSettings. */ @@ -1462,6 +1465,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 @@ -2162,6 +2168,9 @@ export namespace google { /** PythonSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** PythonSettings experimentalFeatures */ + experimentalFeatures?: (google.api.PythonSettings.IExperimentalFeatures|null); } /** Represents a PythonSettings. */ @@ -2176,6 +2185,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 @@ -2254,6 +2266,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 { @@ -2580,6 +2704,9 @@ export namespace google { /** GoSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** GoSettings renamedServices */ + renamedServices?: ({ [k: string]: string }|null); } /** Represents a GoSettings. */ @@ -2594,6 +2721,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 @@ -2918,6 +3048,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, @@ -3034,6 +3267,7 @@ export namespace google { /** Edition enum. */ enum Edition { EDITION_UNKNOWN = 0, + EDITION_LEGACY = 900, EDITION_PROTO2 = 998, EDITION_PROTO3 = 999, EDITION_2023 = 1000, @@ -3064,6 +3298,9 @@ export namespace google { /** FileDescriptorProto weakDependency */ weakDependency?: (number[]|null); + /** FileDescriptorProto optionDependency */ + optionDependency?: (string[]|null); + /** FileDescriptorProto messageType */ messageType?: (google.protobuf.IDescriptorProto[]|null); @@ -3113,6 +3350,9 @@ export namespace google { /** FileDescriptorProto weakDependency. */ public weakDependency: number[]; + /** FileDescriptorProto optionDependency. */ + public optionDependency: string[]; + /** FileDescriptorProto messageType. */ public messageType: google.protobuf.IDescriptorProto[]; @@ -3247,6 +3487,9 @@ export namespace google { /** DescriptorProto reservedName */ reservedName?: (string[]|null); + + /** DescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents a DescriptorProto. */ @@ -3288,6 +3531,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 @@ -4135,6 +4381,9 @@ export namespace google { /** EnumDescriptorProto reservedName */ reservedName?: (string[]|null); + + /** EnumDescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents an EnumDescriptorProto. */ @@ -4161,6 +4410,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 @@ -5095,6 +5347,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); @@ -5150,6 +5405,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[]; @@ -5370,6 +5628,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. */ @@ -5608,6 +5981,9 @@ export namespace google { /** EnumValueOptions debugRedact */ debugRedact?: (boolean|null); + /** EnumValueOptions featureSupport */ + featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** EnumValueOptions uninterpretedOption */ uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); } @@ -5630,6 +6006,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[]; @@ -6219,6 +6598,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. */ @@ -6248,6 +6633,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 @@ -6370,6 +6761,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. */ @@ -6489,8 +6990,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. */ @@ -6505,8 +7009,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. @@ -7039,6 +7546,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-locationfinder/$1/protos/protos.js b/packages/google-cloud-locationfinder/$1/protos/protos.js index 66906ce6ab71..01499d8a977a 100644 --- a/packages/google-cloud-locationfinder/$1/protos/protos.js +++ b/packages/google-cloud-locationfinder/$1/protos/protos.js @@ -3655,6 +3655,7 @@ * @interface ICommonLanguageSettings * @property {string|null} [referenceDocsUri] CommonLanguageSettings referenceDocsUri * @property {Array.|null} [destinations] CommonLanguageSettings destinations + * @property {google.api.ISelectiveGapicGeneration|null} [selectiveGapicGeneration] CommonLanguageSettings selectiveGapicGeneration */ /** @@ -3689,6 +3690,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 @@ -3721,6 +3730,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; }; @@ -3772,6 +3783,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; @@ -3823,6 +3838,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; }; @@ -3865,6 +3885,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; }; @@ -3883,8 +3908,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) { @@ -3892,6 +3919,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; }; @@ -5714,6 +5743,7 @@ * @memberof google.api * @interface IPythonSettings * @property {google.api.ICommonLanguageSettings|null} [common] PythonSettings common + * @property {google.api.PythonSettings.IExperimentalFeatures|null} [experimentalFeatures] PythonSettings experimentalFeatures */ /** @@ -5739,6 +5769,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 @@ -5765,6 +5803,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; }; @@ -5805,6 +5845,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; @@ -5845,6 +5889,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; }; @@ -5865,6 +5914,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; }; @@ -5881,10 +5935,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; }; @@ -5914,6 +5972,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; })(); @@ -6790,6 +7100,7 @@ * @memberof google.api * @interface IGoSettings * @property {google.api.ICommonLanguageSettings|null} [common] GoSettings common + * @property {Object.|null} [renamedServices] GoSettings renamedServices */ /** @@ -6801,6 +7112,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) @@ -6815,6 +7127,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 @@ -6841,6 +7161,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; }; @@ -6871,7 +7194,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) @@ -6881,6 +7204,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; @@ -6921,6 +7267,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; }; @@ -6941,6 +7295,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; }; @@ -6957,10 +7318,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; }; @@ -7599,29 +7968,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; })(); @@ -7868,6 +8482,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 @@ -7882,6 +8497,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; @@ -7906,6 +8522,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 @@ -7928,6 +8545,7 @@ this.dependency = []; this.publicDependency = []; this.weakDependency = []; + this.optionDependency = []; this.messageType = []; this.enumType = []; this.service = []; @@ -7978,6 +8596,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 @@ -8099,6 +8725,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; }; @@ -8171,6 +8800,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 = []; @@ -8273,6 +8908,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"; @@ -8327,6 +8969,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -8379,6 +9022,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"); @@ -8442,6 +9092,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -8507,6 +9161,7 @@ object.extension = []; object.publicDependency = []; object.weakDependency = []; + object.optionDependency = []; } if (options.defaults) { object.name = ""; @@ -8563,6 +9218,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; }; @@ -8611,6 +9271,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 */ /** @@ -8716,6 +9377,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 @@ -8768,6 +9437,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; }; @@ -8860,6 +9531,10 @@ message.reservedName.push(reader.string()); break; } + case 11: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -8973,6 +9648,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; }; @@ -9072,6 +9756,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; }; @@ -9101,6 +9805,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; @@ -9146,6 +9851,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; }; @@ -11190,6 +11897,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 */ /** @@ -11250,6 +11958,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 @@ -11287,6 +12003,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; }; @@ -11349,6 +12067,10 @@ message.reservedName.push(reader.string()); break; } + case 6: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -11417,6 +12139,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; }; @@ -11466,6 +12197,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; }; @@ -11490,6 +12241,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; @@ -11510,6 +12262,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; }; @@ -13828,6 +14582,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 @@ -13948,6 +14703,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 @@ -14022,6 +14785,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(); @@ -14123,6 +14888,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 = []; @@ -14258,6 +15027,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"; @@ -14446,6 +15220,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"); @@ -14543,6 +15322,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")) @@ -14575,6 +15355,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) @@ -14847,6 +15629,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -14888,103 +15671,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; @@ -15579,6 +16848,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 */ @@ -15622,6 +16892,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 @@ -15660,6 +16938,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(); @@ -15711,6 +16991,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 = []; @@ -15763,6 +17047,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"; @@ -15796,6 +17085,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"); @@ -15828,6 +17122,7 @@ object.deprecated = false; object.features = null; object.debugRedact = false; + object.featureSupport = null; } if (message.deprecated != null && message.hasOwnProperty("deprecated")) object.deprecated = message.deprecated; @@ -15835,6 +17130,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) @@ -17274,6 +18571,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 */ /** @@ -17339,6 +18638,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 @@ -17375,6 +18690,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; }; @@ -17435,6 +18754,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; @@ -17525,6 +18852,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; }; @@ -17664,6 +19011,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; }; @@ -17687,6 +19082,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; @@ -17700,6 +19097,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; }; @@ -17827,6 +19228,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; })(); @@ -18011,6 +19625,7 @@ default: return "minimumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -18028,6 +19643,7 @@ default: return "maximumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -18076,6 +19692,10 @@ case 0: message.minimumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.minimumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.minimumEdition = 998; @@ -18128,6 +19748,10 @@ case 0: message.maximumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.maximumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.maximumEdition = 998; @@ -18236,7 +19860,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 */ /** @@ -18263,12 +19888,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. @@ -18294,10 +19927,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; }; @@ -18338,8 +19973,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: @@ -18382,6 +20021,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -18394,10 +20034,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; }; @@ -18425,6 +20070,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -18466,10 +20115,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; }; @@ -18488,13 +20142,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; }; @@ -19709,6 +21366,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-locationfinder/$1/protos/protos.json b/packages/google-cloud-locationfinder/$1/protos/protos.json index ce1d92740cc8..18ee0abda87c 100644 --- a/packages/google-cloud-locationfinder/$1/protos/protos.json +++ b/packages/google-cloud-locationfinder/$1/protos/protos.json @@ -303,8 +303,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": { @@ -527,6 +526,10 @@ "rule": "repeated", "type": "ClientLibraryDestination", "id": 2 + }, + "selectiveGapicGeneration": { + "type": "SelectiveGapicGeneration", + "id": 3 } } }, @@ -667,6 +670,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 + } + } } } }, @@ -724,6 +749,11 @@ "common": { "type": "CommonLanguageSettings", "id": 1 + }, + "renamedServices": { + "keyType": "string", + "type": "string", + "id": 2 } } }, @@ -785,6 +815,19 @@ "PACKAGE_MANAGER": 20 } }, + "SelectiveGapicGeneration": { + "fields": { + "methods": { + "rule": "repeated", + "type": "string", + "id": 1 + }, + "generateOmittedAsInternal": { + "type": "bool", + "id": 2 + } + } + }, "LaunchStage": { "values": { "LAUNCH_STAGE_UNSPECIFIED": 0, @@ -818,12 +861,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, @@ -862,6 +912,11 @@ "type": "int32", "id": 11 }, + "optionDependency": { + "rule": "repeated", + "type": "string", + "id": 15 + }, "messageType": { "rule": "repeated", "type": "DescriptorProto", @@ -950,6 +1005,10 @@ "rule": "repeated", "type": "string", "id": 10 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 11 } }, "nested": { @@ -1175,6 +1234,10 @@ "rule": "repeated", "type": "string", "id": 5 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 6 } }, "nested": { @@ -1225,7 +1288,14 @@ "type": "ServiceOptions", "id": 3 } - } + }, + "reserved": [ + [ + 4, + 4 + ], + "stream" + ] }, "MethodDescriptorProto": { "edition": "proto2", @@ -1389,6 +1459,7 @@ 42, 42 ], + "php_generic_services", [ 38, 38 @@ -1524,7 +1595,8 @@ "type": "bool", "id": 10, "options": { - "default": false + "default": false, + "deprecated": true } }, "debugRedact": { @@ -1552,6 +1624,10 @@ "type": "FeatureSet", "id": 21 }, + "featureSupport": { + "type": "FeatureSupport", + "id": 22 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -1621,6 +1697,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 + } + } } } }, @@ -1709,6 +1805,10 @@ "default": false } }, + "featureSupport": { + "type": "FieldOptions.FeatureSupport", + "id": 4 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -1851,6 +1951,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_2023", "edition_defaults.value": "EXPLICIT" } @@ -1861,6 +1962,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "OPEN" } @@ -1871,6 +1973,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "PACKED" } @@ -1881,6 +1984,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "VERIFY" } @@ -1891,7 +1995,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" } }, @@ -1901,27 +2006,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, @@ -1966,7 +2082,13 @@ "UTF8_VALIDATION_UNKNOWN": 0, "VERIFY": 2, "NONE": 3 - } + }, + "reserved": [ + [ + 1, + 1 + ] + ] }, "MessageEncoding": { "values": { @@ -1981,6 +2103,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 + } + } + } } } }, @@ -2008,11 +2157,26 @@ "type": "Edition", "id": 3 }, - "features": { + "overridableFeatures": { "type": "FeatureSet", - "id": 2 + "id": 4 + }, + "fixedFeatures": { + "type": "FeatureSet", + "id": 5 } - } + }, + "reserved": [ + [ + 1, + 1 + ], + [ + 2, + 2 + ], + "features" + ] } } }, @@ -2025,6 +2189,12 @@ "id": 1 } }, + "extensions": [ + [ + 536000000, + 536000000 + ] + ], "nested": { "Location": { "fields": { @@ -2110,6 +2280,14 @@ } } }, + "SymbolVisibility": { + "edition": "proto2", + "values": { + "VISIBILITY_UNSET": 0, + "VISIBILITY_LOCAL": 1, + "VISIBILITY_EXPORT": 2 + } + }, "Duration": { "fields": { "seconds": { diff --git a/packages/google-cloud-locationfinder/$1/src/v1/cloud_location_finder_client.ts b/packages/google-cloud-locationfinder/$1/src/v1/cloud_location_finder_client.ts index b6ef063cc8ef..2d05a7a60f5b 100644 --- a/packages/google-cloud-locationfinder/$1/src/v1/cloud_location_finder_client.ts +++ b/packages/google-cloud-locationfinder/$1/src/v1/cloud_location_finder_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 CloudLocationFinderClient { 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('locationfinder'); @@ -57,10 +66,10 @@ export class CloudLocationFinderClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - cloudLocationFinderStub?: Promise<{[name: string]: Function}>; + pathTemplates: { [name: string]: gax.PathTemplate }; + cloudLocationFinderStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of CloudLocationFinderClient. @@ -101,21 +110,42 @@ export class CloudLocationFinderClient { * const client = new CloudLocationFinderClient({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 CloudLocationFinderClient; - 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 = 'cloudlocationfinder.' + 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 CloudLocationFinderClient { 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 CloudLocationFinderClient { } 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,7 +210,7 @@ export class CloudLocationFinderClient { // Create useful helper objects for these. this.pathTemplates = { cloudLocationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/cloudLocations/{cloud_location}' + 'projects/{project}/locations/{location}/cloudLocations/{cloud_location}', ), }; @@ -192,16 +218,25 @@ export class CloudLocationFinderClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listCloudLocations: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'cloudLocations'), - searchCloudLocations: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'cloudLocations') + listCloudLocations: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'cloudLocations', + ), + searchCloudLocations: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'cloudLocations', + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.locationfinder.v1.CloudLocationFinder', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.locationfinder.v1.CloudLocationFinder', + 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 +267,45 @@ export class CloudLocationFinderClient { // Put together the "service stub" for // google.cloud.locationfinder.v1.CloudLocationFinder. this.cloudLocationFinderStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.locationfinder.v1.CloudLocationFinder') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.locationfinder.v1.CloudLocationFinder, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.locationfinder.v1.CloudLocationFinder', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.locationfinder.v1 + .CloudLocationFinder, + 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 cloudLocationFinderStubMethods = - ['listCloudLocations', 'getCloudLocation', 'searchCloudLocations']; + const cloudLocationFinderStubMethods = [ + 'listCloudLocations', + 'getCloudLocation', + 'searchCloudLocations', + ]; for (const methodName of cloudLocationFinderStubMethods) { const callPromise = this.cloudLocationFinderStub.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 +320,14 @@ export class CloudLocationFinderClient { * @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 'cloudlocationfinder.googleapis.com'; } @@ -289,8 +338,14 @@ export class CloudLocationFinderClient { * @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 'cloudlocationfinder.googleapis.com'; } @@ -321,9 +376,7 @@ export class CloudLocationFinderClient { * @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; @@ -332,8 +385,9 @@ export class CloudLocationFinderClient { * 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; @@ -344,197 +398,271 @@ export class CloudLocationFinderClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Retrieves a resource containing information about a cloud 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.locationfinder.v1.CloudLocation|CloudLocation}. - * Please see the {@link 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_location_finder.get_cloud_location.js - * region_tag:cloudlocationfinder_v1_generated_CloudLocationFinder_GetCloudLocation_async - */ + /** + * Retrieves a resource containing information about a cloud 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.locationfinder.v1.CloudLocation|CloudLocation}. + * Please see the {@link 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_location_finder.get_cloud_location.js + * region_tag:cloudlocationfinder_v1_generated_CloudLocationFinder_GetCloudLocation_async + */ getCloudLocation( - request?: protos.google.cloud.locationfinder.v1.IGetCloudLocationRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.locationfinder.v1.ICloudLocation, - protos.google.cloud.locationfinder.v1.IGetCloudLocationRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.locationfinder.v1.IGetCloudLocationRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.locationfinder.v1.ICloudLocation, + ( + | protos.google.cloud.locationfinder.v1.IGetCloudLocationRequest + | undefined + ), + {} | undefined, + ] + >; getCloudLocation( - request: protos.google.cloud.locationfinder.v1.IGetCloudLocationRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.locationfinder.v1.ICloudLocation, - protos.google.cloud.locationfinder.v1.IGetCloudLocationRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.locationfinder.v1.IGetCloudLocationRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.locationfinder.v1.ICloudLocation, + | protos.google.cloud.locationfinder.v1.IGetCloudLocationRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getCloudLocation( - request: protos.google.cloud.locationfinder.v1.IGetCloudLocationRequest, - callback: Callback< - protos.google.cloud.locationfinder.v1.ICloudLocation, - protos.google.cloud.locationfinder.v1.IGetCloudLocationRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.locationfinder.v1.IGetCloudLocationRequest, + callback: Callback< + protos.google.cloud.locationfinder.v1.ICloudLocation, + | protos.google.cloud.locationfinder.v1.IGetCloudLocationRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getCloudLocation( - request?: protos.google.cloud.locationfinder.v1.IGetCloudLocationRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.locationfinder.v1.ICloudLocation, - protos.google.cloud.locationfinder.v1.IGetCloudLocationRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.locationfinder.v1.IGetCloudLocationRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.locationfinder.v1.ICloudLocation, - protos.google.cloud.locationfinder.v1.IGetCloudLocationRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.locationfinder.v1.ICloudLocation, - protos.google.cloud.locationfinder.v1.IGetCloudLocationRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.locationfinder.v1.IGetCloudLocationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.locationfinder.v1.ICloudLocation, + | protos.google.cloud.locationfinder.v1.IGetCloudLocationRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.locationfinder.v1.ICloudLocation, + ( + | protos.google.cloud.locationfinder.v1.IGetCloudLocationRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getCloudLocation request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.locationfinder.v1.ICloudLocation, - protos.google.cloud.locationfinder.v1.IGetCloudLocationRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.locationfinder.v1.ICloudLocation, + | protos.google.cloud.locationfinder.v1.IGetCloudLocationRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getCloudLocation response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getCloudLocation(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.locationfinder.v1.ICloudLocation, - protos.google.cloud.locationfinder.v1.IGetCloudLocationRequest|undefined, - {}|undefined - ]) => { - this._log.info('getCloudLocation response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && error.statusDetails instanceof Array) { - const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos) as unknown as gax.protobuf.Type; - error.statusDetails = decodeAnyProtosInArray(error.statusDetails, protos); + return this.innerApiCalls + .getCloudLocation(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.locationfinder.v1.ICloudLocation, + ( + | protos.google.cloud.locationfinder.v1.IGetCloudLocationRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getCloudLocation response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + error.statusDetails 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 cloud locations under a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent, which owns this collection of cloud locations. - * Format: projects/{project}/locations/{location} - * @param {number} [request.pageSize] - * Optional. The maximum number of cloud locations to return per page. The - * service might return fewer cloud locations than this value. If unspecified, - * server will pick an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * Provide page token returned by a previous 'ListCloudLocations' call to - * retrieve the next page of results. When paginating, all other parameters - * provided to 'ListCloudLocations' 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 example, - * 'cloud_location_type=CLOUD_LOCATION_TYPE_REGION'. Multiple filter queries - * are space-separated. For example, - * 'cloud_location_type=CLOUD_LOCATION_TYPE_REGION territory_code="US"' By - * default, each expression is an AND expression. However, you can include AND - * and OR expressions explicitly. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link protos.google.cloud.locationfinder.v1.CloudLocation|CloudLocation}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listCloudLocationsAsync()` - * method described below for async iteration which you can stop as 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 cloud locations under a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent, which owns this collection of cloud locations. + * Format: projects/{project}/locations/{location} + * @param {number} [request.pageSize] + * Optional. The maximum number of cloud locations to return per page. The + * service might return fewer cloud locations than this value. If unspecified, + * server will pick an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * Provide page token returned by a previous 'ListCloudLocations' call to + * retrieve the next page of results. When paginating, all other parameters + * provided to 'ListCloudLocations' 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 example, + * 'cloud_location_type=CLOUD_LOCATION_TYPE_REGION'. Multiple filter queries + * are space-separated. For example, + * 'cloud_location_type=CLOUD_LOCATION_TYPE_REGION territory_code="US"' By + * default, each expression is an AND expression. However, you can include AND + * and OR expressions explicitly. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.locationfinder.v1.CloudLocation|CloudLocation}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listCloudLocationsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listCloudLocations( - request?: protos.google.cloud.locationfinder.v1.IListCloudLocationsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.locationfinder.v1.ICloudLocation[], - protos.google.cloud.locationfinder.v1.IListCloudLocationsRequest|null, - protos.google.cloud.locationfinder.v1.IListCloudLocationsResponse - ]>; + request?: protos.google.cloud.locationfinder.v1.IListCloudLocationsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.locationfinder.v1.ICloudLocation[], + protos.google.cloud.locationfinder.v1.IListCloudLocationsRequest | null, + protos.google.cloud.locationfinder.v1.IListCloudLocationsResponse, + ] + >; listCloudLocations( - request: protos.google.cloud.locationfinder.v1.IListCloudLocationsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.locationfinder.v1.IListCloudLocationsRequest, - protos.google.cloud.locationfinder.v1.IListCloudLocationsResponse|null|undefined, - protos.google.cloud.locationfinder.v1.ICloudLocation>): void; + request: protos.google.cloud.locationfinder.v1.IListCloudLocationsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.locationfinder.v1.IListCloudLocationsRequest, + | protos.google.cloud.locationfinder.v1.IListCloudLocationsResponse + | null + | undefined, + protos.google.cloud.locationfinder.v1.ICloudLocation + >, + ): void; listCloudLocations( - request: protos.google.cloud.locationfinder.v1.IListCloudLocationsRequest, - callback: PaginationCallback< - protos.google.cloud.locationfinder.v1.IListCloudLocationsRequest, - protos.google.cloud.locationfinder.v1.IListCloudLocationsResponse|null|undefined, - protos.google.cloud.locationfinder.v1.ICloudLocation>): void; + request: protos.google.cloud.locationfinder.v1.IListCloudLocationsRequest, + callback: PaginationCallback< + protos.google.cloud.locationfinder.v1.IListCloudLocationsRequest, + | protos.google.cloud.locationfinder.v1.IListCloudLocationsResponse + | null + | undefined, + protos.google.cloud.locationfinder.v1.ICloudLocation + >, + ): void; listCloudLocations( - request?: protos.google.cloud.locationfinder.v1.IListCloudLocationsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.locationfinder.v1.IListCloudLocationsRequest, - protos.google.cloud.locationfinder.v1.IListCloudLocationsResponse|null|undefined, - protos.google.cloud.locationfinder.v1.ICloudLocation>, - callback?: PaginationCallback< + request?: protos.google.cloud.locationfinder.v1.IListCloudLocationsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.locationfinder.v1.IListCloudLocationsRequest, - protos.google.cloud.locationfinder.v1.IListCloudLocationsResponse|null|undefined, - protos.google.cloud.locationfinder.v1.ICloudLocation>): - Promise<[ - protos.google.cloud.locationfinder.v1.ICloudLocation[], - protos.google.cloud.locationfinder.v1.IListCloudLocationsRequest|null, - protos.google.cloud.locationfinder.v1.IListCloudLocationsResponse - ]>|void { + | protos.google.cloud.locationfinder.v1.IListCloudLocationsResponse + | null + | undefined, + protos.google.cloud.locationfinder.v1.ICloudLocation + >, + callback?: PaginationCallback< + protos.google.cloud.locationfinder.v1.IListCloudLocationsRequest, + | protos.google.cloud.locationfinder.v1.IListCloudLocationsResponse + | null + | undefined, + protos.google.cloud.locationfinder.v1.ICloudLocation + >, + ): Promise< + [ + protos.google.cloud.locationfinder.v1.ICloudLocation[], + protos.google.cloud.locationfinder.v1.IListCloudLocationsRequest | null, + protos.google.cloud.locationfinder.v1.IListCloudLocationsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-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.locationfinder.v1.IListCloudLocationsRequest, - protos.google.cloud.locationfinder.v1.IListCloudLocationsResponse|null|undefined, - protos.google.cloud.locationfinder.v1.ICloudLocation>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.locationfinder.v1.IListCloudLocationsRequest, + | protos.google.cloud.locationfinder.v1.IListCloudLocationsResponse + | null + | undefined, + protos.google.cloud.locationfinder.v1.ICloudLocation + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listCloudLocations values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -543,234 +671,263 @@ export class CloudLocationFinderClient { this._log.info('listCloudLocations request %j', request); return this.innerApiCalls .listCloudLocations(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.locationfinder.v1.ICloudLocation[], - protos.google.cloud.locationfinder.v1.IListCloudLocationsRequest|null, - protos.google.cloud.locationfinder.v1.IListCloudLocationsResponse - ]) => { - this._log.info('listCloudLocations values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.locationfinder.v1.ICloudLocation[], + protos.google.cloud.locationfinder.v1.IListCloudLocationsRequest | null, + protos.google.cloud.locationfinder.v1.IListCloudLocationsResponse, + ]) => { + this._log.info('listCloudLocations values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listCloudLocations`, 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 cloud locations. - * Format: projects/{project}/locations/{location} - * @param {number} [request.pageSize] - * Optional. The maximum number of cloud locations to return per page. The - * service might return fewer cloud locations than this value. If unspecified, - * server will pick an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * Provide page token returned by a previous 'ListCloudLocations' call to - * retrieve the next page of results. When paginating, all other parameters - * provided to 'ListCloudLocations' 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 example, - * 'cloud_location_type=CLOUD_LOCATION_TYPE_REGION'. Multiple filter queries - * are space-separated. For example, - * 'cloud_location_type=CLOUD_LOCATION_TYPE_REGION territory_code="US"' By - * default, each expression is an AND expression. However, you can include AND - * and OR expressions explicitly. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.locationfinder.v1.CloudLocation|CloudLocation} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listCloudLocationsAsync()` - * method described below for async iteration which you can stop as 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 `listCloudLocations`, 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 cloud locations. + * Format: projects/{project}/locations/{location} + * @param {number} [request.pageSize] + * Optional. The maximum number of cloud locations to return per page. The + * service might return fewer cloud locations than this value. If unspecified, + * server will pick an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * Provide page token returned by a previous 'ListCloudLocations' call to + * retrieve the next page of results. When paginating, all other parameters + * provided to 'ListCloudLocations' 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 example, + * 'cloud_location_type=CLOUD_LOCATION_TYPE_REGION'. Multiple filter queries + * are space-separated. For example, + * 'cloud_location_type=CLOUD_LOCATION_TYPE_REGION territory_code="US"' By + * default, each expression is an AND expression. However, you can include AND + * and OR expressions explicitly. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.locationfinder.v1.CloudLocation|CloudLocation} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listCloudLocationsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listCloudLocationsStream( - request?: protos.google.cloud.locationfinder.v1.IListCloudLocationsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.locationfinder.v1.IListCloudLocationsRequest, + 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['listCloudLocations']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listCloudLocations stream %j', request); return this.descriptors.page.listCloudLocations.createStream( this.innerApiCalls.listCloudLocations as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listCloudLocations`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used 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 cloud locations. - * Format: projects/{project}/locations/{location} - * @param {number} [request.pageSize] - * Optional. The maximum number of cloud locations to return per page. The - * service might return fewer cloud locations than this value. If unspecified, - * server will pick an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * Provide page token returned by a previous 'ListCloudLocations' call to - * retrieve the next page of results. When paginating, all other parameters - * provided to 'ListCloudLocations' 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 example, - * 'cloud_location_type=CLOUD_LOCATION_TYPE_REGION'. Multiple filter queries - * are space-separated. For example, - * 'cloud_location_type=CLOUD_LOCATION_TYPE_REGION territory_code="US"' By - * default, each expression is an AND expression. However, you can include AND - * and OR expressions explicitly. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.locationfinder.v1.CloudLocation|CloudLocation}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/cloud_location_finder.list_cloud_locations.js - * region_tag:cloudlocationfinder_v1_generated_CloudLocationFinder_ListCloudLocations_async - */ + /** + * Equivalent to `listCloudLocations`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used 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 cloud locations. + * Format: projects/{project}/locations/{location} + * @param {number} [request.pageSize] + * Optional. The maximum number of cloud locations to return per page. The + * service might return fewer cloud locations than this value. If unspecified, + * server will pick an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * Provide page token returned by a previous 'ListCloudLocations' call to + * retrieve the next page of results. When paginating, all other parameters + * provided to 'ListCloudLocations' 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 example, + * 'cloud_location_type=CLOUD_LOCATION_TYPE_REGION'. Multiple filter queries + * are space-separated. For example, + * 'cloud_location_type=CLOUD_LOCATION_TYPE_REGION territory_code="US"' By + * default, each expression is an AND expression. However, you can include AND + * and OR expressions explicitly. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.locationfinder.v1.CloudLocation|CloudLocation}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/cloud_location_finder.list_cloud_locations.js + * region_tag:cloudlocationfinder_v1_generated_CloudLocationFinder_ListCloudLocations_async + */ listCloudLocationsAsync( - request?: protos.google.cloud.locationfinder.v1.IListCloudLocationsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.locationfinder.v1.IListCloudLocationsRequest, + 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['listCloudLocations']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listCloudLocations iterate %j', request); return this.descriptors.page.listCloudLocations.asyncIterate( this.innerApiCalls['listCloudLocations'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Searches for cloud locations from a given source location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent, which owns this collection of cloud locations. - * Format: projects/{project}/locations/{location} - * @param {string} request.sourceCloudLocation - * Required. The source cloud location to search from. - * Example search can be searching nearby cloud locations from the source - * cloud location by latency. - * @param {number} [request.pageSize] - * Optional. The maximum number of cloud locations to return. The service - * might return fewer cloud locations than this value. If unspecified, server - * will pick an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * Provide Page token returned by a previous 'ListCloudLocations' call to - * retrieve the next page of results. When paginating, all other parameters - * provided to 'ListCloudLocations' must match the call that provided the page - * token. - * @param {string} [request.query] - * Optional. The query string in search query syntax. While filter is used to - * filter the search results by attributes, query is used to specify the - * search requirements. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of {@link protos.google.cloud.locationfinder.v1.CloudLocation|CloudLocation}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `searchCloudLocationsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Searches for cloud locations from a given source location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent, which owns this collection of cloud locations. + * Format: projects/{project}/locations/{location} + * @param {string} request.sourceCloudLocation + * Required. The source cloud location to search from. + * Example search can be searching nearby cloud locations from the source + * cloud location by latency. + * @param {number} [request.pageSize] + * Optional. The maximum number of cloud locations to return. The service + * might return fewer cloud locations than this value. If unspecified, server + * will pick an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * Provide Page token returned by a previous 'ListCloudLocations' call to + * retrieve the next page of results. When paginating, all other parameters + * provided to 'ListCloudLocations' must match the call that provided the page + * token. + * @param {string} [request.query] + * Optional. The query string in search query syntax. While filter is used to + * filter the search results by attributes, query is used to specify the + * search requirements. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of {@link protos.google.cloud.locationfinder.v1.CloudLocation|CloudLocation}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `searchCloudLocationsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ searchCloudLocations( - request?: protos.google.cloud.locationfinder.v1.ISearchCloudLocationsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.locationfinder.v1.ICloudLocation[], - protos.google.cloud.locationfinder.v1.ISearchCloudLocationsRequest|null, - protos.google.cloud.locationfinder.v1.ISearchCloudLocationsResponse - ]>; + request?: protos.google.cloud.locationfinder.v1.ISearchCloudLocationsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.locationfinder.v1.ICloudLocation[], + protos.google.cloud.locationfinder.v1.ISearchCloudLocationsRequest | null, + protos.google.cloud.locationfinder.v1.ISearchCloudLocationsResponse, + ] + >; searchCloudLocations( - request: protos.google.cloud.locationfinder.v1.ISearchCloudLocationsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.locationfinder.v1.ISearchCloudLocationsRequest, - protos.google.cloud.locationfinder.v1.ISearchCloudLocationsResponse|null|undefined, - protos.google.cloud.locationfinder.v1.ICloudLocation>): void; + request: protos.google.cloud.locationfinder.v1.ISearchCloudLocationsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.locationfinder.v1.ISearchCloudLocationsRequest, + | protos.google.cloud.locationfinder.v1.ISearchCloudLocationsResponse + | null + | undefined, + protos.google.cloud.locationfinder.v1.ICloudLocation + >, + ): void; searchCloudLocations( - request: protos.google.cloud.locationfinder.v1.ISearchCloudLocationsRequest, - callback: PaginationCallback< - protos.google.cloud.locationfinder.v1.ISearchCloudLocationsRequest, - protos.google.cloud.locationfinder.v1.ISearchCloudLocationsResponse|null|undefined, - protos.google.cloud.locationfinder.v1.ICloudLocation>): void; + request: protos.google.cloud.locationfinder.v1.ISearchCloudLocationsRequest, + callback: PaginationCallback< + protos.google.cloud.locationfinder.v1.ISearchCloudLocationsRequest, + | protos.google.cloud.locationfinder.v1.ISearchCloudLocationsResponse + | null + | undefined, + protos.google.cloud.locationfinder.v1.ICloudLocation + >, + ): void; searchCloudLocations( - request?: protos.google.cloud.locationfinder.v1.ISearchCloudLocationsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.locationfinder.v1.ISearchCloudLocationsRequest, - protos.google.cloud.locationfinder.v1.ISearchCloudLocationsResponse|null|undefined, - protos.google.cloud.locationfinder.v1.ICloudLocation>, - callback?: PaginationCallback< + request?: protos.google.cloud.locationfinder.v1.ISearchCloudLocationsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.locationfinder.v1.ISearchCloudLocationsRequest, - protos.google.cloud.locationfinder.v1.ISearchCloudLocationsResponse|null|undefined, - protos.google.cloud.locationfinder.v1.ICloudLocation>): - Promise<[ - protos.google.cloud.locationfinder.v1.ICloudLocation[], - protos.google.cloud.locationfinder.v1.ISearchCloudLocationsRequest|null, - protos.google.cloud.locationfinder.v1.ISearchCloudLocationsResponse - ]>|void { + | protos.google.cloud.locationfinder.v1.ISearchCloudLocationsResponse + | null + | undefined, + protos.google.cloud.locationfinder.v1.ICloudLocation + >, + callback?: PaginationCallback< + protos.google.cloud.locationfinder.v1.ISearchCloudLocationsRequest, + | protos.google.cloud.locationfinder.v1.ISearchCloudLocationsResponse + | null + | undefined, + protos.google.cloud.locationfinder.v1.ICloudLocation + >, + ): Promise< + [ + protos.google.cloud.locationfinder.v1.ICloudLocation[], + protos.google.cloud.locationfinder.v1.ISearchCloudLocationsRequest | null, + protos.google.cloud.locationfinder.v1.ISearchCloudLocationsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'parent': request.parent ?? '', + options.otherArgs.headers['x-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.locationfinder.v1.ISearchCloudLocationsRequest, - protos.google.cloud.locationfinder.v1.ISearchCloudLocationsResponse|null|undefined, - protos.google.cloud.locationfinder.v1.ICloudLocation>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.locationfinder.v1.ISearchCloudLocationsRequest, + | protos.google.cloud.locationfinder.v1.ISearchCloudLocationsResponse + | null + | undefined, + protos.google.cloud.locationfinder.v1.ICloudLocation + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('searchCloudLocations values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -779,139 +936,144 @@ export class CloudLocationFinderClient { this._log.info('searchCloudLocations request %j', request); return this.innerApiCalls .searchCloudLocations(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.locationfinder.v1.ICloudLocation[], - protos.google.cloud.locationfinder.v1.ISearchCloudLocationsRequest|null, - protos.google.cloud.locationfinder.v1.ISearchCloudLocationsResponse - ]) => { - this._log.info('searchCloudLocations values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.locationfinder.v1.ICloudLocation[], + protos.google.cloud.locationfinder.v1.ISearchCloudLocationsRequest | null, + protos.google.cloud.locationfinder.v1.ISearchCloudLocationsResponse, + ]) => { + this._log.info('searchCloudLocations values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `searchCloudLocations`, 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 cloud locations. - * Format: projects/{project}/locations/{location} - * @param {string} request.sourceCloudLocation - * Required. The source cloud location to search from. - * Example search can be searching nearby cloud locations from the source - * cloud location by latency. - * @param {number} [request.pageSize] - * Optional. The maximum number of cloud locations to return. The service - * might return fewer cloud locations than this value. If unspecified, server - * will pick an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * Provide Page token returned by a previous 'ListCloudLocations' call to - * retrieve the next page of results. When paginating, all other parameters - * provided to 'ListCloudLocations' must match the call that provided the page - * token. - * @param {string} [request.query] - * Optional. The query string in search query syntax. While filter is used to - * filter the search results by attributes, query is used to specify the - * search requirements. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.locationfinder.v1.CloudLocation|CloudLocation} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `searchCloudLocationsAsync()` - * method described below for async iteration which you can stop as 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 `searchCloudLocations`, 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 cloud locations. + * Format: projects/{project}/locations/{location} + * @param {string} request.sourceCloudLocation + * Required. The source cloud location to search from. + * Example search can be searching nearby cloud locations from the source + * cloud location by latency. + * @param {number} [request.pageSize] + * Optional. The maximum number of cloud locations to return. The service + * might return fewer cloud locations than this value. If unspecified, server + * will pick an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * Provide Page token returned by a previous 'ListCloudLocations' call to + * retrieve the next page of results. When paginating, all other parameters + * provided to 'ListCloudLocations' must match the call that provided the page + * token. + * @param {string} [request.query] + * Optional. The query string in search query syntax. While filter is used to + * filter the search results by attributes, query is used to specify the + * search requirements. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.locationfinder.v1.CloudLocation|CloudLocation} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `searchCloudLocationsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ searchCloudLocationsStream( - request?: protos.google.cloud.locationfinder.v1.ISearchCloudLocationsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.locationfinder.v1.ISearchCloudLocationsRequest, + 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['searchCloudLocations']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('searchCloudLocations stream %j', request); return this.descriptors.page.searchCloudLocations.createStream( this.innerApiCalls.searchCloudLocations as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `searchCloudLocations`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used 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 cloud locations. - * Format: projects/{project}/locations/{location} - * @param {string} request.sourceCloudLocation - * Required. The source cloud location to search from. - * Example search can be searching nearby cloud locations from the source - * cloud location by latency. - * @param {number} [request.pageSize] - * Optional. The maximum number of cloud locations to return. The service - * might return fewer cloud locations than this value. If unspecified, server - * will pick an appropriate default. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * Provide Page token returned by a previous 'ListCloudLocations' call to - * retrieve the next page of results. When paginating, all other parameters - * provided to 'ListCloudLocations' must match the call that provided the page - * token. - * @param {string} [request.query] - * Optional. The query string in search query syntax. While filter is used to - * filter the search results by attributes, query is used to specify the - * search requirements. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. - * When you iterate the returned iterable, each element will be an object representing - * {@link protos.google.cloud.locationfinder.v1.CloudLocation|CloudLocation}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - * @example include:samples/generated/v1/cloud_location_finder.search_cloud_locations.js - * region_tag:cloudlocationfinder_v1_generated_CloudLocationFinder_SearchCloudLocations_async - */ + /** + * Equivalent to `searchCloudLocations`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used 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 cloud locations. + * Format: projects/{project}/locations/{location} + * @param {string} request.sourceCloudLocation + * Required. The source cloud location to search from. + * Example search can be searching nearby cloud locations from the source + * cloud location by latency. + * @param {number} [request.pageSize] + * Optional. The maximum number of cloud locations to return. The service + * might return fewer cloud locations than this value. If unspecified, server + * will pick an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * Provide Page token returned by a previous 'ListCloudLocations' call to + * retrieve the next page of results. When paginating, all other parameters + * provided to 'ListCloudLocations' must match the call that provided the page + * token. + * @param {string} [request.query] + * Optional. The query string in search query syntax. While filter is used to + * filter the search results by attributes, query is used to specify the + * search requirements. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | async iteration }. + * When you iterate the returned iterable, each element will be an object representing + * {@link protos.google.cloud.locationfinder.v1.CloudLocation|CloudLocation}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + * @example include:samples/generated/v1/cloud_location_finder.search_cloud_locations.js + * region_tag:cloudlocationfinder_v1_generated_CloudLocationFinder_SearchCloudLocations_async + */ searchCloudLocationsAsync( - request?: protos.google.cloud.locationfinder.v1.ISearchCloudLocationsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.locationfinder.v1.ISearchCloudLocationsRequest, + 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['searchCloudLocations']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('searchCloudLocations iterate %j', request); return this.descriptors.page.searchCloudLocations.asyncIterate( this.innerApiCalls['searchCloudLocations'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** + + /** * Gets information about a location. * * @param {Object} request @@ -946,12 +1108,11 @@ export class CloudLocationFinderClient { | 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. @@ -984,7 +1145,7 @@ export class CloudLocationFinderClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } @@ -1001,7 +1162,7 @@ export class CloudLocationFinderClient { * @param {string} cloud_location * @returns {string} Resource name string. */ - cloudLocationPath(project:string,location:string,cloudLocation:string) { + cloudLocationPath(project: string, location: string, cloudLocation: string) { return this.pathTemplates.cloudLocationPathTemplate.render({ project: project, location: location, @@ -1017,7 +1178,8 @@ export class CloudLocationFinderClient { * @returns {string} A string representing the project. */ matchProjectFromCloudLocationName(cloudLocationName: string) { - return this.pathTemplates.cloudLocationPathTemplate.match(cloudLocationName).project; + return this.pathTemplates.cloudLocationPathTemplate.match(cloudLocationName) + .project; } /** @@ -1028,7 +1190,8 @@ export class CloudLocationFinderClient { * @returns {string} A string representing the location. */ matchLocationFromCloudLocationName(cloudLocationName: string) { - return this.pathTemplates.cloudLocationPathTemplate.match(cloudLocationName).location; + return this.pathTemplates.cloudLocationPathTemplate.match(cloudLocationName) + .location; } /** @@ -1039,7 +1202,8 @@ export class CloudLocationFinderClient { * @returns {string} A string representing the cloud_location. */ matchCloudLocationFromCloudLocationName(cloudLocationName: string) { - return this.pathTemplates.cloudLocationPathTemplate.match(cloudLocationName).cloud_location; + return this.pathTemplates.cloudLocationPathTemplate.match(cloudLocationName) + .cloud_location; } /** @@ -1050,13 +1214,15 @@ export class CloudLocationFinderClient { */ close(): Promise { if (this.cloudLocationFinderStub && !this._terminated) { - return this.cloudLocationFinderStub.then(stub => { + return this.cloudLocationFinderStub.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-locationfinder/$1/src/v1/index.ts b/packages/google-cloud-locationfinder/$1/src/v1/index.ts index 4bea53dca912..969f27d5acb5 100644 --- a/packages/google-cloud-locationfinder/$1/src/v1/index.ts +++ b/packages/google-cloud-locationfinder/$1/src/v1/index.ts @@ -16,4 +16,4 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {CloudLocationFinderClient} from './cloud_location_finder_client'; +export { CloudLocationFinderClient } from './cloud_location_finder_client'; diff --git a/packages/google-cloud-locationfinder/$1/system-test/fixtures/sample/src/index.ts b/packages/google-cloud-locationfinder/$1/system-test/fixtures/sample/src/index.ts index 258a9b6299a5..7fd012f2c4d2 100644 --- a/packages/google-cloud-locationfinder/$1/system-test/fixtures/sample/src/index.ts +++ b/packages/google-cloud-locationfinder/$1/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 {CloudLocationFinderClient} from '@google-cloud/locationfinder'; +import { CloudLocationFinderClient } from '@google-cloud/locationfinder'; // check that the client class type name can be used -function doStuffWithCloudLocationFinderClient(client: CloudLocationFinderClient) { +function doStuffWithCloudLocationFinderClient( + client: CloudLocationFinderClient, +) { client.close(); } diff --git a/packages/google-cloud-locationfinder/$1/system-test/install.ts b/packages/google-cloud-locationfinder/$1/system-test/install.ts index f66069aa3940..ccf167042d2e 100644 --- a/packages/google-cloud-locationfinder/$1/system-test/install.ts +++ b/packages/google-cloud-locationfinder/$1/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-locationfinder/$1/test/gapic_cloud_location_finder_v1.ts b/packages/google-cloud-locationfinder/$1/test/gapic_cloud_location_finder_v1.ts index 04aa50ee2321..7e7ac6aeb7cf 100644 --- a/packages/google-cloud-locationfinder/$1/test/gapic_cloud_location_finder_v1.ts +++ b/packages/google-cloud-locationfinder/$1/test/gapic_cloud_location_finder_v1.ts @@ -19,1056 +19,1429 @@ 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 cloudlocationfinderModule 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.CloudLocationFinderClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new cloudlocationfinderModule.v1.CloudLocationFinderClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'cloudlocationfinder.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new cloudlocationfinderModule.v1.CloudLocationFinderClient(); - 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 = cloudlocationfinderModule.v1.CloudLocationFinderClient.servicePath; - assert.strictEqual(servicePath, 'cloudlocationfinder.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = cloudlocationfinderModule.v1.CloudLocationFinderClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'cloudlocationfinder.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new cloudlocationfinderModule.v1.CloudLocationFinderClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudlocationfinder.example.com'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = + new cloudlocationfinderModule.v1.CloudLocationFinderClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'cloudlocationfinder.googleapis.com'); + }); - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new cloudlocationfinderModule.v1.CloudLocationFinderClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudlocationfinder.example.com'); - }); + it('has universeDomain', () => { + const client = + new cloudlocationfinderModule.v1.CloudLocationFinderClient(); + 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 cloudlocationfinderModule.v1.CloudLocationFinderClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudlocationfinder.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 = + cloudlocationfinderModule.v1.CloudLocationFinderClient.servicePath; + assert.strictEqual(servicePath, 'cloudlocationfinder.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 cloudlocationfinderModule.v1.CloudLocationFinderClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudlocationfinder.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 cloudlocationfinderModule.v1.CloudLocationFinderClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + cloudlocationfinderModule.v1.CloudLocationFinderClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'cloudlocationfinder.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new cloudlocationfinderModule.v1.CloudLocationFinderClient( + { universeDomain: 'example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudlocationfinder.example.com'); + }); - it('has port', () => { - const port = cloudlocationfinderModule.v1.CloudLocationFinderClient.port; - assert(port); - assert(typeof port === 'number'); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new cloudlocationfinderModule.v1.CloudLocationFinderClient( + { universe_domain: 'example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudlocationfinder.example.com'); + }); - it('should create a client with no option', () => { - const client = new cloudlocationfinderModule.v1.CloudLocationFinderClient(); - 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 cloudlocationfinderModule.v1.CloudLocationFinderClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudlocationfinder.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 cloudlocationfinderModule.v1.CloudLocationFinderClient({ - 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 cloudlocationfinderModule.v1.CloudLocationFinderClient({ + universeDomain: 'configured.example.com', }); - assert(client); + const servicePath = client.apiEndpoint; + assert.strictEqual( + servicePath, + 'cloudlocationfinder.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 cloudlocationfinderModule.v1.CloudLocationFinderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.cloudLocationFinderStub, undefined); - await client.initialize(); - assert(client.cloudLocationFinderStub); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new cloudlocationfinderModule.v1.CloudLocationFinderClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('has close method for the initialized client', done => { - const client = new cloudlocationfinderModule.v1.CloudLocationFinderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.cloudLocationFinderStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has port', () => { + const port = cloudlocationfinderModule.v1.CloudLocationFinderClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has close method for the non-initialized client', done => { - const client = new cloudlocationfinderModule.v1.CloudLocationFinderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.cloudLocationFinderStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('should create a client with no option', () => { + const client = + new cloudlocationfinderModule.v1.CloudLocationFinderClient(); + assert(client); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new cloudlocationfinderModule.v1.CloudLocationFinderClient({ - 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 cloudlocationfinderModule.v1.CloudLocationFinderClient( + { + fallback: true, + }, + ); + assert(client); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new cloudlocationfinderModule.v1.CloudLocationFinderClient({ - 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 cloudlocationfinderModule.v1.CloudLocationFinderClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + assert.strictEqual(client.cloudLocationFinderStub, undefined); + await client.initialize(); + assert(client.cloudLocationFinderStub); }); - describe('getCloudLocation', () => { - it('invokes getCloudLocation without error', async () => { - const client = new cloudlocationfinderModule.v1.CloudLocationFinderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.locationfinder.v1.GetCloudLocationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.locationfinder.v1.GetCloudLocationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.locationfinder.v1.CloudLocation() - ); - client.innerApiCalls.getCloudLocation = stubSimpleCall(expectedResponse); - const [response] = await client.getCloudLocation(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getCloudLocation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCloudLocation 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 cloudlocationfinderModule.v1.CloudLocationFinderClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + client.initialize().catch((err) => { + throw err; + }); + assert(client.cloudLocationFinderStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes getCloudLocation without error using callback', async () => { - const client = new cloudlocationfinderModule.v1.CloudLocationFinderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.locationfinder.v1.GetCloudLocationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.locationfinder.v1.GetCloudLocationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.locationfinder.v1.CloudLocation() - ); - client.innerApiCalls.getCloudLocation = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getCloudLocation( - request, - (err?: Error|null, result?: protos.google.cloud.locationfinder.v1.ICloudLocation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getCloudLocation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCloudLocation 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 cloudlocationfinderModule.v1.CloudLocationFinderClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + assert.strictEqual(client.cloudLocationFinderStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes getCloudLocation with error', async () => { - const client = new cloudlocationfinderModule.v1.CloudLocationFinderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.locationfinder.v1.GetCloudLocationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.locationfinder.v1.GetCloudLocationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getCloudLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getCloudLocation(request), expectedError); - const actualRequest = (client.innerApiCalls.getCloudLocation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCloudLocation 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 cloudlocationfinderModule.v1.CloudLocationFinderClient( + { + 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 getCloudLocation with closed client', async () => { - const client = new cloudlocationfinderModule.v1.CloudLocationFinderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.locationfinder.v1.GetCloudLocationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.locationfinder.v1.GetCloudLocationRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getCloudLocation(request), expectedError); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new cloudlocationfinderModule.v1.CloudLocationFinderClient( + { + 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('listCloudLocations', () => { - it('invokes listCloudLocations without error', async () => { - const client = new cloudlocationfinderModule.v1.CloudLocationFinderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.locationfinder.v1.ListCloudLocationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.locationfinder.v1.ListCloudLocationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.locationfinder.v1.CloudLocation()), - generateSampleMessage(new protos.google.cloud.locationfinder.v1.CloudLocation()), - generateSampleMessage(new protos.google.cloud.locationfinder.v1.CloudLocation()), - ]; - client.innerApiCalls.listCloudLocations = stubSimpleCall(expectedResponse); - const [response] = await client.listCloudLocations(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listCloudLocations as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCloudLocations as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + describe('getCloudLocation', () => { + it('invokes getCloudLocation without error', async () => { + const client = new cloudlocationfinderModule.v1.CloudLocationFinderClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.locationfinder.v1.GetCloudLocationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.locationfinder.v1.GetCloudLocationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.locationfinder.v1.CloudLocation(), + ); + client.innerApiCalls.getCloudLocation = stubSimpleCall(expectedResponse); + const [response] = await client.getCloudLocation(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getCloudLocation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCloudLocation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listCloudLocations without error using callback', async () => { - const client = new cloudlocationfinderModule.v1.CloudLocationFinderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.locationfinder.v1.ListCloudLocationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.locationfinder.v1.ListCloudLocationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.locationfinder.v1.CloudLocation()), - generateSampleMessage(new protos.google.cloud.locationfinder.v1.CloudLocation()), - generateSampleMessage(new protos.google.cloud.locationfinder.v1.CloudLocation()), - ]; - client.innerApiCalls.listCloudLocations = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listCloudLocations( - request, - (err?: Error|null, result?: protos.google.cloud.locationfinder.v1.ICloudLocation[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listCloudLocations as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCloudLocations as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getCloudLocation without error using callback', async () => { + const client = new cloudlocationfinderModule.v1.CloudLocationFinderClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.locationfinder.v1.GetCloudLocationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.locationfinder.v1.GetCloudLocationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.locationfinder.v1.CloudLocation(), + ); + client.innerApiCalls.getCloudLocation = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getCloudLocation( + request, + ( + err?: Error | null, + result?: protos.google.cloud.locationfinder.v1.ICloudLocation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getCloudLocation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCloudLocation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listCloudLocations with error', async () => { - const client = new cloudlocationfinderModule.v1.CloudLocationFinderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.locationfinder.v1.ListCloudLocationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.locationfinder.v1.ListCloudLocationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listCloudLocations = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listCloudLocations(request), expectedError); - const actualRequest = (client.innerApiCalls.listCloudLocations as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCloudLocations as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getCloudLocation with error', async () => { + const client = new cloudlocationfinderModule.v1.CloudLocationFinderClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.locationfinder.v1.GetCloudLocationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.locationfinder.v1.GetCloudLocationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getCloudLocation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getCloudLocation(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getCloudLocation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCloudLocation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listCloudLocationsStream without error', async () => { - const client = new cloudlocationfinderModule.v1.CloudLocationFinderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.locationfinder.v1.ListCloudLocationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.locationfinder.v1.ListCloudLocationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.locationfinder.v1.CloudLocation()), - generateSampleMessage(new protos.google.cloud.locationfinder.v1.CloudLocation()), - generateSampleMessage(new protos.google.cloud.locationfinder.v1.CloudLocation()), - ]; - client.descriptors.page.listCloudLocations.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listCloudLocationsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.locationfinder.v1.CloudLocation[] = []; - stream.on('data', (response: protos.google.cloud.locationfinder.v1.CloudLocation) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listCloudLocations.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listCloudLocations, request)); - assert( - (client.descriptors.page.listCloudLocations.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes getCloudLocation with closed client', async () => { + const client = new cloudlocationfinderModule.v1.CloudLocationFinderClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.locationfinder.v1.GetCloudLocationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.locationfinder.v1.GetCloudLocationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getCloudLocation(request), expectedError); + }); + }); - it('invokes listCloudLocationsStream with error', async () => { - const client = new cloudlocationfinderModule.v1.CloudLocationFinderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.locationfinder.v1.ListCloudLocationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.locationfinder.v1.ListCloudLocationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listCloudLocations.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listCloudLocationsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.locationfinder.v1.CloudLocation[] = []; - stream.on('data', (response: protos.google.cloud.locationfinder.v1.CloudLocation) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listCloudLocations.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listCloudLocations, request)); - assert( - (client.descriptors.page.listCloudLocations.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + describe('listCloudLocations', () => { + it('invokes listCloudLocations without error', async () => { + const client = new cloudlocationfinderModule.v1.CloudLocationFinderClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.locationfinder.v1.ListCloudLocationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.locationfinder.v1.ListCloudLocationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.locationfinder.v1.CloudLocation(), + ), + generateSampleMessage( + new protos.google.cloud.locationfinder.v1.CloudLocation(), + ), + generateSampleMessage( + new protos.google.cloud.locationfinder.v1.CloudLocation(), + ), + ]; + client.innerApiCalls.listCloudLocations = + stubSimpleCall(expectedResponse); + const [response] = await client.listCloudLocations(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listCloudLocations as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCloudLocations as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listCloudLocations without error', async () => { - const client = new cloudlocationfinderModule.v1.CloudLocationFinderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.locationfinder.v1.ListCloudLocationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.locationfinder.v1.ListCloudLocationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.locationfinder.v1.CloudLocation()), - generateSampleMessage(new protos.google.cloud.locationfinder.v1.CloudLocation()), - generateSampleMessage(new protos.google.cloud.locationfinder.v1.CloudLocation()), - ]; - client.descriptors.page.listCloudLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.locationfinder.v1.ICloudLocation[] = []; - const iterable = client.listCloudLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listCloudLocations without error using callback', async () => { + const client = new cloudlocationfinderModule.v1.CloudLocationFinderClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.locationfinder.v1.ListCloudLocationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.locationfinder.v1.ListCloudLocationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.locationfinder.v1.CloudLocation(), + ), + generateSampleMessage( + new protos.google.cloud.locationfinder.v1.CloudLocation(), + ), + generateSampleMessage( + new protos.google.cloud.locationfinder.v1.CloudLocation(), + ), + ]; + client.innerApiCalls.listCloudLocations = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listCloudLocations( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.locationfinder.v1.ICloudLocation[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listCloudLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listCloudLocations.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.listCloudLocations as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCloudLocations as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listCloudLocations with error', async () => { - const client = new cloudlocationfinderModule.v1.CloudLocationFinderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.locationfinder.v1.ListCloudLocationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.locationfinder.v1.ListCloudLocationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listCloudLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listCloudLocationsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.locationfinder.v1.ICloudLocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listCloudLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listCloudLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listCloudLocations with error', async () => { + const client = new cloudlocationfinderModule.v1.CloudLocationFinderClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.locationfinder.v1.ListCloudLocationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.locationfinder.v1.ListCloudLocationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listCloudLocations = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listCloudLocations(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listCloudLocations as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCloudLocations as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('searchCloudLocations', () => { - it('invokes searchCloudLocations without error', async () => { - const client = new cloudlocationfinderModule.v1.CloudLocationFinderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.locationfinder.v1.SearchCloudLocationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.locationfinder.v1.SearchCloudLocationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.locationfinder.v1.CloudLocation()), - generateSampleMessage(new protos.google.cloud.locationfinder.v1.CloudLocation()), - generateSampleMessage(new protos.google.cloud.locationfinder.v1.CloudLocation()), - ]; - client.innerApiCalls.searchCloudLocations = stubSimpleCall(expectedResponse); - const [response] = await client.searchCloudLocations(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.searchCloudLocations as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.searchCloudLocations as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes listCloudLocationsStream without error', async () => { + const client = new cloudlocationfinderModule.v1.CloudLocationFinderClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.locationfinder.v1.ListCloudLocationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.locationfinder.v1.ListCloudLocationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.locationfinder.v1.CloudLocation(), + ), + generateSampleMessage( + new protos.google.cloud.locationfinder.v1.CloudLocation(), + ), + generateSampleMessage( + new protos.google.cloud.locationfinder.v1.CloudLocation(), + ), + ]; + client.descriptors.page.listCloudLocations.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listCloudLocationsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.locationfinder.v1.CloudLocation[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.locationfinder.v1.CloudLocation) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('invokes searchCloudLocations without error using callback', async () => { - const client = new cloudlocationfinderModule.v1.CloudLocationFinderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.locationfinder.v1.SearchCloudLocationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.locationfinder.v1.SearchCloudLocationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.locationfinder.v1.CloudLocation()), - generateSampleMessage(new protos.google.cloud.locationfinder.v1.CloudLocation()), - generateSampleMessage(new protos.google.cloud.locationfinder.v1.CloudLocation()), - ]; - client.innerApiCalls.searchCloudLocations = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.searchCloudLocations( - request, - (err?: Error|null, result?: protos.google.cloud.locationfinder.v1.ICloudLocation[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.searchCloudLocations as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.searchCloudLocations 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.listCloudLocations.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listCloudLocations, request), + ); + assert( + (client.descriptors.page.listCloudLocations.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes searchCloudLocations with error', async () => { - const client = new cloudlocationfinderModule.v1.CloudLocationFinderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.locationfinder.v1.SearchCloudLocationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.locationfinder.v1.SearchCloudLocationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.searchCloudLocations = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.searchCloudLocations(request), expectedError); - const actualRequest = (client.innerApiCalls.searchCloudLocations as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.searchCloudLocations as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes listCloudLocationsStream with error', async () => { + const client = new cloudlocationfinderModule.v1.CloudLocationFinderClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.locationfinder.v1.ListCloudLocationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.locationfinder.v1.ListCloudLocationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listCloudLocations.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listCloudLocationsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.locationfinder.v1.CloudLocation[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.locationfinder.v1.CloudLocation) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('invokes searchCloudLocationsStream without error', async () => { - const client = new cloudlocationfinderModule.v1.CloudLocationFinderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.locationfinder.v1.SearchCloudLocationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.locationfinder.v1.SearchCloudLocationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.locationfinder.v1.CloudLocation()), - generateSampleMessage(new protos.google.cloud.locationfinder.v1.CloudLocation()), - generateSampleMessage(new protos.google.cloud.locationfinder.v1.CloudLocation()), - ]; - client.descriptors.page.searchCloudLocations.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.searchCloudLocationsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.locationfinder.v1.CloudLocation[] = []; - stream.on('data', (response: protos.google.cloud.locationfinder.v1.CloudLocation) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.searchCloudLocations.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.searchCloudLocations, request)); - assert( - (client.descriptors.page.searchCloudLocations.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.listCloudLocations.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listCloudLocations, request), + ); + assert( + (client.descriptors.page.listCloudLocations.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes searchCloudLocationsStream with error', async () => { - const client = new cloudlocationfinderModule.v1.CloudLocationFinderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.locationfinder.v1.SearchCloudLocationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.locationfinder.v1.SearchCloudLocationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.searchCloudLocations.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.searchCloudLocationsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.locationfinder.v1.CloudLocation[] = []; - stream.on('data', (response: protos.google.cloud.locationfinder.v1.CloudLocation) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.searchCloudLocations.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.searchCloudLocations, request)); - assert( - (client.descriptors.page.searchCloudLocations.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listCloudLocations without error', async () => { + const client = new cloudlocationfinderModule.v1.CloudLocationFinderClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.locationfinder.v1.ListCloudLocationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.locationfinder.v1.ListCloudLocationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.locationfinder.v1.CloudLocation(), + ), + generateSampleMessage( + new protos.google.cloud.locationfinder.v1.CloudLocation(), + ), + generateSampleMessage( + new protos.google.cloud.locationfinder.v1.CloudLocation(), + ), + ]; + client.descriptors.page.listCloudLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.locationfinder.v1.ICloudLocation[] = + []; + const iterable = client.listCloudLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listCloudLocations.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listCloudLocations.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with searchCloudLocations without error', async () => { - const client = new cloudlocationfinderModule.v1.CloudLocationFinderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.locationfinder.v1.SearchCloudLocationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.locationfinder.v1.SearchCloudLocationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.locationfinder.v1.CloudLocation()), - generateSampleMessage(new protos.google.cloud.locationfinder.v1.CloudLocation()), - generateSampleMessage(new protos.google.cloud.locationfinder.v1.CloudLocation()), - ]; - client.descriptors.page.searchCloudLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.locationfinder.v1.ICloudLocation[] = []; - const iterable = client.searchCloudLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('uses async iteration with listCloudLocations with error', async () => { + const client = new cloudlocationfinderModule.v1.CloudLocationFinderClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.locationfinder.v1.ListCloudLocationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.locationfinder.v1.ListCloudLocationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listCloudLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listCloudLocationsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.locationfinder.v1.ICloudLocation[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listCloudLocations.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listCloudLocations.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('searchCloudLocations', () => { + it('invokes searchCloudLocations without error', async () => { + const client = new cloudlocationfinderModule.v1.CloudLocationFinderClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.locationfinder.v1.SearchCloudLocationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.locationfinder.v1.SearchCloudLocationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.locationfinder.v1.CloudLocation(), + ), + generateSampleMessage( + new protos.google.cloud.locationfinder.v1.CloudLocation(), + ), + generateSampleMessage( + new protos.google.cloud.locationfinder.v1.CloudLocation(), + ), + ]; + client.innerApiCalls.searchCloudLocations = + stubSimpleCall(expectedResponse); + const [response] = await client.searchCloudLocations(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.searchCloudLocations as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.searchCloudLocations as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes searchCloudLocations without error using callback', async () => { + const client = new cloudlocationfinderModule.v1.CloudLocationFinderClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.locationfinder.v1.SearchCloudLocationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.locationfinder.v1.SearchCloudLocationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.locationfinder.v1.CloudLocation(), + ), + generateSampleMessage( + new protos.google.cloud.locationfinder.v1.CloudLocation(), + ), + generateSampleMessage( + new protos.google.cloud.locationfinder.v1.CloudLocation(), + ), + ]; + client.innerApiCalls.searchCloudLocations = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.searchCloudLocations( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.locationfinder.v1.ICloudLocation[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.searchCloudLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.searchCloudLocations.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.searchCloudLocations as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.searchCloudLocations as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with searchCloudLocations with error', async () => { - const client = new cloudlocationfinderModule.v1.CloudLocationFinderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.locationfinder.v1.SearchCloudLocationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.locationfinder.v1.SearchCloudLocationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.searchCloudLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.searchCloudLocationsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.locationfinder.v1.ICloudLocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.searchCloudLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.searchCloudLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes searchCloudLocations with error', async () => { + const client = new cloudlocationfinderModule.v1.CloudLocationFinderClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.locationfinder.v1.SearchCloudLocationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.locationfinder.v1.SearchCloudLocationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.searchCloudLocations = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.searchCloudLocations(request), expectedError); + const actualRequest = ( + client.innerApiCalls.searchCloudLocations as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.searchCloudLocations 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 cloudlocationfinderModule.v1.CloudLocationFinderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - 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 cloudlocationfinderModule.v1.CloudLocationFinderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - 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 searchCloudLocationsStream without error', async () => { + const client = new cloudlocationfinderModule.v1.CloudLocationFinderClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.locationfinder.v1.SearchCloudLocationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.locationfinder.v1.SearchCloudLocationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.locationfinder.v1.CloudLocation(), + ), + generateSampleMessage( + new protos.google.cloud.locationfinder.v1.CloudLocation(), + ), + generateSampleMessage( + new protos.google.cloud.locationfinder.v1.CloudLocation(), + ), + ]; + client.descriptors.page.searchCloudLocations.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.searchCloudLocationsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.locationfinder.v1.CloudLocation[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.locationfinder.v1.CloudLocation) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - it('invokes getLocation with error', async () => { - const client = new cloudlocationfinderModule.v1.CloudLocationFinderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - 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.searchCloudLocations.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.searchCloudLocations, request), + ); + assert( + (client.descriptors.page.searchCloudLocations.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 cloudlocationfinderModule.v1.CloudLocationFinderClient({ - 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 searchCloudLocationsStream with error', async () => { + const client = new cloudlocationfinderModule.v1.CloudLocationFinderClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.locationfinder.v1.SearchCloudLocationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.locationfinder.v1.SearchCloudLocationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.searchCloudLocations.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.searchCloudLocationsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.locationfinder.v1.CloudLocation[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.locationfinder.v1.CloudLocation) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - it('uses async iteration with listLocations with error', async () => { - const client = new cloudlocationfinderModule.v1.CloudLocationFinderClient({ - 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.searchCloudLocations.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.searchCloudLocations, request), + ); + assert( + (client.descriptors.page.searchCloudLocations.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + + it('uses async iteration with searchCloudLocations without error', async () => { + const client = new cloudlocationfinderModule.v1.CloudLocationFinderClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.locationfinder.v1.SearchCloudLocationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.locationfinder.v1.SearchCloudLocationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.locationfinder.v1.CloudLocation(), + ), + generateSampleMessage( + new protos.google.cloud.locationfinder.v1.CloudLocation(), + ), + generateSampleMessage( + new protos.google.cloud.locationfinder.v1.CloudLocation(), + ), + ]; + client.descriptors.page.searchCloudLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.locationfinder.v1.ICloudLocation[] = + []; + const iterable = client.searchCloudLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.searchCloudLocations.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.searchCloudLocations.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); }); - describe('Path templates', () => { + it('uses async iteration with searchCloudLocations with error', async () => { + const client = new cloudlocationfinderModule.v1.CloudLocationFinderClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.locationfinder.v1.SearchCloudLocationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.locationfinder.v1.SearchCloudLocationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.searchCloudLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.searchCloudLocationsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.locationfinder.v1.ICloudLocation[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.searchCloudLocations.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.searchCloudLocations.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 cloudlocationfinderModule.v1.CloudLocationFinderClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + 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 cloudlocationfinderModule.v1.CloudLocationFinderClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + 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 cloudlocationfinderModule.v1.CloudLocationFinderClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + 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 cloudlocationfinderModule.v1.CloudLocationFinderClient( + { + 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 cloudlocationfinderModule.v1.CloudLocationFinderClient( + { + 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('cloudLocation', async () => { - const fakePath = "/rendered/path/cloudLocation"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - cloud_location: "cloudLocationValue", - }; - const client = new cloudlocationfinderModule.v1.CloudLocationFinderClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.cloudLocationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.cloudLocationPathTemplate.match = - sinon.stub().returns(expectedParameters); + describe('Path templates', () => { + describe('cloudLocation', async () => { + const fakePath = '/rendered/path/cloudLocation'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + cloud_location: 'cloudLocationValue', + }; + const client = new cloudlocationfinderModule.v1.CloudLocationFinderClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.cloudLocationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.cloudLocationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); - it('cloudLocationPath', () => { - const result = client.cloudLocationPath("projectValue", "locationValue", "cloudLocationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.cloudLocationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('cloudLocationPath', () => { + const result = client.cloudLocationPath( + 'projectValue', + 'locationValue', + 'cloudLocationValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.cloudLocationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); - it('matchProjectFromCloudLocationName', () => { - const result = client.matchProjectFromCloudLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.cloudLocationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('matchProjectFromCloudLocationName', () => { + const result = client.matchProjectFromCloudLocationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.cloudLocationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); - it('matchLocationFromCloudLocationName', () => { - const result = client.matchLocationFromCloudLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.cloudLocationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('matchLocationFromCloudLocationName', () => { + const result = client.matchLocationFromCloudLocationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.cloudLocationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); - it('matchCloudLocationFromCloudLocationName', () => { - const result = client.matchCloudLocationFromCloudLocationName(fakePath); - assert.strictEqual(result, "cloudLocationValue"); - assert((client.pathTemplates.cloudLocationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('matchCloudLocationFromCloudLocationName', () => { + const result = client.matchCloudLocationFromCloudLocationName(fakePath); + assert.strictEqual(result, 'cloudLocationValue'); + assert( + (client.pathTemplates.cloudLocationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-locationfinder/$1/webpack.config.js b/packages/google-cloud-locationfinder/$1/webpack.config.js index 46c88d4c3a98..775f622457fd 100644 --- a/packages/google-cloud-locationfinder/$1/webpack.config.js +++ b/packages/google-cloud-locationfinder/$1/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-lustre/.eslintignore b/packages/google-cloud-lustre/.eslintignore new file mode 100644 index 000000000000..cfc348ec4d11 --- /dev/null +++ b/packages/google-cloud-lustre/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/packages/google-cloud-lustre/.eslintrc.json b/packages/google-cloud-lustre/.eslintrc.json new file mode 100644 index 000000000000..3e8d97ccb390 --- /dev/null +++ b/packages/google-cloud-lustre/.eslintrc.json @@ -0,0 +1,4 @@ +{ + "extends": "./node_modules/gts", + "root": true +} diff --git a/packages/google-cloud-lustre/README.md b/packages/google-cloud-lustre/README.md index f942e3f16950..6dcaf5f480d5 100644 --- a/packages/google-cloud-lustre/README.md +++ b/packages/google-cloud-lustre/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-lustre/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-lustre/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-lustre/protos/protos.d.ts b/packages/google-cloud-lustre/protos/protos.d.ts index 2fcf821dacaa..3f6d7ac6622f 100644 --- a/packages/google-cloud-lustre/protos/protos.d.ts +++ b/packages/google-cloud-lustre/protos/protos.d.ts @@ -2585,6 +2585,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. */ @@ -2599,6 +2602,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 @@ -2689,6 +2695,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 { @@ -3309,6 +3412,9 @@ export namespace google { /** CommonLanguageSettings destinations */ destinations?: (google.api.ClientLibraryDestination[]|null); + + /** CommonLanguageSettings selectiveGapicGeneration */ + selectiveGapicGeneration?: (google.api.ISelectiveGapicGeneration|null); } /** Represents a CommonLanguageSettings. */ @@ -3326,6 +3432,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 @@ -4026,6 +4135,9 @@ export namespace google { /** PythonSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** PythonSettings experimentalFeatures */ + experimentalFeatures?: (google.api.PythonSettings.IExperimentalFeatures|null); } /** Represents a PythonSettings. */ @@ -4040,6 +4152,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 @@ -4118,6 +4233,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 { @@ -4444,6 +4671,9 @@ export namespace google { /** GoSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** GoSettings renamedServices */ + renamedServices?: ({ [k: string]: string }|null); } /** Represents a GoSettings. */ @@ -4458,6 +4688,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 @@ -4782,6 +5015,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, @@ -4898,6 +5234,7 @@ export namespace google { /** Edition enum. */ enum Edition { EDITION_UNKNOWN = 0, + EDITION_LEGACY = 900, EDITION_PROTO2 = 998, EDITION_PROTO3 = 999, EDITION_2023 = 1000, @@ -4928,6 +5265,9 @@ export namespace google { /** FileDescriptorProto weakDependency */ weakDependency?: (number[]|null); + /** FileDescriptorProto optionDependency */ + optionDependency?: (string[]|null); + /** FileDescriptorProto messageType */ messageType?: (google.protobuf.IDescriptorProto[]|null); @@ -4977,6 +5317,9 @@ export namespace google { /** FileDescriptorProto weakDependency. */ public weakDependency: number[]; + /** FileDescriptorProto optionDependency. */ + public optionDependency: string[]; + /** FileDescriptorProto messageType. */ public messageType: google.protobuf.IDescriptorProto[]; @@ -5111,6 +5454,9 @@ export namespace google { /** DescriptorProto reservedName */ reservedName?: (string[]|null); + + /** DescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents a DescriptorProto. */ @@ -5152,6 +5498,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 @@ -5999,6 +6348,9 @@ export namespace google { /** EnumDescriptorProto reservedName */ reservedName?: (string[]|null); + + /** EnumDescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents an EnumDescriptorProto. */ @@ -6025,6 +6377,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 @@ -6959,6 +7314,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); @@ -7017,6 +7375,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[]; @@ -7237,6 +7598,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. */ @@ -7475,6 +7951,9 @@ export namespace google { /** EnumValueOptions debugRedact */ debugRedact?: (boolean|null); + /** EnumValueOptions featureSupport */ + featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** EnumValueOptions uninterpretedOption */ uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); } @@ -7497,6 +7976,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[]; @@ -8089,6 +8571,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. */ @@ -8118,6 +8606,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 @@ -8240,6 +8734,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 o{"code":"deadline_exceeded","msg":"operation timed out"}